0

I have a PC with an SSD and an HDD. I'm running Linux. I wish to put all the static (very rarely changing) files on the SSD and the rest on the HDD. To achieve that I'd like to have /boot, /usr, /lib, /bin, /etc, /opt on the SSD and the rest - /var, /tmp, /home on the HDD. However, I don't want to create a separate partition for each of them, I want each group to be on its own partition. I suppose that I could mount the SSD to /, the HDD to /mnt/hdd and symlink /home, etc. to point to /mnt/hdd/home, etc.

Are there problems I can expect with such a setup? Such as a program attempting to read from/write to /var early in the boot process before the HDD is mounted? Will logging work as normal if /var (and /var/log) aren't on the root partition?

What would be the best way to solve this?

2 Answers 2

1

So, after more digging around, I found this is the correct incantation for a systemd-based setup:

# 
# /etc/fstab: static file system information
#
# <file system>        <dir>         <type>    <options>          <dump> <pass>
devpts                 /dev/pts      devpts    defaults            0      0
shm                    /dev/shm      tmpfs     nodev,nosuid        0      0

UUID=246b032f-0633-459a-867c-6013304c5b8d swap     swap defaults                             0 0
UUID=64ed9a87-7860-4538-bef6-05eff29ed5c1 /        ext4 defaults,noatime,nodiratime,iversion,fail 0 1
UUID=e3b656bf-69c8-4b2a-bad8-6c051559b43f /mnt/hdd ext4 defaults,noatime,nodiratime,iversion,x-initrd.mount,fail 0 1
/mnt/hdd/home                             /home    none rw,rbind,x-systemd.automount,fail 0 0
/mnt/hdd/root                             /root    none rw,rbind,x-systemd.automount,fail 0 0
/mnt/hdd/tmp                              /tmp     none rw,rbind,x-initrd.mount,fail 0 0
/mnt/hdd/var                              /var     none rw,rbind,x-initrd.mount,fail 0 0
UUID=B084-4D66                            /boot/efi vfat defaults,noauto,noatime,nodiratime,iversion 0 2

For whatever reason, tmp and var have to be x-initrd.mount, while home and root have to be x-systemd.automount. Hope this helps someone else.

0

Use mount --bind, e.g. mount --bind /mnt/hdd/home /home

From the mount man page:

After this call the same contents is accessible in two places. One can also remount a single file (on a single file).

(Note that this binding does not follow other mounts, so if you have a separate partition mounted on /boot, then doing mount bind / /troll/root will not include anything from the /boot partition. If you want a recursive bind, use --rbind.)

To do this in fstab, put none in the FS column and bind in the options column, e.g.

/mnt/hdd/home       /home       none       bind

According to the fstab man page, "The order of records in fstab is important because fsck(8), mount(8), and umount(8) sequentially iterate through fstab doing their thing", so entries like this should appear after (below) the entry mounting a physical device on /mnt/hdd/home.

I'm not aware of any problems with this approach, but I have not tried the setup you describe. I have used a separate partition for /var/log without problem, and I wouldn't expect a bind mount to have any additional effect. If you're not booting from /, I would use a separate partition just for /boot, because it must be handled a certain way by the bootloader.

2
  • Thank you. Is the order of entries in /etc/fstab deterministic (i.e. from top to bottom, I'd expect) and is it still deterministic under systemd?
    – Moshev
    Commented Nov 15, 2014 at 19:22
  • Updated to address the order of fstab entries. Commented Nov 15, 2014 at 19:37

You must log in to answer this question.

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