Today I tired to convert my Windows 2TB RAID disk from a master boot record (MBR) layout to a GUID partition table (GPT) one. The reason I wanted to swap is that GPT supports partitions larger than 2TB. Normally it is easy to convert a MBR disk to a GPT one by using the Disk Management GUI. However, Microsoft do not allow you to convert you disk if you have any partitions on the disk.
After some searching I found that you could convert the disk non-destructively on Linux, but due to various reasons, my RAID does not work inside my Debian Linux :( I had also read a document outlining how to the conversion works, and it seems such a simple process I was surprised that Microsoft didn’t support it.
Some more searching and I found a Linux/Windows tool that will convert MBR to GPT quite easily. Gptgen is a simple command line tool that seemed to work like a charm. I will quickly outline the steps I took to use it “safely”.
Firstly I identified with disk I wanted to alter. This is done by looking at which number the disk is in Disk Management. I then quickly tested the tool without writing the changes
This outputted quite a few lines, including the following:
Write primary.img to LBA address 0. Write secondary.img to LBA address 4395431903.
When you don’t write the changes to disk, gptgen creates two binary files “primary.img”, and “secondary.img”, which contain what it would have written to disk. The console output from gptgen tells me it would have written primary to LBA address 0, and secondary.img to LBA address 4395431903. So I figured it was a good idea to make a backup of those sections first. To do this I use the Windows version of the classic tool dd
dd if=\\.\\physicaldrive1 of=primary-backup.img bs=512 count=34 dd if=\\.\\physicaldrive1 of=secondary-backup.img bs=512 count=33 skip=4395431903
The count and skip values might have to change. The two count values relate to the file sizes of primary.img and secondary.img. Find their file sizes and divide them by 512. In my case, primary.img was exactly 17,408 bytes, so 17408 / 512 = 34. Do the same for secondary.img. The skip number is the LBA address shown by gptgen just a minute ago.
Ok, if you have run dd ok, you should have backups of the two sections it is going to overwrite. Now you can tell gptgen to actually make the changes:
gptgen.exe -w \\.\\physicaldrive1
That should be it, BUT if you need to (for whatever reason) restore the backups issue these commands:
dd if=primary-backup.img of=\\.\\physicaldrive1 bs=512 count=34 dd if=secondary-backup.img of=\\.\\physicaldrive1 bs=512 count=33 seek=4395431903
(notice how the “if” and “of” arguments have swapped, and the word “skip” has changed to “seek”.)