3

I have a Linux Ubuntu machine which has an X GB hard disk. There is folder, say, /opt/software/data. The disk /dev/sda1 is almost full and I have attached another disk at /dev/sda2 which is mounted at /hdd2.

Is it possible for me to link the folders /opt/software/data with /hdd2/software/data so, that every file get stored in the /hdd2/software/data but may be referred from the /opt/software/data?

I can't do a reinstall of the software that creates this data, to change the default location of storage.

2
  • Please edit the question, it's hard to understand what's going on there. And please use commas and formatting!
    – gronostaj
    Nov 11, 2013 at 9:06
  • @gronostaj Done!
    – Jawa
    Nov 11, 2013 at 9:49

1 Answer 1

5

The easiest way to do this is:

  1. Stop the application
  2. copy the data from the old to the new location: rsync -av /opt/software/data /hdd2
  3. rename the old data directory: mv /opt/software/data /opt/software/data.old
  4. create a symlink so /opt/software/data points to hdd2: ln -s /hdd2 /opt/software/data
  5. start the application
  6. if all works well: rm /opt/software/data.old
3
  • thanks man, I'll try it, and mark it an answer if it clicks out for me Nov 11, 2013 at 9:09
  • why do you not simply do mv /opt/software/data /hdd2?
    – markling
    Apr 11, 2023 at 8:23
  • I would add to this step 0. run the program to check it works and how it handles login/user accounts etc.
    – markling
    Apr 11, 2023 at 9:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .