7

I have a problem with binding two directories. The problem comes that storage on hard disk is almost run out and I install another disk moving files in ~/Documents/ into one folder of the new disk. I still want mount --bind folder_on_new_disk ~/Documents, thus I will not change my favor.

The problem is that could I add an item in /etc/fstab to achieve this automatically when system startup?

2 Answers 2

17

You can add this to fstab as follows:

/mnt/new_disk/folder /home/[username]/Documents    none    bind    0 0

Replace the correct folder name, and the username where the documents folder is. It also presumes the /home directory is where your user folders are, so adjust accordingly if not.

6

@Paul's fstab example is, basically, the way to go if you want an answer to the question as asked. However, I would suggest that unless you have specific reasons for only moving your documents, it might not be a bad idea to move the whole /home directory to the new disk, and use the same technique to bind /home to its new location (or even just move /home/* to the root of a partition on the new drive and mount that partition at /home). This will provide two major benefits:

  1. You are likely to get more space for your home directory.
  2. You completely separate the operating system, system-wide configuration files and application binaries from your own files.

The point on separation to me is the bigger issue: it means that if you need to reinstall the OS for some reason, you won't have to worry anywhere near as much about your personal files (e-mails, documents, music, etc etc).

Unix mount points are a very flexible construct - do take advantage of that.

0

You must log in to answer this question.

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