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).
/optchanges often for you,/usrmight too, and at that point, there's not much left in/. – muru Dec 15 '17 at 03:12/.hddand then try to mount something else over the mountpoint/.hdd, but if that works, that might be useful to consider? – Ulrich Schwarz Dec 15 '17 at 07:01bcacheanddm-cache, ormount -t overlay. – meuh Dec 15 '17 at 08:45/would still keep the core things, and make them faster, I don't have much space in the SSD anyway, so... – Trylks Dec 16 '17 at 19:26/hometo a separate partition. – Ulrich Schwarz Dec 16 '17 at 19:45/optfor databases (I have traditionally seen databases stored in/opt, I may create/datafor databases and datasets, though). With respect to/usrit does not seem to change that much In fact,/usris the primary use for the SSD, binaries should run fast, it may take significant space, and they should not change too often (about some files every week, but no file changing every day). That is to the best of my understanding, I would be happy to be corrected if wrong. – Trylks Dec 20 '17 at 18:53/.hddfolder. I even added it as a rule (last one) in fstab, but for some reason I need to runmount -aevery time, as every other mount seems to work from the start but that one. Do you have any idea about why could that happen? – Trylks Dec 21 '17 at 00:43