Easily Create Seperate Home partition with existing Drive or Partition without the need for a livecd in Ubuntu Linux

I recently wanted to create a seperate /home partition since I installed home on / and didnt want the hassle of waiting for the livecd to boot, so here is an easy tutorial that will explain how to setup a seperate /home partition with an existing empty drive or partition you already have without using a livecd.

Ok I have almost always had a seperate home partition, excluding the 3 times I have completely crashed my system and had to redo it all.

Reasons you should use a seperate home partition:
1. Easy backup/restore.
2. You can simply rm -rf / and pop in a livecd and be able to mount your home partition as /home without deleting users home directories and files.
3. You can use multiple linux Distro's with the /home partition
4. You dont have to worrie about the hassle of re-installing or upgrading ubuntu because everything you need is in your /home directory, you can simply backup all your apt packages via aptoncd.
5. You will get better performance accessing files in your /home directory since it is seperate from the filesystem.

First we sudo root then open/edit our /etc/fstab:
sudo -s
sudo gedit /etc/fstab

Now this is the line my fstab contained that we will comment out by putting a "#" symbol in front of the UUID of the empty drive
# /dev/sdb1
UUID=ffa4a03e-116f-4c41-8bb6-4f60bca8f7f9 /media/sdb1 ext3 defaults,noatime,errors=remount-ro 0 0

It will then look like this:
# /dev/sdb1
# UUID=ffa4a03e-116f-4c41-8bb6-4f60bca8f7f9 /media/sdb1 ext3 defaults,noatime,errors=remount-ro 0 0


Now lets scroll down to the bottom of the file and Create a new Line to make our empty disk be mounted as /home
# /dev/sdb1
UUID=ffa4a03e-116f-4c41-8bb6-4f60bca8f7f9 /home ext3 defaults,noatime,errors=remount-ro 0 0


Ok the Hard stuff is done, so we Save /etc/fstab with ctrl-s and exit, lets go back to the terminal and cd to /home:
cd /home
Ok now that we are in home we can issue our copy command to copy the contents of /home to our existing partition in /media/sdb1 as an example:
find . -depth -print0 | sudo cpio --null --sparse -pvd /media/sdb1/
Once this completes which will take a while if you have allot of data we mv the contents of our existing /home to a backup directory:
mkdir /oldhome
mv -R * /oldhome

Ok we are done, simply reboot and everything should be successful, if for some reason this doesn't work all you do is uncomment the fstab line we first edited and comment out the newest line or completely remove it, then umount /dev/"yourdrive" if it mounted, and cd /oldhome/ mv -R * /home and everything should be back to what it was when you rebooted

This took me 5 min to create and is very dangerous if you dont know what you are doing, do not attempt this.

I have an alternate tutorial that explains how to do the same thing above with instructions on creating a new partition here

Clicky Web Analytics