Ubuntu: How to move “home” to a separate partition in recovery mode? [duplicate]


I accidentally screwed my system so I only am able to boot in the repair mode. Anyway, I want to reinstall it (upgrade to 15.10, if that matters). So I want to save my "home" directory. I have access to "home" via the recovery mode, I've checked that.

How can I move my existing "home" directory to a separate partition to save data? And how can I create a new partition? I figure I'll have to resize the existing one but how exactly?


The safe way

Back up your HOME to an external drive by copying its content while in recovery mode. After booting to a root shell or (recommended) after booting your computer with a live system from CD or USB using the 15.10 installation medium we have to mount the external drive. From the live system "Try out Ubuntu" we can simply mount it using Nautilus. From the command line in a root shell we can mount it from the command line as was further elaborated here:

How to access a usb flash drive from the terminal? (How can I mount a flash drive manually?)

After the external drive was mounted just copy your HOME with

# cp -av /home /mnt/usb  

We can then simply restore the backup to a newly created Ubuntu.

This is the recommended way, as in all cases below there is an inherent risk to lose your data if something went wrong on partitioning your drive.

Partition while installing

After we had made a backup of our data we can create new partitions on installing Ubuntu when running GParted on choosing "Try out Ubuntu" prior to the installation. This will give you an option to shrink the existing partition where your HOME resides to give space for an additional partition. On installing by choosing "Someting else" take care to not format the existing partition where your HOME resides for later use.

Move home

Shrinking partitions can only be done when the drive was not mounted. This can not be done from a root shell you had booted from the same drive. You will also need to boot to a live system (see above).

After we had created a new partition we can move the HOME from the command line, which could also be a root shell, as was elaborated here:

Move home folder to second drive

But this may be a rather inconvenient way as compared to just skipping the partitioning of the partition that holds the old HOME.

Re-install without deleting HOME

Of course we can also re-install Ubuntu on the exiting partition without removing data from our previous HOME by choosing "Upgrade Ubuntu xxx to Ubuntu xxx".

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »