Microwave Biscuit

Move /home to it’s own partition

Posted in Linux, ubuntu by microwavebiscuit on November 12, 2007

I have long heard about the benefits of moving /home to its own partition and I have really wanted to do so, however I was concerned about breaking something so I haven’t done it until now. Last night I found this post:

Move /home to it’s own partition « Ubuntu Blog

Which goes back a ways but by reading the whole post and the comments I was able to easily move my home folder to its own partition. To recap the steps (including changes/deviations to the original authors steps) here you go:

1. Create a new partition – this could be a new drive, resize and existing drive, etc. In my case I resized an under-used disk I have (hdb1) and allowed for 50 Gib of space for /home. I did this with Gnome Partion Manager (GParted). Probably a bit more space than I needed as my existing home folder is roughly 1 gig but as I said the disk is underused as it is. My new partition is hdb2. If you are doing this, you should change hdb2 in my steps to whatever your new drive is.
2. As per the original article, make a new directory and mount the partition:

$mkdir /mnt/newhome
$sudo mount -t ext3 /dev/hdb2 /mnt/newhome

3. Next I had to deviate a bit to get everything copied correctly. I did:

sudo find . -depth -print0 | sudo cpio --null --sparse --preserve-modification-time -pvd /mnt/newhome/

Which copied everything over and preserved the modification times. The reason for preserving the modification times is so that using a tool like Krusader you can compare directories and make sure everything in your existing /home folder is in /newhome
4. Unmount the /newhome new partition:

$sudo umount /mnt/newhome

5. Move your existing home folder (note: you should have already made sure everything was moved cleanly before this step!!!!)

$sudo mv /home /old_home

6. Make a new “home” for /home:

sudo mkdir /home

7. Mount the new home:

$sudo mount /dev/hda5 /home

8. Modify your /etc/fstab file:

sudo gedit /etc/fstab

and add the line:

/dev/hdb2 /home ext3 nodev,nosuid 0 2

9. I then rebooted my computer, made sure everything is working right and finally:

$sudo rm -r /old_home

which will get rid of your old home directory.

So, with everything in place I now have /home on it’s own partition. This allows for the re-installation of everything should I corrupt my system without losing all of my crucial data. If I have to re-install all of the executables on my system that’s a piece of cake – just get a new CD of Ubuntu and go. If I lost my /home folder it would be a lot harder to recover from. This doesn’t take the place of backups – regular backups are still crucial. It’s just that by having /home on its own partition you segregate the operating system from your data.


One Response

Subscribe to comments with RSS.

  1. Trey said, on November 12, 2007 at 9:24 pm

    I used this one on my first install, worked perfectly


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: