Hidden Linux: Moving /home

It's one of the common Linux mistakes: forgetting to place the
/home
directory in a separate partition. It's not a critical failture, but it
does give you a bit more safety and security. If the latest upgrade
turns to custard or you accidentally trash something vital, you can
simply reinstall the operating system knowing that all your user data,
settings, etc. will remain untouched.
There's also a school of thought that says it means you can use the same user account when installing multiple distributions, but I'm a little hesitant here. Certainly you can use the same
/home
partition, but I'd suggest setting up different user accounts as there
are sometimes subtle differences in program settings that don't
translate well between different distros.
Making room
The first step is finding somewhere to put it, and that usually means adding a partition to the current drive. (That doesn't have to be the case of course. You could add it to a second drive, but you're still likely to want to partition the disk, so carry on.)
Obviously you can't repartition a drive you're currently working in so you'll need an appropriate bootable tool. For this I reccommend the System Rescue CD from www.sysresccd.org. I'll admit it's a little bit of overkill as it has tons more tools than just partitioning, but SysRescue is

Once you're into the GUI, start GParted from the menu and you'll get a screen like this.
OK, how much space do you give your new
/home? That
depends on you and the size of your hard disk, but as an indication,
70% of the 15GB I allocated to the / (root) partition on
my main machine has been used (and I have lot installed!), so all the
rest is /home. If it turns out you want more or less for
any particular partition, changing things is just a SysRescue boot
away.

/home.
Movin' it
Now we need to move the
/home folder to it's new
location. For this we'll use the command line so switch to SysRescue's
Terminal.
Before we can do anything, we need to create mount points for the two partitions:
mkdir /mnt/part1 /mnt/part2 |
and mount them
mount /dev/sda1 /mnt/part1
|
Note that the
/dev (short for "device") settings comes
from GParted. Yours may be different!
If you now travel to the first mounted partition ...
cd /mnt/part1 |
ls |
bin cdrom
etc homee
lib media
opt root selinux sys |
It's now simply a matter of copying the contents of the
/homecp -av home /mnt/part2
|
Note that we're only copying the contents. The next step will mount and use that copy but if anything goes wrong, simply back out the next step and you'll be back where you were with a bootable disk.
Telling it where to go
There's one final step. We need to tell the root partition where the new
/home partition now resides. We do this by editing
root's file system table /etc/fstab. SysRescue has a
built-in GUI editor called Geany so let's use that:
geany /mnt/part1/etc/fstab
|
Add a line like the following:
/dev/sda2 /home ext4
defaults 0 2 |
What does that all mean?
/dev/sda2 is the device name
/home is the mount point
ext4 is the partition typedefaults are mount options
0 is
the dump frequency (disabled)2 indicates the partition should be checked for errors at
boot time after /
(root) has been checked.Save the file and we're done. Shut down SysRescue, reboot.
As a final check, run
df -h |
to see where your filesystems are mounted
Filesystem
Size Used Avail Use% Mounted on |
Now enjoy your new
/home!
![]() |
![]() |



PC World is New Zealand’s top selling computing and technology magazine.
Comments
Absolutely, Ross!
Posted by: Geoff | September 6, 2010 6:19 PM
I am running out of room for personal files on my home partition. I have a user partition which I don't have permission to write to. Can I shrink this using the SysRescue CD, then expand home?
Posted by: Ross | September 6, 2010 12:42 PM