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
dd
and dc3dd
for that matter will also copy the UUID(s) which may need to be changed
– Elder Geek
Nov 23 '19 at 00:29
rsync
– BlueSkies
Nov 23 '19 at 14:11
rsync
you are not cloning partition, you are copying folders.
– user68186
Nov 23 '19 at 14:15
rsync
works. Is it similar to copy/paste in Windows? Copy/paste in Windows adds new files, replaces old ones and retains the rest. Or the rsync
first removes all the files from the destination partition and then copies all files from the source partition?
– BlueSkies
Nov 23 '19 at 14:43
rsync
is like copy and paste. Type man rsync
in a terminal to read the "manual". It has many options that modifies how it works. For example it can overwrite existing files with the same name, or skip them, or only overwrite if the file in the destination is older than the one at the source, etc.
– user68186
Nov 23 '19 at 14:51
man rsync
. My first bash file with rsync commands, I included the description of parameters so I could remember what I was doing.
– oldfred
Nov 23 '19 at 14:53
rsync
. It can do many things and it is always good to check the man
.
– user68186
Nov 23 '19 at 15:08
-Havn
option (because someone recommended it) but I don't understand what is the -H
supposed to do...
– BlueSkies
Nov 23 '19 at 15:15
rsync
options you are recommending to use.
– BlueSkies
Nov 23 '19 at 16:07
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.
– user68186
Nov 24 '19 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' – guiverc Nov 22 '19 at 23:48