This information is elsewhere on the web but I thought it might be useful to have it on the forum.
I don't use windows so I've never seen a need to switch to UEFI style booting. Why add a layer of complication when I'm very comfortable with GRUB?
However, the are several serious benefits to using the newer GPT (GUID Partition Table) rather than the ancient MBR (Master Boot Record) partitioning. Some of these are:
Since I'm still using GRUB I don't need an EFI partition, but I do need to reserve space for GRUB to install to. In the early MBR days, GRUB-Legacy (aka GRUB 1) fit neatly ahead within space already reserved by the MBR format. Later, when we went to GRUB-PC (aka GRUB 2) a bit more space was required. Now when using GPT we need to manually reserve the space needed for GRUB2. If you don't reserve this space, GRUB2 won't install to the disk. You'll get the dreaded error:
The good news is the space we need is part of the disk we're not using anyway. Just a few quick steps when you partition your disk before installing to it and you'll avoid the above "gotcha."
What we need to do is create a small partition of a specific type at the beginning of the disk. If you have already formatted your disk using GPT but didn't do this first, don't panic. Unless you did something unusual the space GRUB needs is still there. GPT automatically aligns the first partition at Sector 2048. The easiest (thus best) way to accomplish this is using the "gdisk" utility in terminal mode or from konsole. There are numerous GUI tools for disk partitioning but I won't be explaining any of those as I rarely use them.
To get started, open a terminal window and type:
sudo gdisk /dev/sdb
Use the correct device name for your disk - /dev/sda, /dev/sdb, etc. I will use /dev/sdb for this how-to.
Once you've entered this command the prompt you see will change to:
All commands for gdisk begin with entering a single letter. Here's an example printout of a GPT partition table from disk (using gdisk command "p"):
If you've never used fdisk or gdisk before, note the first line above says "? for help". Entering a ? will print a command list. It's a good idea to review the list if you're new to gdisk. I recommend you hit the ? often as you follow this how-to to review what you're actually doing.
You'll notice at the end of the printout above, the partition table information shows that the first partition starts at sector 2048. We'll be using the space between the first usable sector (34) and the last unused sector (2047) for GRUB. This requires some "expert" mode partitioning.
First we have to change the "sector alignment value" to allow us to begin a sector before 2048. This command is in the "expert" mode of gdisk. To get there we enter "x" and we will see the prompt change again:
Now we will set the sector alignment value to "1" so we can manually pick our target sector 34 for our GRUB partition. This command is "l" (lowercase L):
and then return to the main menu using "m":
Now we can create our new partition using "n" and entering the values we need:
Here, since the only free space on the disk is sectors 34 to 2047, it defaulted to those numbers. There are no entries after the colons above because I needed only hit enter three times to use the defaults. If your disk has other free space or you are starting with a blank partition table you may need to enter "34" and "2047" for the First and Last sectors. You can also specify a partition number here by entering it on the first line. This might be useful if you are regimented about your partition numbers and you have multiple drives on your computer. I allowed the default of "3" to be used (more on numbering partitions later).
Now notice I haven't yet completed this command - I stopped at "Hex code or GUID...". This is where we tell gdisk to use the partition type that GRUB recognizes as space reserved for it to use. The correct entry here is "ef02" ( you can see the entire list of partition types by typing "L" if you wish ). My full entry looks like:
and now my partition table looks like:
This will work fine, I can commit it to disk at this point with the command "w" to "write" the new partition table to disk. However, my personal preference is to have my partition table entries in the same order as they are on the disk. I try to work logically on computers and this is more logical to me. Fixing this is not a problem as gdisk has the "s" command to auto-magically "sort" the partition entries for me:
The warning "You may need to edit /etc/fstab and/or your boot loader configuration!" can safely be ignored if you're using UUIDs in GRUB and fstab, UUID usage has been the default for Ubuntu for quite some time.
Now I can hit "w" and write this all to disk, followed by a "q" to quit gdisk. Now your disk is ready for a GRUB install!
If you started with a blank partition table and now want to create more partitions on this disk, you need to return to "expert" mode and reset the sector alignment back to 2048 (the default) before continuing. The entries to do this are "x", "l" (lower case L), enter, "m". Which, in order do:
and then continue creating more partitions. Or you could just enter "w" to write to disk as it stands, quit gdisk with a "q", and launch your favorite GUI partitioning tool.
Additional comment: The GRUB installer will find and use this partition in it's raw state. There is no need to install a file system to it (aka format) as you will not be using it to store any files. Once you have created the ef02 partition, run grub-install to your disk - sudo grub-install /dev/sdb - as you would have in the past. Do not install grub to this partition -sudo grub-install /dev/sdb1 - as this will not make your drive bootable.
I don't use windows so I've never seen a need to switch to UEFI style booting. Why add a layer of complication when I'm very comfortable with GRUB?
However, the are several serious benefits to using the newer GPT (GUID Partition Table) rather than the ancient MBR (Master Boot Record) partitioning. Some of these are:
- Full duplicate partition table on the disk as a backup in case the primary table gets corrupted or damaged.
- Automatically optimal sector boundary alignment.
- By default, allows up to 128 primary partitions - no "extended" or "logical" partitioning required.
- Maximum device size is well beyond anything produced today.
Since I'm still using GRUB I don't need an EFI partition, but I do need to reserve space for GRUB to install to. In the early MBR days, GRUB-Legacy (aka GRUB 1) fit neatly ahead within space already reserved by the MBR format. Later, when we went to GRUB-PC (aka GRUB 2) a bit more space was required. Now when using GPT we need to manually reserve the space needed for GRUB2. If you don't reserve this space, GRUB2 won't install to the disk. You'll get the dreaded error:
Executing 'grub-install /dev/sda' failed.
This is a fatal error.
This is a fatal error.
What we need to do is create a small partition of a specific type at the beginning of the disk. If you have already formatted your disk using GPT but didn't do this first, don't panic. Unless you did something unusual the space GRUB needs is still there. GPT automatically aligns the first partition at Sector 2048. The easiest (thus best) way to accomplish this is using the "gdisk" utility in terminal mode or from konsole. There are numerous GUI tools for disk partitioning but I won't be explaining any of those as I rarely use them.
To get started, open a terminal window and type:
sudo gdisk /dev/sdb
Use the correct device name for your disk - /dev/sda, /dev/sdb, etc. I will use /dev/sdb for this how-to.
Once you've entered this command the prompt you see will change to:
Code:
Command (? for help):
Code:
Command (? for help): p Disk /dev/sdb: 1953525168 sectors, 931.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): 512242D7-F3BB-4EA1-914B-CEDA513DAB26 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 1953525134 Partitions will be aligned on 8-sector boundaries Total free space is 7 sectors (3.5 KiB) Number Start (sector) End (sector) Size Code Name 1 2048 419430400 200.0 GiB 8300 Linux filesystem 2 419430408 1953525134 731.5 GiB 8300 Linux filesystem
You'll notice at the end of the printout above, the partition table information shows that the first partition starts at sector 2048. We'll be using the space between the first usable sector (34) and the last unused sector (2047) for GRUB. This requires some "expert" mode partitioning.
First we have to change the "sector alignment value" to allow us to begin a sector before 2048. This command is in the "expert" mode of gdisk. To get there we enter "x" and we will see the prompt change again:
Code:
Command (? for help): x Expert command (? for help):
Code:
Expert command (? for help): l Enter the sector alignment value (1-65536, default = 2048): 1 Expert command (? for help):
Code:
Expert command (? for help): m Command (? for help):
Code:
Command (? for help): n Partition number (3-128, default 3): First sector (34-2047, default = 34) or {+-}size{KMGTP}: Last sector (35-2047, default = 2047) or {+-}size{KMGTP}: Current type is 'Linux filesystem' Hex code or GUID (L to show codes, Enter = 8300):
Now notice I haven't yet completed this command - I stopped at "Hex code or GUID...". This is where we tell gdisk to use the partition type that GRUB recognizes as space reserved for it to use. The correct entry here is "ef02" ( you can see the entire list of partition types by typing "L" if you wish ). My full entry looks like:
Code:
Command (? for help): n Partition number (3-128, default 3): First sector (34-2047, default = 34) or {+-}size{KMGTP}: Last sector (35-2047, default = 2047) or {+-}size{KMGTP}: 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):
Code:
Command (? for help): p Disk /dev/sdb: 1953525168 sectors, 931.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): 512242D7-F3BB-4EA1-914B-CEDA513DAB26 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 1953525134 Partitions will be aligned on 1-sector boundaries Total free space is 0 sectors (0 bytes) Number Start (sector) End (sector) Size Code Name 1 2048 419430400 200.0 GiB 8300 Linux filesystem 2 419430408 1953525134 731.5 GiB 8300 Linux filesystem 3 34 2047 1007.0 KiB EF02 BIOS boot partition Command (? for help):
Code:
Command (? for help): s You may need to edit /etc/fstab and/or your boot loader configuration! Command (? for help): p Disk /dev/sdb: 1953525168 sectors, 931.5 GiB Logical sector size: 512 bytes Disk identifier (GUID): 512242D7-F3BB-4EA1-914B-CEDA513DAB26 Partition table holds up to 128 entries First usable sector is 34, last usable sector is 1953525134 Partitions will be aligned on 1-sector boundaries Total free space is 0 sectors (0 bytes) Number Start (sector) End (sector) Size Code Name 1 34 2047 1007.0 KiB EF02 BIOS boot partition 2 2048 419430400 200.0 GiB 8300 Linux filesystem 3 419430408 1953525134 731.5 GiB 8300 Linux filesystem Command (? for help):
Now I can hit "w" and write this all to disk, followed by a "q" to quit gdisk. Now your disk is ready for a GRUB install!
If you started with a blank partition table and now want to create more partitions on this disk, you need to return to "expert" mode and reset the sector alignment back to 2048 (the default) before continuing. The entries to do this are "x", "l" (lower case L), enter, "m". Which, in order do:
Code:
x = extra functionality l = set the sector alignment value enter = accept the default of 2048 m = return to main menu
Additional comment: The GRUB installer will find and use this partition in it's raw state. There is no need to install a file system to it (aka format) as you will not be using it to store any files. Once you have created the ef02 partition, run grub-install to your disk - sudo grub-install /dev/sdb - as you would have in the past. Do not install grub to this partition -
Comment