1

I am on an Ubuntu 16.04 LTS machine and in preparation for an upgrade to 18.04 LTS I want to move all /home directories (in fact there is only /home/juergen) to a separate, now free partition that I happen to have.

I found two good tutorials on how to do this correctly, namely

https://help.ubuntu.com/community/Partitioning/Home/Moving

and (in German)

https://wiki.ubuntuusers.de/Home_umziehen/

I understand them fully, but have a question about the optimal set of options to use for moving the home directory data.

The first source recommends

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

the second one

rsync -avxH --progress /home/ /mnt/tmp

I understand that the --exclude from the first source is reasonable and --progress from the second one too and that they can be combined. But what about the other options? S (preserving sparsity) seems to be useful as I generated artificially for some test purposes some very big 'files with holes' in my home-directory. H (hard links) looks worthwhile too - or could it be a problem to preserve hard-links? X seems also good: as I want to preserve everything and this promises to preserve 'extended attributes' (whatever this means). So should I simply combine them all?

But even then there might be some options lurking, that would be useful? I must admit I can not come to a clear conclusion with all these rsync options (in my own backups I use rsync -avzu).

Many thanks in advance for your answers!

1

I would do rsync -aPHAXS source dest if it were me. But you also talk about moving them and rsync copies so maybe just mv is enough?

2
  • Actually I do not know this, but I think 'mv' would destroy a lot of properties associated with a file, especially times - or is this untrue? Aug 18 '20 at 22:30
  • Personally I wouldn't use the -P/--partial option. Using mv is really not recommended. This command is not safe from too many points of view. Aug 18 '20 at 23:23
1

So should I simply combine them all?

Yes. You could also add A, U and H for good measure, so the net result will be sudo rsync -aXSAUH --progress --preallocate source/ destination.

The --preallocate option is very nice IMO because it avoids file fragmentation.

Comparing the checksums of the original and destination files is also hugely recommended. At least I always do that to avoid probable interface errors. There are multiple ways to do that, including diff, cmp, find/xargs/md5sum, etc.


Personally I'd use e2image because rsync cannot copy file creation times. Also, copying an image is almost always a lot faster than copying individual files.

Here's an example:

e2image -rap /dev/source_partition /dev/destination_partition

The meaning of these options can be found in man e2image. You will need to remount the source_partition ro before running this command. There are other options as well: https://wiki.archlinux.org/index.php/Disk_cloning


Lastly you could delete everything except /home in your / folder and simply install new Ubuntu into a new partition - that's my personal favorite because your data will be untouched and / doesn't actually take a lot of space.

6
  • If I understand your example correctly, it would be necessary, that /home is already in a separate partition before the copy. Unfortunately as things now are, /home is just a directory in a big / partition (as I used Ubuntu defaults on installing). Aug 18 '20 at 21:58
  • I found no option -U (did you mean -u)? Aug 18 '20 at 22:09
  • Maybe my rsync is newer than yours, cause man rsync here says --atimes, -U preserve access (use) times. Aug 18 '20 at 22:19
  • Maybe, I have, rsync version 3.1.1 protocol version 31 (from rsync --help). I will think about yout proposal, to use the new partition as the root for a new installation. The main problem with this for me is, that I have lots of packages added to the default installation and need a way to migrate them to a new Ubuntu version, so that I considered the 'upgrade' way as the only possible. Aug 18 '20 at 22:27
  • @JürgenBöhm This might be what you're looking for: askubuntu.com/a/37704 Installing fresh is almost always safer than updating even for Linux. Aug 18 '20 at 22:54

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.