I'd like to create the following situation:

  • A separate partition for my user's home directory,
  • A second separate partition for ~/Documents, and
  • A third separate partition for ~/Videos and ~/Music.

Achieving the first point doesn't seem to be hard, and that's already covered in questions like: How can I move the home directory to a separate partition?

Achieving the other two goals should follow the same pattern, but I'm not sure if I have to take care of the order of mounting somewhere/-how (i.e., first /home/user, then /home/user/whatever) . AFAIK the order in /etc/fstab doesn't matter at all.

While it might be easier to set up, I don't want to make the XDG directories symbolic links, unless other solutions were overly complex.

  • Yes, you have to mount in order, I just tested and it hid the existing directory when I mounted something to its containing directory. – Kevin Dec 5 '11 at 15:32
  • Its time you consider automounter (or autofs) for better options. Wherein, given for user requirements, you can have seperate user specific partitions on a share/partitions like user1_Documents, user1_Videos, user1_Music and have them mounted under /home/user1/{Documents,Videos,Music} respectively. It can get difficult when you have many partitions to manage otherwise though.. – Nikhil Mulley Dec 5 '11 at 16:23

TL,DR: I recommend symlinks.

If you mount a partition to a mount point that isn't in the root partition, you must take care to mount the host partition first and unmount the host partition first. For example, if you have separate partitions for /, /home and /home/htorque/Documents, then you must mount /home before /home/htorque/Documents. If you list the partitions in /etc/fstab, then it's enough to list /home before /home/htorque/Documents, since the entries are mounted in order at boot time. Thus nested mount points are not a problem in normal operation.

Nested mount points can be a problem in unusual circumstances. Suppose the disk containing one of the partition crashes, or you're doing maintenance such as unmounting a filesystem to move it to a different disk. You cannot unmount /home unless you've unmounted the partitions whose mount point is on it. If /home is not mounted at boot time because its filesystem is damaged, then /home/htorque/Documents will not be mounted either. Should you decide to rename /home/torque/Documents, you'll need to unmount the partition first. Furthermore, if at any point /home/htorque/Documents is not mounted and you accidentally drop a file in that directory, then the file will mysteriously vanish when you then mount /home/htorque/Documents.

One case where you will not be able to (conveniently) use mount points under your home directory is if it is encrypted and mounted when you log in, for example the way Ubuntu uses ecryptfs if you ask for your home directory to be encrypted. You would have to mount the other partitions manually (or from a login script) afterwards, and to be careful to unmount them before logging out.

A limitation which may or may not be relevant is that if you want your home directory not to be publicly readable but you do want e.g. your music to be publicly readable, then the path to your music directory must not go through your home directory. This is another argument against mount points under your home directory in a specific cirsumstance.

Bind mounts won't buy you much here. They're useful when a symbolic link won't do, for example when you need files to be available in a chroot. But they combine the heavy maintenance of mount points with some of the downsides of symbolic links (the files also exist elsewhere) plus downsides of their own (multiple canonical paths to a file require special care when doing backups, among other things).

So I recommend to create partitions mounted directly on the root partition (not necessarily directly underneath the root directory), and to create symbolic links. Or you can configure different path for those directories in ~/.config/user-dirs.dirs.

  • While I wouldn't consider any of the unusual circumstances you mention a real problem in my case, in my opinion this answer explains best what you have to think about when taking that route. Given that my underlying goal is to reduce complexity of my partition chaos, I think the three answers have changed my mind. ;) – htorque Dec 5 '11 at 21:15

Symlinks are much easier than other approaches, but I wouldn't call them a "clean" approach - If you delete a symlink, for example, you only delete the link, not the file it points to, resulting in what looks like inconsistent behavior. You can use for example bind mounts:

mount --bind /media/my-disk /home/user/Documents

Those are generally indistinguishable from the real thing.

  • This is doing the trick for sharing a folder between a dual boot Win/Linux system in which I share a folder from Windows to Linux. Thank you. – Geppettvs D'Constanzo May 26 '18 at 22:28

Symbolic links for the subdirs of home is by far the cleanest approach.

While I think you could use a filesystem overlay, it'll be a lot more complex to initialize the directories when you create a new user - you'd need to create new branches for each directory or use pseudo links (which are effectively little different from symbolic links).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.