I had a Linux box with two disks:
/dev/sda: fast SSD, ~200 GB; operating system installed here/dev/sdb: large HDD, ~4 TB; empty
The obvious option would be to create a mount point like /storage and mount /dev/sdb there. But after reading about intelligent partitioning and the recommended Debian partitioning scheme, I wanted to move /var, /home, and /tmp to the big disk, not as three separate partitions, but all living together in one partition on /dev/sdb.
The key distinction Link to heading
This approach is different from the usual fstab method. The typical fstab approach is one-directory-per-partition: /home on its own partition, /var on another. Here, we use a single partition on /dev/sdb and store all three directories inside it, using bind mounts to make them appear at their expected root filesystem locations.
The three original directories stay on /dev/sda but remain empty. Their actual contents live on /dev/sdb, with bind mounts linking the two.
Process Link to heading
1. Back up your data. Seriously.
2. Boot from a live distribution (e.g., KNOPPIX) to work on unmounted filesystems.
3. Mount both disks:
mkdir /mnt/sda1 /mnt/sdb1
mount /dev/sda1 /mnt/sda1
mount /dev/sdb1 /mnt/sdb1
4. Copy the directories from the SSD to the HDD, preserving all attributes and permissions:
cp -ax /mnt/sda1/{home,tmp,var} /mnt/sdb1/
5. Rename the originals and create empty mount points:
mv /mnt/sda1/home /mnt/sda1/home.old
mv /mnt/sda1/tmp /mnt/sda1/tmp.old
mv /mnt/sda1/var /mnt/sda1/var.old
mkdir /mnt/sda1/{home,tmp,var}
6. Update /etc/fstab to mount the second disk and create the bind mounts:
# Mount the second disk
/dev/sdb1 /mnt/sdb1 ext4 defaults 0 2
# Bind mount the moved directories
/mnt/sdb1/home /home none defaults,bind 0 0
/mnt/sdb1/tmp /tmp none defaults,bind 0 0
/mnt/sdb1/var /var none defaults,bind 0 0
7. Unmount and reboot:
umount /mnt/sda1
umount /mnt/sdb1
reboot
8. Verify that /home, /var, and /tmp are working correctly, then delete the .old backups once you’re confident.
Variations Link to heading
- Single-user mode instead of a live distro: You can do this without booting from external media by switching to single-user mode, though you’ll need to adapt the mount paths accordingly.
- With LVM: If your root disk uses LVM, you can create a new logical volume and copy directly into it without needing to boot from a live system; just work with the LV while the VG is active.
This process works for any root subdirectory you want to relocate, with the exception of /boot, which must remain on a partition the bootloader can access directly.