I have a computer with an SSD and an HDD. I want to put the directories that do not change often in the SSD and the ones that do in the HDD. This means keeping root / in the SSD, along with most paths by default, and putting in the HDD /home, /opt, /root, /tmp, and /var, if I'm not mistaken.
There are two options: symlinks and bind mounts in fstab. This is explained in many questions:
- How to mount multiple directories on the same partition?
- Are there any drawbacks from using mount --bind as a substitute for symbolic links?
- How to mount multiple directories on the same partition?
- Mapping the home folder to a different location in fstab
- How to re-mount a different partition as /home?
- Can I change the /home folder after ubuntu installation?
- Debian install, mounting /var /tmp /home in the same partition
- Many more...
Each method has different pros and cons. The biggest problems being that symlinks are not transparent (e.g. to cd or pwd), and that bind duplicates the paths and the data accessed, (e.g. when using find).
Of these two problems, the latter seems easier to solve, but I could not find any mention to this in the previous links, hence I have to ask if there is any solution or not.
I think that the best solution may be binding the previous paths (/home, /opt, /root, /tmp, and /var) as subpaths of /.hdd (a new one, defined as mount point in the HDD partition) and then hiding /.hdd to avoid the problems that arise when binding the directories. The question is how to hide /.hdd in the easiest and most effective way without breaking anything. I can think of two ways.
- Setting its permissions to 000, which may not be very useful as root or when sudoing.
- Using chroot, which may break some things.
These options are not mentioned by anyone so I guess they are useless or worse than useless, why? Are there any good options? (to make /.hdd as invisible as possible, while subpaths remain binded transparently).