I run 16.04 on a combined system and home partiton. I plan a complete reinstall with a separate home partition. Is it a good idea to save my entire /home/myUser folder on external media and copy it back to the new home partition (overwriting files if they exist)?
Or should I just save user data like pictures, files I edited etc on external media. Also some selected "system" files? The only one I come to think of now is .vimrc. (And not overwrite any files.)
What problems/double work may occur in this process?
(Long ago I heard of procedures to create a separate home partition without using external media, but that is maybe an unnecessary risk?)
Best Answer
Yes! You can copy the old home folder to the new partition (via an external hard drive)
But... what about file permissions?
The issue is if your external hard drive is formatted for Windows incompatibilities, then it will not respect the file ownership and permissions when you copy them to the external drive.
For most files this will not matter. However, for some files like ssh private key, permissions are important and without the right kind of permissions the key will not work.
Solution 1
Format the external drive to
ext4
the default format used by Ubuntu. The disadvantage is, all the data in the external drive will be lost when you reformat it toext4
. On the plus side, you will have an external drive specifically for transferring data between two Ubuntu (any Linux) computers.Drag and drop or copy paste by Ctrl+C and Ctrl+V in Nautilus would only work if you are the only user of the computer, and there is only one user account (yours).
If the computer has other user accounts you want to copy using the terminal. Say your external hard drive is mounted as
/media/$USER/USB2TB
. Open a terminal by pressing Ctrl+Alt+T and enter:Instead of the
cp
command you may want to usersync
like:See https://stackoverflow.com/questions/6339287/copy-or-rsync-command for various answers about difference between
cp
andrsync
.In all cases, remember to eject or Safely Remove the hard drive and WAIT till it is safe to unplug.
Solution 2
Use the default Backup software that comes with Ubuntu to backup your home folder. Make sure the backup target is the external drive. This ensures the ownership and permission data is preserved even if the drive is formatted FAT32 or NTFS.
Solution 3
Put everything in a compressed tarball. Open a terminal by pressing Ctrl+Alt+T and enter:
where
$USER
is your user ID for this computer. The tar optionsczvf
does the following:<name of archive>
use archive file name<name of archive>
To overwrite or not?
Since this is the same machine, with no new hardware, I would overwrite the existing files. First, with a brand new install, there is no "real" data in your home folder. Second, overwriting the hidden files brings back the configurations, bookmarks etc. from your old install.
I find it easier to go through the hidden folders and files (the file and folder names that start with a .dot) later and delete the ones that are not needed. For example, if I don't need the program foo any more and did not install
foo
in the new installation, I would delete the folder.foo
in my home folder. Even if I don't delete.foo
it does not take up a lot of space. If I decide I need to usefoo
again some day, the config will be there.Can it be done without a new install?
Yes! You can move the home folder to a new partition. There is an excellent guide about it at: https://help.ubuntu.com/community/Partitioning/Home/Moving
I strongly advise that you make a backup (or two backups!) of your pictures, songs, or whatever you hold dear to your heart, before you try this.
Mistakes happens. If you make one, your data could be gone forever. So, be safe and keep at least two backups of important files before you try any of this.
Hope this helps