You are not logged in.

#1 2012-07-22 14:44:48

itti
Member
Registered: 2007-06-01
Posts: 77

Is there a streamlined process for the MBR -> GPT -> GRUB transition?

Hi,

I've spend this weekend on and off reading bbs and wiki entries about GPT conversion from MBR partitioning under the light of replacing grub-legacy with grub-bios. At the moment I maintain five different arch boxes that all use full system encryption (luks). Every machine has it's own storage setup (multiple HDDs for desktop machines and usually single HDDs for laptops, different sizes, some multi boot with windows)... The main problem here seems to be this strange requirement to both have free space after the last partition (for GPT) and free space (2MB for grub) before the boot partition. When I set up the machines I usually allocated the whole disk and there is no unpartitioned space left. My laptop for example has it's partitions layed out like this:

Disk /dev/sda: 320.1 GB, 320072933376 bytes
255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0xc5d3bc32

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *          63      498014      248976   83  Linux
/dev/sda2          498015     8498384     4000185   83  Linux
/dev/sda3         8498385   625142447   308322031+  83  Linux

So /dev/sda1 is /boot, /dev/sda2 is encrypted swap and /dev/sda3 is encrypted /.

Here the swap partition is needlessly big. In theory I may be able to shrink the swap partition by disabling swap and using gparted. I could then move the boot partition 2MB from the beginning of the drive so that grub-bios can be satisfied. But how am I supposed to move my encrypted root partition? Is this even doable?

And that's just the simplest of all my machines partitioning wise. I fear until there is some kind of streamlined process to shrink/move LUKS-partitions and do this MBR->GPT->Grub transition I may have to stay with grub-legacy or maybe switch to syslinux. What I like about grub is the built in boot shell that often saves oneself from the fatality of boot config errors. Is something similar possible with plain syslinux?

Last edited by itti (2012-07-22 14:45:37)

Offline

#2 2012-07-22 22:36:42

cedeel
Member
From: ~
Registered: 2009-08-25
Posts: 176
Website

Re: Is there a streamlined process for the MBR -> GPT -> GRUB transition?

Why do you think you need GPT for Grub2?

Also, GPT is a no-go if multibooting with Windows (BIOS mode).

Offline

#3 2012-07-22 23:12:42

ataraxia
Member
From: Pittsburgh
Registered: 2007-05-06
Posts: 1,553

Re: Is there a streamlined process for the MBR -> GPT -> GRUB transition?

Indeed, you don't actually have to move to GPT to use GRUB 2. grub-install will complain if there's not enough space to install the boot blocks at the start of the drive, and refuse to mess up your disk. At that point, you could copy the contents of /boot someplace on / temporarily, recreate /boot a little smaller (with the start moved later on the disk, not the end), move your boot files back, and then retry grub-install again.

