Announcement

Collapse
No announcement yet.

Using GRUB with GPT drives in legacy BIOS mode

Collapse
This topic is closed.
X
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Using GRUB with GPT drives in legacy BIOS mode

    This is documented elsewhere on the web, but I thought since I had run into it yesterday, I would put it here too.

    I am upgrading my server so I have a new Mobo, CPU, and RAM to get running. I wiped a small SSD for the OS, leaving the big drives for the storage pool. When attempting to install Ubuntu server, it failed at installing GRUB. Now, I could go into my BIOS, enable EFI mode, figure out how to install rEFInd or some other boot manager and move on without GRUB, but this is a server. It only boots one OS and frankly, I wasn't in the mood to learn EFI at the time.

    Installing grub to a GPT disk works fine if you take a small step before attempting the install. You have to create a special partition for GRUB to use of the type EF02. The nice thing is it takes zero usable space away from your drive. Here's the steps to create this partition. Use the correct drive letter in place of sda in the following example. I have included the terminal output along with all the commands.

    Code:
    user@mypc:~$sudo gdisk /dev/sda
    GPT fdisk (gdisk) version 0.8.10
    
    
    Partition table scan:
      MBR: protective
      BSD: not present
      APM: not present
      GPT: present
    
    
    Found valid GPT with protective MBR; using GPT.
    
    
    Command (? for help): x
    
    Expert command (? for help): l
    Enter the sector alignment value (1-65536, default = 2048): 34
    
    
    Expert command (? for help): m
    
    
    Command (? for help): n
    Partition number (1-128, default 1): 1
    First sector (34-3907029134, default = 34) or {+-}size{KMGTP}: 34
    Last sector (34-2101247, default = 2101247) or {+-}size{KMGTP}: 2047
    Current type is 'Linux filesystem'
    Hex code or GUID (L to show codes, Enter = 8300): EF02
    Changed type of partition to 'BIOS boot partition'
    
    
    Command (? for help): p
    Disk /dev/sda: 3907029168 sectors, 1.8 TiB
    Logical sector size: 512 bytes
    Disk identifier (GUID): FA7FD45C-E141-4DB3-A867-D80C4B41C281
    Partition table holds up to 128 entries
    First usable sector is 34, last usable sector is 3907029134
    Partitions will be aligned on 34-sector boundaries
    Total free space is 2099343 sectors (1.0 GiB)
    
    
    Number  Start (sector)    End (sector)  Size       Code  Name
       1              34            2047   1007.0 KiB  EF02  BIOS boot partition
    
    
    Command (? for help): w
    As an explanation of what you've done, the gdisk commands/entries are:
    x - enable expert mode.
    l - change the sector alignment value so you can use otherwise wasted space.
    34 - is the first truly free sector in the first 2 megs of your GPT disk.
    m - returns you to the main menu.
    n - create new partition.
    1 - the new partition number - could be another number if you wish or already have other partitions on this disk.
    34 - the beginning of the new partition (likely, this will show as the default so ENTER works).
    2047 - the end of the new partition.
    EF02 - the partition type code for a GRUB partition.
    w - write the changes and exit.
    You will now be able to install grub to your GPT disk.

    *** If you want to create other partitions at the same time, you must go back to the expert menu (x) and change the sector alignment back to 2048. ***
    Last edited by oshunluvr; Sep 10, 2015, 08:09 AM.

    Please Read Me

    #2
    Nice work.

    So the BIOS Boot Partition is plenty big at (2047-34)*512 B.
    GRUB Stage 1 goes into the Protective MBR; GRUB Stage 2 goes into this new partition you just created, the EF02, BIOS Boot Partition.

    The gdisk is pretty neat, isn't it?

    Nice write-up.
    An intellectual says a simple thing in a hard way. An artist says a hard thing in a simple way. Charles Bukowski

    Comment


      #3
      Thanks. Yeah, not my work but useful info. I had done this before but only found out recently the little trick of using sectors 34-2047. Might as well use space not used elsewhere. I also use a small dedicated grub partition on my multi-booting desktop that holds necessary grub files so I can wipe and re-install without worrying about messing up GRUB.

      You my have noted this was done on a 2TB drive but my server has a 32GB SSD as a boot device. This drive will actually move to the server soon too. I'm re-configuring my desktop a little bit and upgrading server. It has two old 1TB drives I'm replacing (still work, but are 7ish years old!) with a 2TB and 6TB WD "Red" drives. I use the server to stream video so I decided it was time to upgrade the whole kit-n-kaboodle. I'm going from a 1.8GHz Atom to an i3 T-4160 at 3.1-3.6GHz. It's a 35W CPU so I'll reduce my electricity and heat while quadrupling the CPU speed (added hyper-threading along with the higher GHz). This also adds DDR3 (vs DDR2) RAM, USB 3.0, Sata III, wifi along with the dual NICs. and doubles the RAM. All for less than $280, not including the drives of course. A heck of a nice upgrade...

      Please Read Me

      Comment

      Working...
      X