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?
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It only takes a minute to sign up.
Sign up to join this communityrsync
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
dd
and dc3dd
for that matter will also copy the UUID(s) which may need to be changed
Nov 23, 2019 at 0:29
man rsync
. My first bash file with rsync commands, I included the description of parameters so I could remember what I was doing.
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
rsync
does not copy partitions, it can copy all the contents of a partition. If that copied partition happens to be a root files system (/
) partition. One would need to change reference to the UUID of the source partition to the new destination partition's UUID within the copied files so that the system files can work properly and use the new partition as the system partition.
Nov 24, 2019 at 18:46
rsync
works on files located on a file-system, the UUID is related to the file-system itself and is a lower level than the files that can then be stored on it. Different levels of the 'stack'