Making your drive bootable
This is an enhancement to the information provided by Krunal and clarkttfu with more details on the steps to create a BIOS boot partition and install grub to it.
If you are changing the partition table on a a boot drive you will need to create a new "BIOS boot partition" for grub to store the bootloader in. These examples use the drive /dev/sda which will usually be the boot drive.
First, validate that there is space before the current first partition to support a boot partition, fisk -l should show that the first partition starts at sector 2048:
johnf@ubuntu:~$ sudo fdisk -l /dev/sda
[...]
Device Boot Start End Sectors Size Id Type
/dev/sda1 * 2048 499711 497664 243M 83 Linux
/dev/sda2 501758 125829119 125327362 59.8G 5 Extended
/dev/sda5 501760 125829119 125327360 59.8G 8e Linux LVM
If it does then you have the space required to create the partition. If it doesn't you cannot follow these instructions and have a bootable system.
Use gdisk to convert the partition to gpt, you can now create a new partition for your MBR, run sudo gdisk /dev/sd, enter n
to create a new partition, accept the proposed partition number, you should be able to select a first sector of 34, set the partition type of ef02:
Command (? for help): n
Partition number (2-128, default 2):
First sector (34-4294967262, default = 4294922240) or {+-}size{KMGTP}: 34
Last sector (34-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'
You can now write your partition table with w
. Run partprobe again and then install grub:
johnf@ubuntu:~$ sudo partprobe
johnf@ubuntu:~$ sudo grub-install /dev/sda
Installing for i386-pc platform.
Installation finished. No error reported.
You should now be able to reboot your machine without issue.
gdisk -l /dev/sdX
(substitutesdX
with your HDD) so we can tell more.