Search This Blog

Sunday 12 September 2010

Ubuntu separate home partition

I wanted to do this to avoid potential issues when upgrading (which I did, today, to Lucid).

These are the guides I used:


Creating A seperate Home Partition In Ubuntu

gnome-dev-harddiskRunning your Ubuntu installation with a separate home partition has many benefits, mainly being easier distribution upgrade (which is every six months) which enables you to upgrade the operating system in isolation, leaving your home folder along with all your documents untouched. The process of creating a separate home partition is slightly tricky but not at all impossible

Creating A Separate Home Partition

Note: you will need your Ubuntu live CD, as a security measure Ubuntu does not allow editing of the partition where the operating system resides on.
1. Boot into your live CD session
2. Using Gparted, resize your operating system partition (usually sda1 or hda1) to approximately 6GB, you can choose any size for your operating system partition however it musnt’nt be less that 4GB.
3. create a new partition to fill the free space you have just created in step 2
4. Now boot into your installed Ubuntu system and open the terminal, Mount the partition you created in step 3 (replace sda3 with your new home partition designation, quick way to check is to use your system monitor >>f ile systems)
$sudo mount /dev/sda3
alternatively you may also mount this partition using the places menu in the top panel, if you feel more comfortable using the graphical user interface

5. Copy your home folder over to the new partition (again replace sda3 with your new home partition designation, quick way to check is to use your system monitor >>f ile systems)
$sudo cp /home /media/sda3
6. Change the permission of your new home partition so that your account has access to it’s files
$sudo chown username:username /media/sda3/ -R
7. We need to back up your current home partition, just in case anything goes wrong. Type in the following command
$sudo mv /home /old_home
8. Now we have finished preparing the new partition, we will now set the new partition as the home folder.
$sudo mkdir /home
9. Lastly we need to set the new partition to mount as the home folder everytime the system boots
sudo gedit /etc/fstab
This will open a text file in Gedit, enter the following lines to the end of that file
/dev/sda3 /home ext4 nodev,nosuid 0 2
Take note of the partition designation,replace sda3 with the designation of your new home partition and also replace ext4 with the filesystem type that you created your new partition with.
Save the file and reboot your computer. Your pc should now be using your separate home partition as its home folder. If anything went wrong and it doesnt work, boot into your live CD session to rescue your old home from the /old_home folder

Restoring your seperate home folder partition after upgrade/new installation

The process of restoring your separate partition to the home folder is similar to the process above.
1. Boot into your newly installed Ubuntu operating system
2. Back up your home folder
$sudo mv /home /old_home
3 create a mount point for your separate home partition
$sudo mkdir /home
4, Mount your home partition and change its file permission (note change sda3 to the name of your home partition)
$sudo mount /dev/sda3
$sudo chown username:username /media/sda3/ -R
5. Edit your fstab file
sudo gedit /etc/fstab
This will open a text file in Gedit, enter the following lines to the end of that file
/dev/sda3 /home ext4 nodev,nosuid 0 2
Reboot your computer and presto, your separate home partition is restored
Thats it all done, I hope this was a useful and informative guide to getting your home folder onto a separate partition


From http://tecverse.com/software/creating-a-seperate-home-partition-in-ubuntu.html

and

his tutorial will explain How to Create a separate /home partition in Ubuntu.
Advantage
If Ubuntu for some reason crashes and becomes unbootable and unfixable reinstalling will not delete all of your important data and settings. You simply specify the /home partition to be mounted at /home when reinstalling.

Disadvantages
Partitioning can end very badly if you dont know what your doing.
To help make this easier, everything we do will be done with a GUI. All of these steps can also be accomplished with the Terminal though.
Procedure to follow
Step 1: Boot into the live CD
Reboot your computer with your Ubuntu (or any live linux cd) in the cd drive and boot into the live system.
Step 2: Partitioning the hard drive
A. Start GParted from System->Administration->GParted
On most systems, /dev/sda is the main partition so we will work with that.
B. You should see all of the partitions on your hard drive. If you only have Ubuntu you will see 2: one is / and the other is swap. Right click on the / partition and select “Resize/Move” Shrink it to however big you wish you /home partition to be.
C. Now right click the free space (it will say unallocated and have a grey square) and select “New” Make it whatever file system you wish, label it something if you want to keep better track of it, and click “Add”.
We recomend you double check what you have done up to this point, there is no going back after step D
D. To commit all these changes, click the check mark at the top of the program (it says “Apply all operations” if you hold your mouse over it) This will repartition your hard drive.
Step 3: Reboot and add fstab entry
A. Reboot your computer without the live cd in the drive. Log in as usual. If you have anything important in your /home folder, i recommend copying it to an external of the root drive so you will be able to add it back once you are done setting up the /home partition.
B. Install Storage Device Manager by going here http://packages.ubuntu.com/pysdm
and clicking the version that is for your version of Ubuntu. This will allow you to edit you fstab file and allow the new partition to be mounted as /home.
C. Start Storage Device Manager by going to System->Administration->Storage Device Manager
D. Click the dropdown arrow next to /dev/sda (or whichever hard disk your partitions are located on) and select the newly created partition. If it asks if you would like to configure it click yes.
E. Next to Mountpoint, click the folder icon and goto File System (your root drive), click the home folder and then click open. This will assign the new partition a mount point at /home.
F. Next to options, click the set defaults button. This will mount the partition at boot.
Step 4: Reboot your system
A. Reboot your computer and log into your account. You will have to set ownership of the /home folder with sudo chown YOURUSERNAME /home/YOURUSERNAME before you can copy your files and folders onto it.
B. Done!

from http://www.ubuntugeek.com/how-to-create-a-separate-home-partition-in-ubuntu.html