How to Create a separate /home partition in Ubuntu
Sponsored Link
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!
Full Credit goes here
You can also do this by choosing the “Manual” partitioning option in the Ubuntu installer on the LiveCD. The installer takes care of all the dirty work for you.
http://guvnr.com/pc/karmic-install-tutorial/
Thanks for the great tutorial. But how do i set the ownership?
use “cp -a” or “rsync -a” when copying your home folder off to another media. Then copy the data back to the new /home mounted partition as root and all of your files will be placed in the correct location as the correct users. This way all user accounts on the system are taken care of and no manual permissioning need be done.
Eismaus: look into the “chown” command.
Tom K: Good point but this only works if you’re doing a new fresh install. Doing this task above before starting the new install and then not formatting the /home partition can result in some rewarding outcomes.
Ok, but how to move the data from the actual partition to another one without damage?
Thanks for writing this tutorial but I think there are more cons than pros:
If the operating system crashes, your /home has the same chances of being consistent whether it’s in the same partition or not. If the operating system gets broken/won’t boot you can always boot from live cd and backup your data. On the other hand having separate /home partition requires manual configuration, and makes your /home fixed size (although it’s changeable, it’s less trivial). For the possibility that one day you’d like to reinstall the operating system without manual backup, I don’t think it worth the trouble. If one tend to install operating systems a lot he should probably use virtual machine.
IF you login in as root, and don’t have anything USING (lsof / fuser) /home, you can using the live cd to repartition, but then you can migrate /home live without having to map the hard drive partitions manually from live cd (reboot off HD)
mount the extra partition as /home2 and run
cd /home
find . -print | cpio -pdmv /home2
cd /
mv home home.old
umount home2
mkdir home
mount partition to /home
edit fstab to add /home mount
B. Install Storage Device Manager by going here http://packages.ubuntu.com/pysdm
In the above step i wonder why you suggest the users to install the package by going to packages.ubuntu.com/pysdm. The easier and officially suggested way is use Synaptic/apt-get/aptitude. Also in case you want the users to go via website, in that case, you need to add a few more steps like >download the package; >Right-click on downloaded package; >Click Install; etc.
Also a straight-forward way of doing Step 3 (a subjective matter) would have been to:
>Open the /etc/fstab file as root
>Add the following line in the end:
/dev/sdxy /home ext4 defaults 0 0
(where ‘sdxy’ is the partition you just created)
>Save and close file
“On most systems, /dev/sda is the main partition”
No it isn’t.
/dev/sda is an entire drive.
/dev/sda1 is a partition on the drive.
Alguém em português??
Existiria algum programa com interface gráfica que permita fazer a troca da /home para outro HD transferindo os dados para novo destino, fazendo os ajustes necessários no fstab sem a necessidade de comando de linha?
Ok, but how to move the data from the actual partition to another one without damage?
Making a separate home partition seems like a great idea, but everyone’s instructions for how to create one always assume that I am currently using less than 50% of my HDD’s physical capacity. What if it’s physically impossible for me to copy all of /home into a second partition, because I simply don’t have that much disk space? (Let’s also assume that I don’t want to buy and physically install a second hard disk.) Is there a way to take my existing /dev/sda1 partition, which contains my old /home as well as all the old OS stuff, and tell the new OS to mount it as /home?
Right now I have /dev/sda1 containing my old Ubuntu 8.04 install with valuable stuff in the /home directory, and then /dev/sda6 containing a new Ubuntu 10.04 install with junk in the /home directory. Can I just mark sda6 with the “boot” flag in gparted, and then somehow automatically mount sda1 as /home? If so, how?
For bonus points, can I somehow clean all the old OS junk out of my /dev/sda1, thus letting me use that whole partition for /home stuff, or is that going to be too risky?