How to Clone Windows with Clonezilla when the Destination Disk is Smaller than the Original – OR – Cloning a Large Drive to a Smaller SSD

I’ve done this probably about 7 or 8 times now over the last couple of years when it comes to swapping out workstation hard drives with SSDs and it’s pretty much become second nature at this point, but I think the world could use a good write up on this because I’ve wasted countless hours acquiring this knowledge.

So, for today’s lesson, we will be cloning a Windows 8.1 installation from a 500GB desktop hard drive onto a 250GB SSD. Basic knowledge of how to use tools like the command line and Disk Management are assumed.

  1. Install the new or replacement disk (/dev/sdb is our secondary disk in Linux – 250GB SSD) into the computer and boot up the machine into Windows. Go into Computer Managment (run compmgmt.msc as administrator) and go to Disk Management. If the disk is brand new, it will need to be initialized inside of Windows first, and it should ask you to do that now. Set the partition type most likely to GPT.
  2. Once inside of Disk Management, locate and select the main partition that houses your Windows installation (/dev/sda is our primary disk in Linux – 500GB), right-click, select Shrink Volume,  and set it down to a size well below the total capacity of your new disk after it is formatted. In my case, I shrank it down to 180GB just to be on the safe side.
  3. A few things to try if your drive doesn’t want to shrink to a small enough size because of immovable files. Try disabling the Windows Page File, disabling System Restore, deleting the System Restore files, running Disk Cleanup Utility, and running Defrag tool.
  4. Create a Recovery Disk or USB (WinPE environment) for your Operating System.
    Control Panel > Recovery > Create a recovery drive
  5. Run cmd.exe as administrator, and take a screenshot of your boot configuration. This will help you if you run into trouble later.
    bcdedit /enum

  6. Reboot into Clonezilla.
  7. Enter_shell
  8. sudo parted
    unit s
    print all

    Either write down or snap a picture of all the start and end sectors and flags for each partition on /dev/sda. Example below. Also take note as to whether there are any partitions on /dev/sdb that need to go away.

  9. select /dev/sdb

    If there were any existing partitions on this drive, delete them all, we need a clean disk here to work with.

    rm 1

    Now we want to recreate /dev/sda’s partition heirarchy following the same exact sector layout for /dev/sdb, excluding our main Windows partition (4 in this case), since it is smaller. Also, you will need to toggle on and off the exact Flags listed to the right hand side of the picture above, they need to match exactly. I can’t show you every scenario for the flags, so use your own discretion here. Just make them match.

    mkpart primary ntfs 2048 616447
    toggle 1 hidden
    toggle 1 diag
    mkpart primary fat32 616448 821247
    toggle 2 boot
    toggle 2 esp
    mkpart primary ntfs 821248 1083391
    toggle 3 msftres
    mkpart primary ntfs 1083392 100%
    toggle 4 msftdata
    quit
  10. Clear the dirty bit in case Windows has set it on the main partition, otherwise Clonezilla will error out.
    sudo ntfsfix -d /dev/sda4
  11. Get back into Clonezilla by hitting Ctl+Alt+Del to restart and then press F9 or whatever hotkey to get to the boot menu to get back into the application.
  12. Now we want to run the basic Clonezilla wizard options for device to device and then local part to local part. Run the wizard for each partition selecting /dev/sda1 as the source and /dev/sdb1 as the destination. Do this for all remaining partitions respectively (/dev/sda2 to /dev/sdb2, /dev/sda3 to /dev/sdb3, and /dev/sda4 to /dev/sda4).
  13. When finished cloning, get back to the command prompt by selecting that option and back up the boot sector and partition table, but then only restore the one portion of it that we need.
    sudo dd if=/dev/sda of=/tmp/mbr.img bs=512 count=1
    sudo dd if=/tmp/mbr.img of=/dev/sdb bs=446 count=1
  14. Poweroff the machine and disconnect old hard drive (/dev/sda)
  15. Insert your recovery disk and boot into the WinPE recovery environment, selecting the following options:
    US > English (United States) > US > Troubleshoot > Advanced options > Command Prompt
  16. Open the Windows Disk Partition utility.
    diskpart
    list volume
  17. Find the FAT32 boot partition (around 100MB) and assign a drive letter to it.
    select volume 3
    assign
    list volume
    

    Get the drive letters of the main windows partition and the boot partition and then type exit.

  18. Show the BCD, then update the unknown device paths. Make sure to set the correct drive letter of whatever it showed in the previous step. You may or may not have to update the {bootmgr} entry to show the correct path.
    bcdedit /enum
    bcdedit /set {default} device partition=C:
    bcdedit /set {default} osdevice partition=C:
    exit > Turn Off PC
  19. At this point, hopefully everything works as it should. I like to run check disk on the new disk just for good measure.
    Run cmd.exe as administrator
    chkdsk /f C:
    Type Y to confirm at next startup and then reboot
    shutdown /r /t 0

    Let check disk run, log back into Windows, Enjoy. The End.

Leave a Reply