I read somewhere that after using rsync to copy a partition from one device to other one, it is important to edit the UUID, since devices cannot coexist with the same UUID.
Is it true? How do I do it?
I read somewhere that after using rsync to copy a partition from one device to other one, it is important to edit the UUID, since devices cannot coexist with the same UUID.
Is it true? How do I do it?
rsync does not copy partitionsrsync is a file and folder copying/syncing tool. It is great for syncing a local folder with a folder in a remote computer or backing up folders and files in one computer to another computer.
One thing it does not do is clone a partition. Therefore there is no need to worry about UUID of the partitions while using rsync.
gparted (or dd) to clone a partitionIf you want to copy a partition, use GUI gparted or commandline dd. It will make an exact copy of the original partition with the exact size and free space as in the original. The copy will also have the same UUID.
This is a problem when a system tries to mount a partition by its UUID, such as using the /etc/fstab file and finds two partition with the same UUID. If the original and the copy are in two different computers, or if the copy replaces the original then the same UUID should not be a problem.
gparted:ext4 partitions only)$ tune2fs -U $(uuidgen) /dev/sdXN
or
$ tune2fs -U random /dev/sdXN
where X is a letter, and N is a number specific to the partition of interest.
See answers to this question in Stackexchange for more on changing UUID using the commandline.
Hope this helps
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: Bash script to backkup/clone Ubuntu to another partition
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:
SourceUUID= The UUID of your current partitionTargetUUID= The UUID of your target / clone partitionTargetMnt= The mount point of your clone partitions/quiet splash/nosplash/g line is optional so that when you boot your clone you see a difference with system messages displayed and no splash screen.Finally to add a GRUB menu option pointing to your new cloned Ubuntu use:
sudo update grub