While reading this post, you may feel that this question has been asked many times before, but given the different types of situations in all those threads, I'm not quite sure which set of instructions to follow, so I hope you can help me out here.

While installing Ubuntu (trusty), I put / (~ 10GB) and /home (~230 GB) on separate partitions. But only today did I realise, after / started running out of space quickly, that my current home directory (/home/navneeth) is within the / partition and that the separate home (/media/navneeth/a7775a8b-8cbd-445b-a05d-284226b3c3aa/navneeth) is virtually empty. So, how should I proceed to move my files from the first to the second without all the app configurations going awry?

https://askubuntu.com/a/473923/422985 seems like the easiest solution. Would it work? Is there a method that's 'cleaner'? By which I would like to know if there's a way to make the correct home directory the 'go-to' home henceforth.

System info:

navneeth@home:/boot$ df -h
Filesystem      Size  Used Avail Use% Mounted on
/dev/sda7       9.3G  8.8G   62M 100% /
none            4.0K     0  4.0K   0% /sys/fs/cgroup
udev            994M  4.0K  994M   1% /dev
tmpfs           201M 1008K  200M   1% /run
none            5.0M     0  5.0M   0% /run/lock
none           1003M  512K 1003M   1% /run/shm
none            100M   56K  100M   1% /run/user

navneeth@home:~$ sudo fdisk -l

Disk /dev/sda: 300.1 GB, 300067970560 bytes
255 heads, 63 sectors/track, 36481 cylinders, total 586070255 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xd6edd6ed

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63   114688034    57343986    7  HPFS/NTFS/exFAT
/dev/sda3       114690046   586070015   235689985    5  Extended
/dev/sda5       582070272   586070015     1999872   82  Linux swap / Solaris
/dev/sda6       134690816   582070271   223689728   83  Linux
/dev/sda7       114690048   134688767     9999360   83  Linux

Partition table entries are not in disk order

navneeth@home:/boot$  sudo du -hs /*
[sudo] password for navneeth: 
9.3M    /bin
63M /boot
4.0K    /cdrom
4.0K    /dev
13M /etc
3.9G    /home
0   /initrd.img
0   /initrd.img.old
389M    /lib
16K /lost+found
8.0K    /media
4.0K    /mnt
356M    /opt
du: cannot access ‘/proc/1948/task/1998/fdinfo/43’: No such file or directory
du: cannot access ‘/proc/1948/task/1998/fdinfo/80’: No such file or directory
du: cannot access ‘/proc/1948/task/2074/fd/81’: No such file or directory
du: cannot access ‘/proc/7123/task/7123/fd/3’: No such file or directory
du: cannot access ‘/proc/7123/task/7123/fdinfo/3’: No such file or directory
du: cannot access ‘/proc/7123/fd/3’: No such file or directory
du: cannot access ‘/proc/7123/fdinfo/3’: No such file or directory
0   /proc
208K    /root
du: cannot access ‘/run/user/1000/gvfs’: Permission denied
1.6M    /run
12M /sbin
4.0K    /srv
0   /sys
40K /tmp
3.5G    /usr
518M    /var
0   /vmlinuz
0   /vmlinuz.old

I'm going to assume that /dev/sda6 is your currently unused 230G /home partition you want to use, based on the number of blocks. This should work:

$ cd /
$ sudo mkdir /media/home_backup
$ sudo mount /dev/sda6 /media/home_backup

# below, -rp flags indicate recursive, and keep owner/permissions

$ sudo cp -rp /home/* /media/home_backup

$ sudo umount /media/home_backup
$ sudo mv /home /home.bak
$ sudo mkdir /home
$ sudo mount /dev/sda6 /home

# the large partition should be mounted at /home now. The following
# will make sure it's mounted at boot

$ sudo umount /home

# edit /etc/fstab as sudo, and add the following to the bottom
# of the file (tab separate each entry)

/dev/sda6 /home ext4 default 0 2

# save the file and then:

$ sudo mount -a

If the last command works and you can list the /home partition, it will mount successfully at boot.

  • Have you read the other answer? It's not as "pure" as your solution, but much easier to implement... ;-) – Fabby Jun 23 '15 at 23:34
  • Yes, I know that. However, I have always found it more consistent to mount the mountpoints to their proper location. Symlinks can cause issues in the long run when doing backups and other tasks. More work up front, but you're not relying on redirection etc. You're not limited to going the whole way here, so why bother taking shortcuts? – stevieb Jun 24 '15 at 0:22
  • 1
    Yes, your answer is the cleanest solution, but to a rep 1 user, I'd still recommend the other one... :P ;-) (Upvoted because this is exactly what I did a few years back...) – Fabby Jun 24 '15 at 0:31
  • I appreciate you concern, Fabby, but I in my original post I did ask for a cleaner solution. ;-) – navneethc Jun 24 '15 at 7:04
  • stevieb, thanks a lot for your detailed post. However, before I proceed with the steps, I'd like to have a few things clarified. The 230G home is already mounted at /media/navneeth/a7775a8b-8cbd-445b-a05d-284226b3c3aa/navneeth, so are the second and third steps necessary? (Also, 230G is /dev/sda6; sda7 is the root partition. :-)) I notice that there's an 'If' in the last sentence :-) : what are the ways in which this can go wrong? And in case of a failure, do I simply unmount the new home, re-edit fstab, restore the back-up and re-mount it? – navneethc Jun 24 '15 at 7:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.