This article is triggered by the real case when I have not only to clone larger (external) disk into a smaller one, but to keep cloned disk bootable as it’s source.
The article is mainly reminder what I need to do, as I frequently need to prepare PoC (Proof of Concept) that requires to run VirtualBox or similar technology on external HDD drives.
The other reason for writing an article about cloning bootable HDD on a smaller external disk was triggered with my frustration that after searching the Web, I still didn’t find complete and correct answer that will resolve problem I’m dealing with.
In my case I have one larger external 1 Tb HDD (source disk) that I want to clone to a smaller one external 500 Gb HDD.
In order to do that, here are the steps you should take:
Find out disk layout from the source disk.
firstname.lastname@example.org:~>sfdisk -l /dev/sdb Disk /dev/sdb: 931,5 GiB, 1000204885504 bytes, 1953525167 sectors Disk model: Silicon-Power Units: 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: 0x0003898a Device Boot Start End Sectors Size Id Type /dev/sdb1 * 2048 128907263 128905216 61,5G 83 Linux /dev/sdb2 128909310 193359871 64450562 30,8G 5 Extended /dev/sdb5 128909312 193359871 64450560 30,8G 82 Linux swap / Solaris /dev/sdb6 193359872 1631584256 1631584256 778,6G 87 Extended
Boot from source 1Tb HDD and copy all files you have on the largest sdb6 partition to some other disk, as in case your larger source disk is above 500 Gb, you won’t be able to copy all from.
After that you can delete /dev/sdb6 partition by using fdisk or GParted or Disks if you prefer GUI based tools.
You can also resize partition(s) to fit to your destination disk.
Finally you can proceed with a next step.
Dump disk layout of your source 1Tb disk into the file by executing the following command:
email@example.com:/home/josippo/Desktop>sfdisk -d /dev/sdb > partition_disk
Partition your target disk equally to your source disk by executing the following:
firstname.lastname@example.org:/home/josippo/Desktop>sfdisk /dev/sdc < partition_disk Checking that no-one is using this disk right now ... OK Disk /dev/sdc: 465,8 GiB, 500107862016 bytes, 976773168 sectors Disk model: HDD CH94 Units: 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: 0xdd26c0e1 Old situation: >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Script header accepted. >>> Created a new DOS disklabel with disk identifier 0x0003898a. /dev/sdc1: Created a new partition 1 of type 'Linux' and of size 61,5 GiB. Partition #1 contains a ext4 signature. /dev/sdc2: Created a new partition 2 of type 'Extended' and of size 30,8 GiB. /dev/sdc3: Created a new partition 5 of type 'Linux swap / Solaris' and of size 30,8 GiB. Partition #5 contains a swap signature. /dev/sdc6: Done. New situation: Disklabel type: dos Disk identifier: 0x0003898a Device Boot Start End Sectors Size Id Type /dev/sdc1 * 2048 128907263 128905216 61,5G 83 Linux /dev/sdc2 128909310 193359871 64450562 30,8G 5 Extended /dev/sdc5 128909312 193359871 64450560 30,8G 82 Linux swap / Solaris The partition table has been altered. Calling ioctl() to re-read partition table. Syncing disks.
Finally you need to insert Clonezilla CD/DVD or USB stick and to reboot your machine.
When Clonezilla starts, when you get into the following screen you need to choose device – device option as in the following screenshot.
After that it is important to choose Expert mode (Beginner mode is default).
On the option screen, you should disable the first option (Reinstall grub on target hard disk boot sector).
The last important option you need to choose is “-k” Do NOT create partition table on boot sector on target machine.
By combining several tools and tricks, you should be able to clone your bootable, writible large external HDD into the smaller one, and release space on your larger external HDD.