Move home to its own partition
From The Linux Mint Wiki
This article is used so much used in support that it is locked from editing to avoid that it is destroyed.
Unfortunately we even had the entire howto section of the wiki destroyed once and parts of it several times.
If you want to contribute please do so in the discussion tab and if it is good I will include it in the main article /husse
If you,like me, have a long story with Windows the chance is that you only created two partitions when you installed Linux Mint - at least I did. Linux handles partitions much better than Windows so it's a good thing to have a few partitions.
The first change you may want to do is to move /home to its own partition.
There is a guide on that in an Ubuntu blog: http://ubuntu.wordpress.com/2006/01/29/move-home-to-its-own-partition/
However I find it a bit hard to read and not entirely correct (see the section about copy) so I've decided to make a guide here.
You can use this guide to move any folder to its own partition simply by replacing home with your folder (boot, var and usr are the most likely candidates)
You may have to use the live CD at some stage for this, if necessary files cannot be found when you move around. If you try this you should know how to do that so that's not included
Contents |
The simple basics
It's really very simple to achieve this goal.
1) Create a partition
2) Copy /home to that partition
3) Remove/rename your old /home folder
4) Mount the /home partition in a new /home folder
As always there is a but (or rather several).
Create a partition
GParted can resize a partition on your disk to make room for a new partition for home. Before you do this it's best to defragment the partition you want to shrink if it is a Windows partition (FAT, NTFS) and back up your data! It should not be a problem though, if you are careful. You have to decide for your self if you want take the (small) risk of data loss. I back up all valuable partitions daily so data loss is no problem for me. Format the new partition, the preferred file system is ext3
Copy /home to that partition
This has to be done in several steps. First create a folder to mount your new empty partition in.
sudo mkdir /mnt/newhome
It seems that mnt is a folder often used for this purpose.
Mount the new partition: sudo mount -t ext3 /dev/sda4 /mnt/newhome
Change sda4 to what ever your partition is labeled. Check that the partition is mounted - you could right click > Properties.
Copying is not just copying
You may think copy is copy, so what? However there are things like hidden files, symbolic and hard links and user rights to consider. This is a problem in Windows as well as Linux. One method, presented by the above mentioned blog is this elaborate command: "find . -depth -print0 | cpio –null –sparse -pvd". Unfortunately there is no sudo which lead me to the erroneous conclusion that you should not copy as root, but that's the only way to do it. This is much simpler and does the job:
sudo cp -a -v -u /home/* /mnt/newhome/
-a means the options dpR together. -d is "preserve=link" -p is "never follow symbolic links" -R is "copy directories recursively" -v is "verbose" -u is "copy only when the SOURCE file is newer than the destination file or when the destination file is missing"
This gives a correct copy of /home in the new partition
Check the copy - there should be the same number of files and bytes in /home and in your new partition.
Make the partition your new home
First, rename your current home:
sudo mv /home /old_home
Then make a new home folder:
sudo mkdir /home
Unmount the partition:
sudo umount /mnt/newhome
Mount the partition in your new home folder:
sudo mount /dev/sda4 /home
Of course you should change sda4 to what ever you have. Now you have a working home on its own partition.
Make the change last:
Edit fstab, sudo gedit /etc/fstab, and add:
/dev/sda4 /home ext3 nodev,nosuid 0 2
Again change sda4 to whatever you have.
If you used the guide to move /boot the line in fstab is
/dev/sda4 /boot ext3 defaults 0 2 and again change sda4 to whatever you have.
Finally - when everything is ok get rid of the old home
sudo rm -r /old_home
You are done!
Installing when you have home on a separate partition
My recommendation here has changed. Move all hidden files and folders (in /home of course) into an archive so you get a fresh install without the risk that old settings play tricks on you. Do not delete them - there are settings for different applications you may want to use when you reinstall - use with care
