grub rescue

It could happen that your PC, after some operations (i.g. with gdisk) doesn’t start booting and you are therefore in grub rescue prompt. A very unpleasant situation.

The steps to follow are:

  1. see what are the partitions, with the command ls
    • you should see something like: (hd0)(hd0,msdos1)(hd0,msdos2)(hd1)(hd1,gpt1)
  2. understand what is the right partition to boot (i.g. hd0,gpt2):
    • you can list a single partition to see what it contains, with the command ls (hd0,gpt2). You should be able to see if a partition is the right one.
  3. give the command set prefix=(hd0,gpt2)/boot/grub
  4. give the command set root=(hd0,gpt2)/ root=/dev/sda2 (if the right partition is hd0,gpt2 the name is /dev/sda2, if it was hd1,gpt3 it would be /dev/sdb3)
  5. give the command insmod normal
  6. give the command: normal (or boot)

In this way the system should start with the expected partition.

boot useful tips

  1. It is not necessary to start booting with EFI if you have GPT partitions (you could choose to have legacy boot with GPT partitions).
  2. It is not necessary that EFI partition be at the start of a disk: it could be in every place, provided that it has a) boot (esp) flags, and b) at least 110mb of space.

customize grub in KDE Neon

0) Avoid Grub customizer: absolutely useless.

1) You can modify /etc/default/grub uncommenting GRUB_THEME=”/boot/grub/themes/breeze/theme.txt”

2) Then you can modify /boot/grub/themes/breeze/theme.txt: for example you can

  • add a background: adding, in # General settings, a line such as “desktop-image: “your-image-in-the-same-folder.png” (obviously you have to put, as root, that image into the folder);
  • reducing the height for menu items, in “+ boot_menu”: “item_height = 15” (not: 33)

3) do “sudo update-grub”

fine tuning

a) you can change the screen resolution (in /etc/default/grub);

  • give this command “xrandr” in order to know the supported resolutions 
  • then uncomment/modify GRUB_GFXMODE=”your desired resolution”

b) you can create your own pf2 font file, with grub-mkfont:
for example “sudo grub-mkfont –output=/boot/grub/fonts/DejaVuSans-10.pf2  –size=10 /usr/share/fonts/truetype/dejavu/DejaVuSans.ttf”

c) per installare nell’mbr
sudo grub-install /dev/sda