How to clone whole Linux partition with Rsync

Assume that we have mounted a new disk to /mnt/disk2 and that we want to copy the whole / partition to it.

Run the following command:

sudo rsync -aAXv --stats --progress / --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} /mnt/disk2
rsyncRsync is a fast and extraordinarily versatile file copying tool.
-aAXvThe files are copied in archive mode which ensures that symbolic links, devices, permissions, ownerships, modification times, access control lists and extended attributes are preserved.
/Source directory
--excludeExcludes the given directories from backup
/mnt/disk2Target directory

Optional: Install GRUB2 bootloader

Assume that the new disk location is: /dev/nvme1n1.

Run the following command to install the GRUB2 bootloader

sudo grub2-install --root-directory=/mnt/disk2 --force /dev/nvme1n1

Optional: Configure UUID of original partition to the new partition

Run the following command to retrieve the UUID of the original partition:

blkid -o full

Run below command to set the UUI on the target partition:

sudo tune2fs -U ORIGINAL-UUID-HERE /dev/nvme1n1