Easily Setup Seperate /home partition in Ubuntu!

Ok I have almost always had a seperate home partition, excluding the 3-10 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.

1. Reboot/Boot up your ubuntu live cd.
2. sudo aptitude update && sudo aptitude install gparted ntfsprogs
3. Then, press Alt-F2 and type:
gksudo gparted
4. In GParted, find the partition you want to resize in order to make room for your upcoming /home partition. In this case, I'm resizing /dev/hda5, but your partition may be different. Be sure to keep track of the names of your partitions--these names are very important (/dev/hda1, /dev/hdb1, /dev/sda2, etc.).
5. Right-click on the partition and choose the Resize/Move option.
6. Choose the new size you want.
7. Then, in the new empty space, right-click and select New.
8. Choose to create the partition as Filesystem ext3.
9. When you're satisfied with your new partition layout, click Apply
Once the changes have been applied, make note of the partition name of your new partition and then quit GParted.

Now, my original partition that I shrunk was /dev/hda5, and it created a new partition called /dev/hda7, and my /home folder lives on /dev/hda1. It's very important that you substitute in your own appropriate partition names for the ones I'm using--you most likely will have only two partitions you're dealing with--the one you shrunk and the newly created one.
Ok sweet now that is done, all we gotta do now is setup the new partition to be used...
Now, back in the terminal, I'm going to mount /dev/hda1 and /dev/hda7:

sudo mkdir /old
sudo mount -t ext3 /dev/hda1 /old
sudo mkdir /new
sudo mount -t ext3 /dev/hda7 /new

Now we're going to back up the /home directory on the old partition and move it to the new partition:
cd /old/home
find . -depth -print0 | sudo cpio --null --sparse -pvd /new/
sudo mv /old/home /old/home_backup
sudo mkdir /old/home

Yes, one of those lines looks really complicated--please type it as is--or, if you're unsure of your typing skills, copy and paste it into the terminal. Believe me--the command is necessary.

Next, we're going to specify to use the new home partition as /home:
sudo cp /old/etc/fstab /old/etc/fstab_backup

type blkid in terminal and find /dev/hda7 it will look something like this:
/dev/hda7/: UUID="8b89a5c4-20ff-477c-a49e-c1ccb435bf11" SEC_TYPE="ext2" TYPE="ext3"

Copy the "UUID=8b89a5c4-20ff-477c-a49e-c1ccb435bf11"
sudo nano /old/etc/fstab

You'll then be taken to the nano text editor. Add in these lines:
# /dev/hda7
UUID=8b89a5c4-20ff-477c-a49e-c1ccb435bf11 /home ext3
Then save (Control-X), confirm (Y), and exit (Enter)

After you reboot, you should be now using your new /home partition.

If you find that you are running out of room on your old partition and you're pretty confident everything is working as it should be, then go ahead and delete the backup of home:
sudo rm -rf /home_backup

What if this doesn't work?
You know, it really should work, but if you somehow messed up your /etc/fstab and didn't configure it correctly... well, that's why we have a live CD, so we can fix things.

Boot up the live CD, go to a terminal, and type:
sudo mkdir /recovery
sudo mount -t ext3 /dev/hda1 /recovery
sudo cp -R /recovery/home_backup /recovery/home
sudo cp /recovery/etc/fstab_backup /recovery/etc/fstab

Clicky Web Analytics