I’ve decided to summarize my steps as posted here (https://forums.opensuse.org/showthread.php/514114-Cloning-an-entire-SSD-Step-by-Step-Instructions) as I found it useful for personal reference in the past couple of years. Thanks to the wonder OpenSUSE community, I was able to benefit from it for many years.
The following will show steps of using dd, destructor of disks (name arguable) which are default to any bash environments to clone an entire drive to either upsize or duplicate drive. This can also clone Windows drives/partitions without an issue from my previous experience.
First you need to be a super user su or root (you can use sudo, but for ease I will stick with su).
Second, you need to check the list of mounted disks and identify them.
Output will look similar to this:
Disk /dev/sda: 477 GiB, 512110190592 bytes, 1000215216 sectorsUnits: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 512 bytes I/O size (minimum/optimal): 512 bytes / 512 bytes Disklabel type: dos Disk identifier: 0xa4624f87 Device Boot Start End Sectors Size Id Type /dev/sda1 * 2048 224249855 224247808 107G 83 Linux /dev/sda2 224249856 958253055 734003200 350G 83 Linux Disk /dev/sdb: 1.8 TiB, 2000398934016 bytes, 3907029168 sectors Units: sectors of 1 * 512 = 512 bytes Sector size (logical/physical): 512 bytes / 4096 bytes I/O size (minimum/optimal): 4096 bytes / 4096 bytes Disklabel type: dos Disk identifier: 0x9e93f24f Device Boot Start End Sectors Size Id Type /dev/sdb1 63 1264582717 1264582655 603G 7 HPFS/NTFS/exFAT /dev/sdb2 1264582718 3878672684 2614089967 1.2T 7 HPFS/NTFS/exFAT
Let’s pretend we are cloning from /dev/sda (in my case a small SSD) to /dev/sdb (in my case a larger data HDD). Let’s first check the block size of the source drive.
blockdev --getbsz /dev/sda
Typically it is 4KB,
but write down the resulting value just to be sure. Now the next step, be sure to triple check
dd if=/dev/sda of=/dev/sdb bs=4K conv=noerror,sync
You can also do this by the following:
dd if=/dev/sda of=/dev/sdb bs=$(blockdev --getbsz /dev/sda) conv=noerror,sync
Now, just be sure that connections are not disrupted and let it clone.
As for expanding the size of partition for upgrading, I typically use gparted or OpenSUSE partitioner to resize the partition(s). The exact same steps can be done for individual partitions. For example:
dd if=/dev/sda1 of=/dev/sdb bs=$(blockdev --getbsz /dev/sda1) conv=noerror,sync
Just be sure that if=source_partition of=target_drive
In a 4 core system, from 2TB HDD SATA to 2TB HDD USB3, it took about 8 hours to complete.
In my case, I always used these instructions above to clone a drive with the intention of replacing the original drive. After cloning, and swapping out the drives on the windows drive would work out of the box, and the linux drive will need a tweak if the partition size has been changed. Typically UUID changes. Since in OpenSUSE drives are mounted by UUID, this can cause a problem and end up being unable to boot. In that case, before you swap out the drive, check:
cat /etc/fstab UUID=**f88fa3c1-7b7c-4516-b55c-59aaa9fd878a** / ext4 acl,user_xattr 0 1 UUID=**b10f9657-b2f5-4e38-b7ec-437d37ea83f8 ** /home ext4 data=ordered,acl,user_xattr 0 2 UUID=FA3ADDB33ADD6CDF /mnt/Shared_Transfer ntfs defaults 0 0
and the UUID of the original drive, then check:
blkid /dev/sda1: UUID="**f88fa3c1-7b7c-4516-b55c-59aaa9fd878a**" TYPE="ext4" PARTUUID="a4624f87-01" /dev/sda2: UUID="**b10f9657-b2f5-4e38-b7ec-437d37ea83f8**" TYPE="ext4" PARTUUID="a4624f87-02" /dev/sdb1: LABEL="Windows_Dedicated" UUID="C448EE2E48EE1EC4" TYPE="ntfs" PARTUUID="9e93f24f-01" /dev/sdb2: LABEL="Shared_Transfer" UUID="FA3ADDB33ADD6CDF" TYPE="ntfs" PARTUUID="9e93f24f-02"
the UUID of the replacement drive. If they are not the same, backup the fstab
cp /etc/fstab /etc/fstab_backup
then replace the UUID of the partitions that are being moved to the new drive, using an editor such as vim, nano or in my case emacs.
Now you can replace the drive and (almost) everything will work as if nothing has changed. I found that typically if google-chrome was open while copying, its configuration file gets fudged and need to be re-installed, which is very easy to do.