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?)


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 to ext4. 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:

sudo cp -rp /home /media/$USER/USB2TB/home

Instead of the cp command you may want to use rsync like:

sudo rsync -aXS --exclude='/*/.gvfs' /home/. /media/home/.

See https://stackoverflow.com/questions/6339287/copy-or-rsync-command for various answers about difference between cp and rsync.

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:

tar czvf /media/$USER/USB2TB/myhomebackup.tar.gz /home/$USER

where $USER is your user ID for this computer. The tar options czvf does the following:

  • c creates a new archive
  • z filters the archive through gzip to make it compressed
  • v verbosely list files processed
  • f <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 use foo 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

  • Thanks. Maybe I can tar the whole thing before I save it on Windows file system and thereby keep the permissions? – cvr Oct 18 '17 at 18:39
  • I will add that in my answer. – user68186 Oct 18 '17 at 18:45
  • Solution 3 is pretty much the safest and easiest way to do this. – Michael Oct 19 '17 at 0:55
  • Problem solved. I followed the excellent link you gave. I will shrink the system partition further after I delete the old home folder. Saving on external media I realized that rsync and mv can be done on ~, but cp not so easily. / Only question about the guide is "If you are doing this from a LiveCd ... you may find differences". I just had expected the reverse, but I am no expert. / Keeping all personal data on a separate partition also sounds interesting. Can I find info about the pros and cons of that, somewhere? Thanks. – cvr Oct 19 '17 at 4:18
  • 1
    The guide worked real fine and also expanding the home partition after deleting the backup home folder in the system partition. My comment is only that I will probably never make a fresh install without a home partition again. Adding one, even though it worked well, is pretty time consuming. Thanks to you guys that help out. – cvr Oct 19 '17 at 8:15

I do exactly the same thing on my system, and generally have no problems.

  • I don't restore all of the files on ~/.config, but only select files that contain some data that I want
  • I do copy back the files in ~/.mozilla and ~/.thunderbird
  • I do copy files in ~/.config/variety and ~/.config/qBittorrent

Most of the files in ~/.config are rebuilt when the program using them starts for the first time, and any changes that I have made are inconsequential.

  • @ycc_swe If you use Thi=underbird for mail, don't forget the ~/.thunderbird folder! – Charles Green Oct 18 '17 at 17:57
  • Thanks. I also use Chrome. (it worked better for me than Chromium, saving passwords etc) I don't find a folder for that one. Maybe just logging in to my Google account will introduce necessary personal information. – cvr Oct 18 '17 at 18:06

Yes, you can copy the content of the old home folder to the new partition.

Let us say that you have booted from a live drive and mount the root partition and the boot partition,

sudo mkdir /mnt/root
sudo mkdir /mnt/home

sudo mount /dev/sdxm /mnt/root  # the root partition
sudo mount /dev/sdyn /mnt/home  # the home partition

where x, y are drive letters and m, n are partition numbers.

Then you can copy with rsync in a way that preserves the permissions and ownership,

sudo rsync -Havn /mnt/root/home/ /mnt/home

Please notice the trailing slash / in the source specification. This is a 'dry run', and if the output looks good, you can do the real copying,

sudo rsync -Hav /mnt/root/home/ /mnt/home

Please remember to add a line for the /home partition in /etc/fstab file, which is at /mnt/root/etc/fstab when you are still booted from the live drive.

sudo nano /mnt/root/etc/fstab

The line should be similar to this line,

UUID=2175f8ed-4ab3-4268-b5d6-f38c2017e547 /home  ext4  errors=remount-ro  0  2

where you should replace the UUID hex string with that of your /home partition as seen by blkid (without quotes).

As described in the answer by Charles Green, you may or may not skip some data in ~/.config.

I used another method when upgrading to 16.04 LTS: I have personal data in a separate data partition, which is also mounted via the /etc/fstab file. This makes my /home directory rather small, so that is can be kept in the root partition. I have symbolic links from the my /home directory to the data partition, where mailboxes, VirtualBox files and other big files can reside.

  • Thanks. So what rsync did was a move command? I will not have to delete the old home folder? // I guess this is a good option since, if I save on external media instead of doing this, depending on the file system of the external media, permissions may get changed and that can be a big problem? – cvr Oct 18 '17 at 18:32
  • No, the rsync command line in my answer is a copying command. If you repeat it you will notice that it is an incremental copying command, that is quite useful also for simple backup purposes. So you must remove the old home directory manually afterwards. -- You are right, if you prefer to or have to store your home directory data on a separate drive, you should have the same file system in a partition of that drive, to avoid losing the permissions and ownership, or you could do it with sudo tar .... – sudodus Oct 18 '17 at 18:40
  • 2
    In every case, you should backup all data, that you cannot afford to lose - back them up to a separate drive before you start with these operations. – sudodus Oct 18 '17 at 18:42
  • Thanks, I already try to keep keep good backups (I hope). To later delete the old home folder, how do I find it so I can delete it? Is it accessible from the new system? Or must I mount the old system+home from a Live USB again and delete it from there? – cvr Oct 18 '17 at 18:44
  • You will see it after the rsync command when still booted from the live drive, it is /mnt/root/home/. I am not sure what happens if you leave it so that there will be two competing 'homes', when you boot into the new system. There might be confusion. – sudodus Oct 18 '17 at 18:48

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.