The Cookie Machine - Click here to drag window

DUMMY TEXT - Real text set in assets/js/theCookieMachine.js

If you can read me, I'm broken!

Views: 2,173     Votes:  3 
Tags: partitioning   rsync   uuid   grub  
Link: 🔍 See Original Answer on Ask Ubuntu ⧉ 🔗

URL: https://askubuntu.com/q/1191198
Title: Does rsync requires changing UUID after copying a partition?
ID: /2019/11/23/Does-rsync-requires-changing-UUID-after-copying-a-partition_
Created: November 23, 2019    Edited:  June 12, 2020
Upload: September 15, 2024    Layout:  post
TOC: false    Navigation:  false    Copy to clipboard:  false


rsync can clone your entire /

But with both rsync and dd or another cloning method you must change /etc/fstab and /etc/default/grub and by extension /boot/grub/grub.cfg for Ubuntu to work properly.

From this script: Backup/clone live to a new partition which can be booted

rsync is called like this:

rsync -haxAX --stats --delete --info=progress2 --info=name0 --inplace  \
      /* "$TargetMnt"                                                   \
      --exclude={/dev/*,/proc/*,/sys/*,/tmp/*,/run/*,/mnt/*,/media/*,/lost+found}

Notice the many directories that you do not want to copy specified with the --exclude directive. These directories are either recreated at boot time (virtual file system) or are pointers to other partitions (like /mnt and /media). You might also want to exclude the Trash folder from copying too.

After rsync completes you need to change the aforementioned files like this:

sudo sed -i "s/$SourceUUID/$TargetUUID/g" "$TargetMnt"/etc/fstab
sudo sed -i "s/$SourceUUID/$TargetUUID/g" "$TargetMnt"/boot/grub/grub.cfg
sudo sed -i "s/quiet splash/nosplash/g" "$TargetMnt"/boot/grub/grub.cfg

Where:

Finally to add a GRUB menu option pointing to your new cloned Ubuntu use:

sudo update grub
⇧ Random freezes on 19.04, unsure which logs to check What is the difference between "cat < filename" and "cat filename"?  ⇩