21

I am installing an SSD and would like to put / on the SSD and /home, /var, and /tmp on the HDD. My current distro is Kubuntu but I would not mind trying another distro if this procedure can be accomplished easier there. I have installed many different Linux OSes on multiple partitions, however I know of no installer that lets one mount multiple directories on a single partition. I would rather not use three separate partitions as particularly /home, /var, and /tmp are prone to large changes in size and it is not practical to allot each of them some arbitrary maximum.

Note that I am discussing a new install, not moving the current system to the SSD / HD split.

dotancohen
  • 15,864

1 Answers1

30

There are two approaches you can use. For either approach, you need first mount your hard disk partition wherever (for example, under /hd) and also add it to /etc/fstab, then create home, var, and tmp inside the mount.

  1. Use symlinks. Then create symlinks from /home to /hd/home, etc.

  2. Instead of symlinks, use bind mounts. Syntax is mount --bind /hd/home /home. You can (should) also put that in fstab, using 'bind' as the fstype.

The basic way to get it to install like that is to set up the target filesystem by hand before starting the actual install. I know its easy enough with debian-installer to use the installer to create your partitions, mount, and then switch to a different terminal (say, alt-f2), cd into /target, and create your symlinks (or bind mounts). Then switch back to alt-f1 and continue the install. Ubuntu's (and I assume Kubuntu's) installers are based on debian-installer, so I assume similar is possible.

derobert
  • 109,670
  • Thank you. In fact Ubuntu is soon dropping support for debian-installer! I will play around with the two approaches, I am not familiar with mount's bind option. – dotancohen Sep 05 '12 at 13:16
  • 8
    For a comparison between symlinks and bind mounts, see this question: http://unix.stackexchange.com/questions/49623/are-there-any-drawbacks-from-using-mount-bind-as-a-substitute-for-symbolic-lin – Flimm Jul 03 '13 at 16:26
  • 1
    My Apache2 install wouldn't follow a symlink. mount --bind worked perfectly and required no Apache config change or restart. – Jacob Bruinsma May 15 '22 at 01:07