Copy one partition to another in Ubuntu Linux
February 23, 2024
NOTE: Following are just for copying one partition from another, they don't discuss generating new UUID and editing fstab that you will have to do if you want to change the mount points
With rsync
code
sudo rsync /home/. /media/home/.
If you want to exclude some files, you can add them with the --exclude= flag, for example: --exclude='/*/.gvfs'
code
--exclude=PATTERN exclude files matching PATTERN
--exclude-from=FILE read exclude patterns from FILE
Check that the copying worked:
code
sudo diff -r /home /media/home -x ".gvfs/*"
With dd
code
sudo dd if=/dev/sdx1 of=/dev/sdy1 bs=64K conv=noerror,sync
/dev/sdx1 is the source partition (input) and /dev/sdy1 is the destination (output)
ifprovides input file (instead of the standard input)ofprovides output filebsmeans block sizenoerrormeans do not stop processing on an input error
With gparted
In the GParted GUI, right click on the drive and select Copy, then right click on the drive where you want to copy to and select Paste