Create a new /home partition after you’ve installed.

There are several reasons as to why you might want to do this.

  • You’re running out of space on the existing /home partition and are unable to re-size it
  • You didn’t create one when you installed and your running out of space
  • You didn’t create one when you installed and now you want to reinstall but keep everything in /home

Since you dont want to delete everything /home while your logged in , you can either boot a live-cd , or login as the root user – note some distrobutions wont let you do this so you might have to use a live-cd.
Assuming you haven’t already done so , create a new partition using gparted.
When that is done , open up a terminal/console and type sudo blkid , this is what I get here ,
/dev/sda1: LABEL=”COMPAQ” UUID=”90CED570CED54EDA” TYPE=”ntfs”
/dev/sda5: UUID=”5dc14104-63d7-45ff-a430-ffa422c7a551″ TYPE=”swap”
/dev/sda6: UUID=”ffab264a-31eb-4ae4-8512-6daaf016ca06″ TYPE=”ext4″
/dev/sda2: UUID=”2495046a-5cc8-4ecf-8e05-b8fec0ef50a0″ TYPE=”ext4″
/dev/sda7: UUID=”54c6bca4-3522-4b2d-9604-404591582fe6″ TYPE=”ext4″
/dev/sdf1: UUID=”37ba0161-f91b-4a94-bcdb-c3deaee1ae1d” TYPE=”ext4″

So what I am going to do is use sda7 as the new home , but before we can mount this as the /home partition we have to copy everything from the existing /home first.
To do that first make a temporary mountpoint so in terminal sudo mkdir /mnt/home
Now mount the new partition in the temporary mountpoint with sudo mount /dev/sda7 /mnt/home (be carefull I am using /dev/sda7 , but this might be different for you)
Copy all the data from /home to /mnt/home , this can be done in your favourite file manager or in terminal using sudo rsync -arvp /home/* /mnt/home
When thats done and you’re confident that all your data has been copied successfully , it is now safe to remove the /home folder. This can be done with your favourite file manager or in terminal with sudo rm -r /home/* , but be sure your in the / directory or any directory not in /home. For those not wanting to risk the loss of data , you can simply rename the /home directory, and create a new /home folder.

We can now mount the new partition as /home , but first we need to create an entry in /etc/fstab so that the partition will mount as /home so from the sudo blkid output before find the entry for the partition, for me it was
/dev/sda7: UUID=”54c6bca4-3522-4b2d-9604-404591582fe6″ TYPE=”ext4″
then open /etc/fstab and add a line similar to
UUID= 54c6bca4-3522-4b2d-9604-404591582fe6 ext4 /home defaults 0 0
When editing /etc/fstab make sure there is an empty line at the end.
Save and exit , but before we can mount the partition umount it from /mnt/home with sudo umount /mnt/home. If that is done then sudo mount -a

We can now see that the partition is now mounted as /home with the mount command , this is what mine looks like
/dev/sda7 on /home type ext4 (rw,relatime,user_xattr,barrier=1,data=ordered)
Since we copied the files as root , they are still owned as root , so we need to change the ownership back to the users , which can be done in your favourite file manager or in terminal with sudo chown -R <user> /home/<user>

Advertisements
Tagged with:
Posted in 01Ben, Linux

Please feel free to leave a reply.

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Archives
Categories

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 69 other followers

%d bloggers like this: