Ubuntu – Mount a directory in another partition as /home directory

home-directorymount

I have tried to create a separate /home partition for all my linux distros and separate all home directories as per the name of the distros i am using like

/homepartition/ubuntu/user-name

/homepartition/debian/user-name

now, I have copied all the neccessary files to this new location and modified the /etc/fstab to mount this new location as the /home directory

I added this line at the last of the file

/dev/sda10/ubuntu /home ext4 nodev,nosuid 0 2

But the folder is not mounting. I am pretty much just a newbie,so please help me out.

Best Answer

Instead of adding /dev/sda10/ubuntu /home ext4 nodev,nosuid 0 2 to your /etc/fstab you can add these two lines:

/dev/sda10 /all-homes ext4 nodev,nosuid 0 2
/all-homes  /home none bind 0 0

You need to make the directory with sudo mkdir /all-homes and be sure that there is no other fstab entry that mounts in /home

The bind type in fstab (and as an mount option) makes the kernel "mirror" one folder in to an other and it seems to me that what just what you wanted (btw this approach should work on all modern linux's, as far as I remember from kernel version 2.6 and forward..)