Showing posts with label partitioning. Show all posts
Showing posts with label partitioning. Show all posts

Saturday, February 28, 2015

Linux Mint: Move your home-directory into a separate partition after installation

Objective


I installed Linux Mint 17.1 Rebecca on new computer with a SSD with the Mint Installer default partitioning scheme, which mounts /boot, /root and /home into the same partition.

Motivation


I decided to have my home-directory in a separate partition which I can mount into /home to make leter upgrading the system a little more painless.

Prerequisites


  • Linux Mint 17.1 Rebecca
  • 512 GB SSD

Solution


Create a new partition


Resize your system partition and create a new partition in the free space. Follow this guide to see how you can resize Ubuntu partitions to complete this step.

Copy the home files into the new partition


Open a terminal and run the following command to create a copy of your current /home directory on the new partition, where /media/HOME is the location of your newly mounted partition (I gave it the LABEL=HOME during the creation process) where the new /home should reside:

$> sudo cp -Rp /home/* /media/HOME

You should check if everything went fine to avoid to loose data:

$> ls /media/HOME

In my case I got:

csch data lost+found

Determine the UUID of the newly created partition


Use the following command to get the UUID of your new home-partition:

$> sudo blkid

In my case I got (you can see the label HOME again here)

...
/dev/sda2: UUID="f270b74b-ce14-4481-bf32-1226b4fd776e" TYPE="ext4"
/dev/sda3: LABEL="HOME" UUID="a9c81163-f588-462a-89b0-dbdad87cef9c" TYPE="ext4"
/dev/sda6: UUID="023cf9e6-199f-475c-9fe1-c70b73d3047c" TYPE="swap"
...

Adapt your mount table in fstab to mount the new partition into "/home"


Make a backup of your current fstab (with a timestamp):

$> sudo cp /etc/fstab /etc/fstab.$(date +%Y-%m-%d)_backup

and edit the original fstab:

$>gksu gedit /etc/fstab

Add this line to your fstab and save the file (replace xxxxx with your UUID):

...
# (identifier) (location) (format, eg ext3 or ext4) (some settings)
UUID=xxxxx /home ext4 nodev,nosuid 0 2

Move home-directory into a backup and create a new mount-directory


$> cd / && sudo mv /home /old_home && sudo mkdir /home

Now you're done, finally reboot and prey!

$> sudo shutdown -r now

After your system is up again, you can savely clean-up the system:

$> sudo rm -rf /home_old

Remark

Additional info on how to deal with separate home-partitions can be found here.