HostOnNet Blog

Moving Home Directory In Ubuntu

Looking for Linux Server Admin or WordPress Expert? We can help.

When i installed Ubuntu on my PC, i choose to install everything in a single partition. It was a dual boot system, so i wanted space for Windows too.

Recently my disk usage on Ubuntu partition reached almost 90%. Since i was not using Windows any more, i deleted my Windows partitions to make free space.

Booted into Ubuntu LIVE CD (or we call it USB now ?), tried to resize the partition. It get following warning


I did some re size of normal partitions before, but don’t want to resize the boot partition because of the warning, i don’t want to reinstall Ubuntu at this stage if anything went wrong as Ubuntu 16.04 will be released in less 2 months and i can’t wait to install it.

So i decided to take easy way, make a new partition on the free space, move /home directory to that folder.

root@hon-pc-01:~# parted  /dev/sda print
Model: ATA ST31000528AS (scsi)
Disk /dev/sda: 1000GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type      File system     Flags
 1      1049kB  125GB   125GB   primary   ext4
 2      125GB   528GB   403GB   primary   ext4
 4      528GB   799GB   271GB   extended
 5      528GB   793GB   265GB   logical   ext4
 6      793GB   799GB   6433MB  logical   linux-swap(v1)
 3      799GB   1000GB  201GB   primary


In the above, partition 2, that is /dev/sda2 will be used as my new /home partition.

So i mounted it as /mnt/newhome

sudo mkdir /mnt/newhome
sudo mount /dev/sda2 /mnt/newhome

Now copy files from my /home folder to /mnt/newhome

sudo rsync -aXSv --exclude='/*/.gvfs' /home/. /mnt/newhome/.

This take a while and slow down my PC as it need to copy lot of files.

After rsync finished, i run it few more times to make sure all files are copied. Now we need to find out UUID of /dev/sda2 so we can add it to /etc/fstab for mounting.

root@hon-pc-01:~# blkid
/dev/sda1: UUID="6da979ef-61e8-42f8-9e7c-06f9d4d77774" TYPE="ext4" 
/dev/sda2: UUID="3c498e9b-2b60-43dc-aec0-78efd5185506" TYPE="ext4" 
/dev/sda5: UUID="722d15fe-5382-400b-9e7e-8338982f5561" TYPE="ext4" 
/dev/sda6: UUID="239c7429-0670-4db1-808c-b14ce0e45830" TYPE="swap" 
/dev/sdc2: LABEL="part_os" UUID="f7e2b77d-8286-4d76-8170-0ce7c2d75a89" TYPE="ext4" 
/dev/sdc3: LABEL="part_data" UUID="8b269653-7fae-4260-ae29-9750ce5f9384" TYPE="ext4" 

From the above, we found UUID for /dev/sda2 is 3c498e9b-2b60-43dc-aec0-78efd5185506

/dev/sda2: UUID=”3c498e9b-2b60-43dc-aec0-78efd5185506″ TYPE=”ext4″

Now it is time we move /home to /oldhome and mount /dev/sda2 as /home

I rebooted PC, on login screen, instead of login, i press CTRL+ALT+F1, logged in to console as root.

cd /
mv home old-home
mkdir home

Now we have empty directory as /home, we need to mount /dev/sda2 on it. For this edit /etc/fstab file and add

UUID=3c498e9b-2b60-43dc-aec0-78efd5185506   /home    ext4          defaults       0       2

Now reboot your PC again with command


On login, you will be using /dev/sda2 as /home directory.

root@hon-pc-01:~# df -h | grep home
/dev/sda2       370G  179G  172G  52% /home

Posted in Ubuntu

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.