Migrate system from 4TB disk to 2TB SSD SATA
My old system disk has 4 TB space, while the new SATA SSD disk only has 2 TB. Therefore, with Clonezilla, I cannot perform a whole disk migration, but only partition based migration.
Procedures for the migration are listed below.
-
Check the partition table on the old disk using
sudo gdisk -l.Number Start (sector) End (sector) Size Code Name 1 2048 31250431 14.9 GiB 8200 Linux swap 2 31250432 2177685503 1023.5 GiB 8303 Linux x86 root (/) 3 34 2047 1007.0 KiB EF02 BIOS boot partition 4 2178734080 7814037134 2.6 TiB 8309 home 5 2177685504 2178734079 512.0 MiB EF00 EFI-system -
Partition the new disk. The swap partition, BIOS boot partition and EFI-system partition have the same sizes as before. The root partition is reduced to 500 GB. The remaining space on the 2 TB disk belongs to the home partition.
-
Format the swap partition using
mkswap, the EFI partition usingmkfs.fat -F. -
Reboot to Debian live USB.
-
Resize root partition of the old disk to 500GB.
-
Reboot to Clonezilla and copy the root partition from the old disk to the new disk.
-
Shutdown the system. Unplug the old disk and connect the new disk to SATA 3.0 port.
-
Reboot to Debian live USB and do not boot into the old system. N.B. This is very important for a correct installation of grub and EFI.
-
Mount the new root partition on the new disk to
/mnt. Mount the EFI partition to/mnt/boot/efi. Bind system directories:sudo mount --bind /dev /mnt/dev sudo mount --bind /proc /mnt/proc sudo mount --bind /sys /mnt/sysChange the root directory of the shell to the mounted root partition
/mnt:sudo chroot /mnt. Because of the previous binding system directory, the live system’s directories/dev,/prodcand/sysare available in the chroot environment. Then GRUB can see the disks andupdate-grubcan detect file systems and UUIDs. -
Install grub and EFI to the new disk.
sudo grub-install --target=i386-pc /dev/sdb sudo grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB update-grubRun
sudo update-grub. -
Modify the UUID for the root partition in
/etc/crypttaband/etc/fstab. It should now be the UUID of the partition on the new disk. -
Reboot to the system on the new disk.
-
Make LUKS and ext4 file system for the home partition on the new disk.
sudo cryptsetup luksFormat /dev/sdb5 sudo cryptsetup open /dev/sdb5 newhome sudo mkfs.ext4 /dev/mapper/newhome -
Mount the home partition on the old disk and copy data to the new disk.
-
Modify the UUID of the swap partition not only in
/etc/fstab, but also in/etc/initramfs-tools/conf.d/resume. Then update Initramfs:sudo update-initramfs -u, then reboot.