Archive for January, 2014

Cloning Windows 8 or Windows 8.1 on UEFI/GPT disk configuration

Operating Systems, Windows 8 | Posted by p_lider January 6th, 2014

Recently I bought a new SSD disk for my new laptop. I didn’t want to install the whole operating system from scratch so I decided to just clone an existing operating system to this new disk. In the past I never worked with GPT formatted disk, so I thought that the process of cloning disk will be similar – and that was a bad assumption.

When I looked how the existing original disk was partitioned to my surprise I saw 5 (that’s right – five) partitions. They were marked as follows:

  1. OEM Partition (1023 MB in size) – now I know that such partition contains Windows Recovery Environment
  2. EFI System Partition called ESP (360MB in size) – it is similar to “Active Partition” known in MBR formatted disks, the UEFI looks for boot manager only on partitions of this type
  3. Boot, Primary partition – the first partition which is actually seen in My Computer as C: drive and it contains Windows system files
  4. Primary Partition – the second and biggest partition which contains my other data (seen as drive D: in My Computer)
  5. OEM Partition (labeled “Recovery Image”) – contains recovery image which was created by laptop manufacturer

 

So the biggest question was – which of those partitions should I clone to the new disk and how to do this? In the past, when working with Windows XP and MBR formatted disks the only partition I had to clone was the partition, that contained the Windows system files (in the above scenario it would be number 3). But here it was not the case. The files that are required for the system to boot lie on the partition number 2. So after checking what these all 5 partitions contain I went to conclusion, that I need to clone at least 2 partitions:

  • EFI System Partition (partition number 2 in my case)
  • Boot, Primary Partition (partition number 3 in my case)

 

When I finally identified which partitions I should clone, I then needed to chose a tool to actually clone them. In the past I was using SelfImage to do such work, however for some reason this program has problems with GPT disks. So then I used a good old tool, known from UNIX like systems, called DD. There is a port of this wonderful tool for Windows called “DD for Windows“.

Having all my questions answered I started to work with cloning the partitions. This is the procedure I followed to successfully clone my current system to a new SSD disk:

  1. Create 2 partitions on new disk (EFI System partition and Windows Primary partition)
    		
    select disk <destination_disk_number>
    clean
    convert gpt
    create partition efi size=SOURCE_EFI_PARTITION_SIZE
    format quick fs=fat32 label="SYSTEM"
    create partition primary
    format quick fs=ntfs label="Windows"
    exit
  2. Using DD program (or any other partition cloning program) copy all contents of source EFI System partition and Windows Primary partition to the new, just created, partitions.

    WARNING: cloning of the partition which contains Windows system files must be done when the system contained on it is not running – I did that using Win7PE DVD, but you could do this using for example any live Linux distribution.

  3. After cloning is complete you have to assign a letter to both cloned partitions (assume that ESP will be mounted to S, and Windows partition will be mounted to W). Although assigning a letter to cloned Windows partition is not a big deal (you can do this from Disk Management), then assigning the letter to the cloned ESP is not so easy – you cannot do this from Disk Management snap-in. To assign a drive letter to ESP partition you have to do this using DISKPART utility:
    		
    select disk <destination_disk_number>
    select partition <index_of_cloned_esp_partition>
    assign letter=s
    exit
  4. Process of cloning the ESP partition makes one nasty thing to boot manager contained on it – it invalidates the “device” and “osdevice” variables stored within its configuration. So to make the cloned system bootable without BSOD, after the letter to cloned partitions are assigned, you have to edit boot manager configuration contained on ESP partition and properly set the “device” and “osdevice” variables so they point to cloned Windows partition. To do so use the BCDEDIT utility (I assumed below that you mounted cloned ESP partition under S letter and cloned Windows partition was mounted under letter W):
    		
    bcdedit /store s:\boot\bcd /set {default} device partition=W:
    bcdedit /store s:\boot\bcd /set {default} osdevice partition=W:

    WARNING: It is very important to use here a cloned ESP and Windows partitions (mounted under letter S and W), not the original ones.

  5. Done – you should now have a working, cloned Windows 8 system on a new disk.