Without installing additional hard drive (which would be impractical for laptop user anyway) the only source for extra space was Vista partition. Vista comes preinstalled with most modern laptops, but there’s no need for it to exist taking up to 40Gb of hard drive space, when Ubuntu is the primary OS.
WARNING: Before executing any of the belowmentioned steps, it is highly recommended to make a full backup of your data.
1. Check how much space you will need
It is good to check how much space you will need for your /home partition. Use “Scan Home” in Disk Usage Analyzer (Applications->Accessories->Disk Usage Analyzer) to check how much space do you use now. This tool will give you excellent perspective on how you use your disk space – and where you can possibly save a few gigabytes. Add some gigabytes on top of the current usage figure for future use and now you now what should be the size of your new /home.
2. Create new partition/filesystem
In Ubuntu there's an excellent tool for manipulating partitions - GParted (System->Administration->Partition Editor).
If the estimated size of your home partition is smaller than the size of Vista partition (or any other partition you’re prepared to re-allocate), then the task is really simple – you just convert Vista’s ntfs partition into ext3. In my case all my data in /home folder didn’t fit into 40Gb, so I had to resize the root / partition. This is not possible while the system is running, so I had to burn Ubuntu Live CD, boot from the CD with “try Ubuntu without affecting you current system” option, and run GParted from there.
Note, that resizing and moving partitions is a time-consuming process – it may take hours, depending on the size of your partitions, so reserve enough time for this operation.
3. Mount the new filesystem
$sudo mkdir /mnt/newhome
$sudo mount -t ext3 /dev/??? /mnt/newhome
4. Copy all files to new home
$cd /home
$sudo cp -ax * /mnt/newhome
That is a copy with “preserve links, preserve mode, ownership, timestamps, copy directories recursively, stay on this file system” parameters.
5. Change homes
Unmount new home partition from temporary mount point
$sudo umount /mnt/newhome
Move old home to a temporary folder oldhome (note that this works only when you are moving /home to own partition from root partition, if you had /home on its own partition already and just moving it to the new place, you’ll need to unmount old /home partition instead of moving it to a temporary folder oldhome)
$sudo mv /home /oldhome
Create a mount point for new home partition
$sudo mkdir /home
Mount new home partition to /home
$sudo mount /dev/??? /home
6. Compare the results
You don’t really have to do that, but if you want to be extra sure that everything is ok and are prepared to wait a bit longer, then type:
$sudo diff -rq /home /oldhome
7. Make changes permanent
Add a line to the “/etc/fstab” file that looks like the following:
/dev/??? /home ext3 nodev,nosuid 0 2
8. Remove old home
Now that everything is ok, you can remove the old home folder (same note as in step 5 – if you had old home on its own partition already – then use GParted to reallocate old partition for new needs)
$sudo rm -r /oldhome
Voila! Now your /home is on its very own partition.
Leave a Reply