0

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:

  1. How to mount multiple directories on the same partition?
  2. Are there any drawbacks from using mount --bind as a substitute for symbolic links?
  3. How to mount multiple directories on the same partition?
  4. Mapping the home folder to a different location in fstab
  5. How to re-mount a different partition as /home?
  6. Can I change the /home folder after ubuntu installation?
  7. Debian install, mounting /var /tmp /home in the same partition
  8. 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.

  1. Setting its permissions to 000, which may not be very useful as root or when sudoing.
  2. 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).

Trylks
  • 393
  • 1
  • 2
  • 9
  • Sorry for the long link list, I tried to make clear that this is not a duplicate of those or similar questions. I know this kind of questions look like duplicates easily. – Trylks Dec 15 '17 at 01:43
  • Why not make individual partitions in the HDD for these? Partitions are cheap. Also, if /opt changes often for you, /usr might too, and at that point, there's not much left in /. – muru Dec 15 '17 at 03:12
  • I've never tried what happens if you first rebind things from /.hdd and 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:01
  • Your requirement seems to be the opposite of what many people want, iwhich is for the fast SSD to be used for often changing data. In any case, you might also look at automatic caching solutions like bcache and dm-cache, or mount -t overlay. – meuh Dec 15 '17 at 08:45
  • @meuh apparently, SSDs are much better than years ago but still less durable to writing in them than HDDs. WRT caches, they make installation and maintenance more difficult, and the performance is never as good as just using the SSD. – Trylks Dec 16 '17 at 19:22
  • @UlrichSchwarz I don't think you can mount anything on non-empty directories, how do you propose to do it? Using the mount command, fstab, or something else? – Trylks Dec 16 '17 at 19:24
  • @muru the problem with the partitions is that I have about 500GB for everything and more partitions means more likelihood that one of them will be full and others will have spare space. With a single partition, sharing the space is easier. Many things would go to the hdd, but / 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
  • @Trylks: you definitely can mount on a non-empty directory and then not see its contents anymore, that's a common pitfall when you run out of space and then want to move, say, /home to a separate partition. – Ulrich Schwarz Dec 16 '17 at 19:45
  • If you are willing to use btrfs, then answer #6 in this archlinux forum seems to show how you can mount btrfs subvolumes to achieve a multi-disc setup. – meuh Dec 16 '17 at 20:26
  • @muru I was considering to use /opt for databases (I have traditionally seen databases stored in /opt, I may create /data for databases and datasets, though). With respect to /usr it does not seem to change that much In fact, /usr is 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
  • @UlrichSchwarz you are right, that effectively hides the /.hdd folder. I even added it as a rule (last one) in fstab, but for some reason I need to run mount -a every 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

0 Answers0