Quantcast
Viewing latest article 21
Browse Latest Browse All 24

How to move /home directory to a separate partition

Having /home directory on a separate partition is a good idea; because you'll have your personal files safe if something happens to your installation. But if you didn't do that when you were installing your distro, follow this tutorial and you'll have your /home directory sitting comfortabely on its own partition!
So fire up your terminal and let's get started.

First we need a new place for our new /home (note that you have to execute all commands as root):

# mkdir /mnt/newhome

ٔNow we need to mount it. Note that you need to replace the sda5 with your own partition number. In here, sda5 stands for the fifth partition in the first SCSI disk (or just hard disk):

# mount -t ext4 /dev/sda5 /mnt/newhome


Now we should copy the original /home directory to its new location, but since it has hard links and other suff in it, we cannot copy it normally and we need to add a few options. Then we will delete the original /home and mount the new one in its final place. So issue these commands one by one (after executing one, wait until you see the prompt again, then continue):

# cd /home
# cp -ax * /mnt/newhome
# cd /
# rm -r /home
# mkdir /home
# umount /dev/sda5
# mount -t ext4 /dev/sda5 /home

Now keep in mind that you have to replace sda5 with your own partition.
We're almost there. We just need to edit the /etc/fstab file and add our new entry for new /home:

# nano /etc/fstab

Now go to the end of the file, and add this line. Make sure they are in the right place (I don't think I would have to mention that note about sda5 again!!!):

 /dev/sda5    /home    ext4    nodev,nosuid    0  2


That's it. Enjoy the new location for your /home!

Viewing latest article 21
Browse Latest Browse All 24

Trending Articles