PDA

View Full Version : HOWTO: Convert MBR to GPT without data loss



bendib
24th September 2012, 01:25 AM
I've made a YouTube video explaining this. It's not hard to do. If anyone can add the correct procedure for installing grub 2 on a partition (not MBR) and adding an MBR that boots the partition marked legacy_boot, I will be grateful.

Click here (http://www.youtube.com/watch?v=wL-BErhF_uM) to view the video. I tried to make it short and to the point.

EDIT: If you encounter a message saying that your partition can only be created a slight bit smaller than it's original size, you have two options: resize2fs /dev/sdawhatever, which has a chance it may not work/could kill your filesystem (unlikely but possible, don't try on a nearly full fs) and requires a bootable medium other than your HDD, or you can recreate your partition table as DOS.

Dan
24th September 2012, 01:42 AM
Hmmm.

Maybe time to go back and read the "How to use the forum" manual ... and maybe the posting rules, too! <..:p..>

Duplicate thread deleted.

bendib
24th September 2012, 01:50 AM
Duplicate? I only posted this once.

Dan
24th September 2012, 01:53 AM
You ended up with two threads posted, one right after another. No harm, no foul. I simply deleted the other one.

bendib
24th September 2012, 01:54 AM
Weird. I must've bumped the button twice or something. Anyhow, it wasn't intentional.

PabloTwo
24th September 2012, 01:56 AM
Dan, this has happened several time to me, and many others, on the forum in the past. Post once, and get two copies of your post. I guess it's V-Bulletin running another one of it's "two for one" specials.

Dan
24th September 2012, 01:56 AM
That happens sometimes. Opera is notorious for it.

Demz3
24th September 2012, 02:23 AM
vbulletin5 will fix all :rolleyes:

Dan
24th September 2012, 02:28 AM
Okey dokey! Just send me a donation cheque for the full amount ... and we'll get right on that.

Demz3
24th September 2012, 02:42 AM
Okey dokey! Just send me a donation cheque for the full amount ... and we'll get right on that.

sure not a prob. but you might think twice about it once you see it :dance:

weitjong
24th September 2012, 07:08 AM
I have done the partition table conversion recently from MSDOS to GPT myself to make a triple boot system on my SSD. No offense, isn't it much easier to do the conversion automatically by using "gdisk" command? The conversion can be done by simply answering "yes" when it offers to convert the disk when it starts. It keeps the existing partitions allocation and of course without losing any data. However, as usual, I only have stomach to perform this kind of things after I have my SSD fully backup using "dd" and boot into single user mode first.


If anyone can add the correct procedure for installing grub 2 on a partition (not MBR) and adding an MBR that boots the partition marked legacy_boot, I will be grateful.

I suppose you still use legacy BIOS mode to boot or otherwise you don't need bootloader in the MBR anymore. In the video, your first partition appears to start at sector 2048. That should give Grub2 plenty of space to install the Grub2's second stage core image in the space between MBR and 2048s, after it has installed the first stage within the MBR. I think a simple 'grub2-install /dev/sda' will do.

However, for discussion sake, if your first partition starts at lower sector number (like mine starts at 40s) then you will need to create a new partition of type "BIOS Boot Partition" using gdisk. I find a few articles on net recommends to create 2 MB but I created mine with 1 MB only and Grub2 is happy to embed its second stage image there. So, even in the latter scenario, a simple 'grub2-install /dev/sda' will do. No 'force' required.

bendib
24th September 2012, 07:30 AM
I'm aware of that method, but it's not safe enough for me IMHO. The point of my tutorial is to recreate your partitions on a bare GPT label, to do a "pure" conversion. I also don't trust auto-reordering of my partitions to another program. I also imagine that gdisk may struggle with extended partitions and other trickery, making it even less viable. My method is usable for other partition tables as well, and can be used to revert to MS-DOS tables and even just pull a partition from an extended partition.

I don't like bootloaders that try to be the only one on my system by installing themselves in the 44(0,6) byte MBR. I like MBRs that boot the active partition, and bootloaders installed on partitions.

I appreciate your commentary.

weitjong
24th September 2012, 08:09 AM
I see your point.

Also, I think now I understand better your question. Do you want "additional" bootloader in active partition so that you can chainload it or multiboot it? To my knowledge that would only work if you have a bootloader in MBR of your BIOS boot drive and has configured it to do the chainloading to other bootloader OR multibooting (to other 2nd stage core image) in its grub.cfg. Still I assume you are using legacy BIOS mode. I cannot see how you can set that up without any bootloader in MBR.

If you use UEFI mode then the story would be totally different. I have not played enough with UEFI mode so I would not make anymore comments about it here other than this, the bootloaders are installed in the ESP (EFI System Partition) instead of MBR.

bendib
24th September 2012, 08:28 AM
All my machines are BIOS based excluding my PPC boxes, I have never come in contact with a non-apple EFI system. My machines are all rather old, but that doesn't mean that they can't benefit from a new partition table. What I want to be able to show people how to do with GRUB is install it onto ONLY a partition and let the MBR (which should boot any partition labeled legacy_boot) boot this partition if it's legacy_boot flag is set.

weitjong
24th September 2012, 08:49 AM
Do not get me wrong. This has nothing to do with the choice of partition table type, no one says old machine cannot use GPT, no one says legacy BIOS cannot use GPT. There is nothing magical about MBR, it is a designated space where the first stage of the bootloader is being installed within the confined space and configure in such a way to continue the BIOS bootstraps process. Perhaps you should redefine your question in other thread so it would be better answer. Sorry for my bad English but it appears that I have misunderstood your question twice.

Thanks for sharing your video.

bendib
24th September 2012, 09:38 AM
No problem. Take care friend. :^)