If you do just want to move to GPT anyway, I'd suggest opening /dev/sda with "gdisk" to see if it complains that it needs more space at the end of the disk. You may get lucky (as I did here), such that there's already a little space there, which was too small to use for that last partition, but is still big enough for the GPT backup table. (If you're not lucky here, just don't save in gdisk, and probably give up here - it's not worth the effort to move your encrypted root.) If there is enough room, gdisk won't give any complaint at startup, so you can boot from an ISO, run gdisk again, and actually save changes this time. Assuming successful conversion, then you could do the same /boot-recreate trick as above to make room for the 2 MB BIOS boot partition. Don't forget to re-run grub-install and grub-mkconfig after all that is done - GRUB cares which format your disk is in, in both the boot blocks themselves and the grub.cfg.

Good luck!

Offline

#4 2012-07-23 09:12:50

itti
Member
Registered: 2007-06-01
Posts: 77

Re: Is there a streamlined process for the MBR -> GPT -> GRUB transition?

cedeel wrote:

Why do you think you need GPT for Grub2?

I know that i don't necessarily need it but the wiki says:

wiki wrote:

If you do not dual-boot with MS Windows (any version) in BIOS systems, it is advisable to switch to GPT partitioning

I do not know exactly why that step is advisable but i figured if I undertake the risk of screwing up my boot process I should at least make the jump to GPT on the same time. It seems that the process of setting up grub-bios differs with regard to the partitioning scheme used.

@ataraxia: You're basically saying that if easy conversion to GPT is not possible (I already checked two of my systems and neither does have enough unpartitioned space left at the end of the disk) I should leave the disk partitioned as MBR and just recreate/shrink my boot partition to satisfy grub? What would be a lower limit on the size of the boot partition? This machine here right now already only has 100MB allocated for /boot.

Last edited by itti (2012-07-23 09:21:12)

Offline

#5 2012-07-23 12:41:09

Lone_Wolf
Member
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 11,868

Re: Is there a streamlined process for the MBR -> GPT -> GRUB transition?

archwiki wrote:

Usually the post-MBR gap (after the 512 byte MBR region and before the start of the 1st partition) in many MBR (or msdos disklabel) partitioned systems is 32 KiB when DOS compatibility cylinder alignment issues are satisfied in the partition table. However a post-MBR gap of about 1 to 2 MiB is recommended to provide sufficient room for embedding GRUB2's core.img

This indicates that shrinking /boot with 2 Mib should be enough.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.


(A works at time B)  && (time C > time B ) ≠  (A works at time C)

Offline

#6 2012-07-23 16:47:51

2011gil
Member
Registered: 2012-01-04
Posts: 18

Re: Is there a streamlined process for the MBR -> GPT -> GRUB transition?

itti wrote:
cedeel wrote:

Why do you think you need GPT for Grub2?

I know that i don't necessarily need it but the wiki says:

wiki wrote:

If you do not dual-boot with MS Windows (any version) in BIOS systems, it is advisable to switch to GPT partitioning

I do not know exactly why that step is advisable but i figured if I undertake the risk of screwing up my boot process I should at least make the jump to GPT on the same time. It seems that the process of setting up grub-bios differs with regard to the partitioning scheme used.

@ataraxia: You're basically saying that if easy conversion to GPT is not possible (I already checked two of my systems and neither does have enough unpartitioned space left at the end of the disk) I should leave the disk partitioned as MBR and just recreate/shrink my boot partition to satisfy grub? What would be a lower limit on the size of the boot partition? This machine here right now already only has 100MB allocated for /boot.

Windows 8 needs GPT, so I believe that the step is "advisable" if you only have one drive. However, if your machine has two hard drives, I do not see a reason why you couldnt have Windows in a separate (GPT) drive and your Linux stuff on the other one (MBR). But of course, if you need the flexibility of having parts of your OS in different drives, you would need both being GPT. And of course if you dont use/dont plan to upgrade to Windows 8, your life is easier.

Last edited by 2011gil (2012-07-23 16:48:31)

Offline

#7 2012-10-24 14:17:37

drcouzelis
Member
From: Connecticut, USA
Registered: 2009-11-09
Posts: 4,092
Website

Re: Is there a streamlined process for the MBR -> GPT -> GRUB transition?

itti wrote:

I know that i don't necessarily need it but the wiki says:

wiki wrote:

If you do not dual-boot with MS Windows (any version) in BIOS systems, it is advisable to switch to GPT partitioning

I do not know exactly why that step is advisable but i figured if I undertake the risk of screwing up my boot process I should at least make the jump to GPT on the same time. It seems that the process of setting up grub-bios differs with regard to the partitioning scheme used.

I went through the exact same thought process. After doing more research about the MBR, GPT, and other operating systems, I went ahead and edited the wiki page to (hopefully) something a lot less nebulous. tongue

Summary: If MBR worked for you last week, then MBR will work for you next week.

Offline

#8 2012-10-24 15:06:40

WonderWoofy
Member
From: Los Gatos, CA
Registered: 2012-05-19
Posts: 8,414

Re: Is there a streamlined process for the MBR -> GPT -> GRUB transition?

I would imagine the reason why there is the recommendation of gpt over mbr is simple the features of gpt.  You can have up to 128 primary partitions by default (though you can change this by enlarging the area that holds the partition info).  It doesn't depend whatsoever on those rediculous extended partitions, which can be dangerous because the real parition info is not held in the mbr itself, but rather in the expended partition's superblock.

Also, the free space at the end of the drive is actually a backup of the partition table.  It really doens't take very much space, so if you downsize your last partition by a couple MB, it should be plenty.  I have actually had a device fall back to this partition before, so it is actually a pretty awesome feature.  With mbr, if it get corrupted, or if an extended partition's superblock gets corrupted, there goes all your partitions... no backup to speak of.

If you like the way grub-legacy was set up and configured, you should give syslinux a try.  It works, and it works well.  What I didi't like about grub2, besides all the bloat I didn't need, was the fact that configuration was done in /etc/default/grub, and you relied on the grub-mkconfig command to generate the config file for you.  To me, it just seems like you are going through several steps to achieve the same thing that used to take a single step of editing a file.  This is of course just personal preference, but our wiki has some pretty great info on syslinux.


Edit: BTW, gdisk (gptfdisk) has an option to "load MBR and build fresh GPT from it" in the "recovery and transformation options (experts only)" section.  I would have to imagine that this would not take care of your need for free space at the end of the disk, but it should simplify things after you create it.

Last edited by WonderWoofy (2012-10-24 15:09:24)

Offline

Board footer

Powered by FluxBB