first some praise: the maintainers of grub did their best they could to bring about a great piece of software, no doubt about that.

the question is: could less be more?

when Greg Kroah-Hartman (can’t find the source) suggested to get rid of the bootloader all together – he was consistent with the UNIX philosophy of K.I.S.S.

“keep it simple” “sit together every week and think: what can we through out?” X-D

everybody else probably thought: “what? he want’s to get rid of the bootloader? is he crazy?” X-D

no he was absolutely right.

mass confusion broke out, when during an “apt update; apt upgrade;” grub2 suddenly reported “the disk grub was installed on is no longer present”

which is obviously WRONG, nothing has changed, just an faulty upgrade, once more.

so grub2 says: install it to all disks and partitions! X-D

probably /dev/sda is usually the right choice

and Gregg is right: nobody ever should have to worry about it. 334,461 views for Nixie Pixel 🙂

background info: about BIOS and BootLoaders: Boot and Loathing Las BIOS

“BIOS is not smart enough to ask you about partitions, in fact, it knows nothing about partitions.

From the BIOS point of view, your disk is just a sequence of 512-byte sectors.

When BIOS is ready to pass the control to the bootloader, it just reads the first 512 bytes from the disk and just blindly passes the control to whatever program is located at the predefined position in that data.

It is the job of that program (MBR bootloader) to load the OS (this usually involves loading a more complex bootloader program from some other location on the disk)… bootloader, stored in MBR, which is aware about partitions” (src: askubuntu.com)

To find the bootable partition the following checks must occur:
  1. Search for an active partition (where the partition status is 0x80 or “Bootable”)
  2. Checks that no other partitions are marked as bootable
  3. If partition is the only bootable partition, then the boot code will read the partition’s Volume Boot Record (first sector, 512 bytes, of the partition) and transfer CPU execution to that memory address.
  4. The VBR is checked for the proper end signature (0xAA55). (src)

grub install man page:

grub-install.man.txt

hostnamectl; # tested on
  Operating System: Debian GNU/Linux 10 (buster)
  Kernel: Linux 4.19.0-8-amd64
  Architecture: x86-64

# what grub versions are installed on the system?
# (this in itself, is confusing, why is there more than one? X-D)
dpkg -l|grep grub
ii  grub-common                           2.02+dfsg1-20                                amd64        GRand Unified Bootloader (common files)
ii  grub-pc                               2.02+dfsg1-20                                amd64        GRand Unified Bootloader, version 2 (PC/BIOS version)
ii  grub-pc-bin                           2.02+dfsg1-20                                amd64        GRand Unified Bootloader, version 2 (PC/BIOS modules)
ii  grub2-common                          2.02+dfsg1-20                                amd64        GRand Unified Bootloader (common files for version 2)

Package: grub-pc-bin (2.02+dfsg1-20+deb10u2)

GRand Unified Bootloader, version 2 (PC/BIOS modules)

GRUB is a portable, powerful bootloader. This version of GRUB is based on a cleaner design than its predecessors, and provides the following new features:

 - Scripting in grub.cfg using BASH-like syntax.
 - Support for modern partition maps such as GPT.
 - Modular generation of grub.cfg via update-grub.  Packages providing GRUB
   add-ons can plug in their own script rules and trigger updates by invoking
   update-grub.
 - VESA-based graphical mode with background image support and complete 24-bit
   color set.
 - Support for extended charsets.  Users can write UTF-8 text to their menu
   entries.

This package contains GRUB modules that have been built for use with the traditional PC/BIOS architecture.

It can be installed in parallel with other flavours, but will not automatically install GRUB as the active boot loader nor automatically update grub.cfg on upgrade unless grub-pc is also installed.

(src)

# where is grub installed?
debconf-show grub-pc
* grub2/linux_cmdline_default: quiet
* grub2/linux_cmdline:
  grub-pc/postrm_purge_boot_grub: false
  grub-pc/kopt_extracted: false
* grub-pc/install_devices: /dev/disk/by-id/ata-Samsung_SSD_860_EVO_500GB_S4XBNF1M920720Y
  grub2/kfreebsd_cmdline_default: quiet
  grub-pc/install_devices_disks_changed:
  grub2/force_efi_extra_removable: false
  grub-pc/mixed_legacy_and_grub2: true
  grub2/kfreebsd_cmdline:
  grub2/update_nvram: true
  grub-pc/install_devices_empty: false
  grub-pc/partition_description:
  grub-pc/timeout: 5
  grub-pc/install_devices_failed_upgrade: true
  grub-pc/hidden_timeout: false
  grub-pc/chainload_from_menu.lst: true
  grub-pc/disk_description:
  grub-pc/install_devices_failed: false

# what partitions are bootable?
# are marked with *
fdisk -l

Disk /dev/sda: 465.8 GiB, 500107862016 bytes, 976773168 sectors
Disk model: Samsung SSD 860 
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x55e2bf00

Device     Boot  Start       End   Sectors   Size Id Type
/dev/sda1  *      2048    499711    497664   243M 83 Linux

# in this case it is a ext2 formated boot partition
# containing those files
ls -lah /boot
total 93M
drwxr-xr-x  4 root root 1.0K 2020-08-08 .
drwxr-xr-x 22 root root 4.0K 2020-08-07 ..
-rw-r--r--  1 root root 202K 2019-11-11 config-4.19.0-6-amd64
-rw-r--r--  1 root root 202K 2020-01-26 config-4.19.0-8-amd64
drwxr-xr-x  5 root root 1.0K 2020-08-08 grub
-rw-r--r--  1 root root  38M 2020-02-04 initrd.img-4.19.0-6-amd64
-rw-r--r--  1 root root  39M 2020-08-08 initrd.img-4.19.0-8-amd64
drwx------  2 root root  12K 2020-02-04 lost+found
-rw-r--r--  1 root root 3.3M 2019-11-11 System.map-4.19.0-6-amd64
-rw-r--r--  1 root root 3.3M 2020-01-26 System.map-4.19.0-8-amd64
-rw-r--r--  1 root root 5.1M 2019-11-11 vmlinuz-4.19.0-6-amd64
-rw-r--r--  1 root root 5.1M 2020-01-26 vmlinuz-4.19.0-8-amd64

lsblk -o "NAME,MAJ:MIN,RM,SIZE,RO,FSTYPE,MOUNTPOINT,UUID"
NAME                   MAJ:MIN RM   SIZE RO FSTYPE      MOUNTPOINT               UUID
sda                      8:0    0 465.8G  0                                      
├─sda1                   8:1    0   243M  0 ext2        /boot                    423f9db5-xxx
├─sda2                   8:2    0     1K  0                                      
└─sda5                   8:5    0 465.5G  0 crypto_LUKS                          694a3c8c-xxx
  └─sda5_crypt         253:0    0 465.5G  0 LVM2_member                          JURsVK-XzG0-xxx
    ├─giada--vg-root   253:1    0    28G  0 ext4        /                        73d90e72-9a4f-xxx
    ├─giada--vg-swap_1 253:2    0   7.9G  0 swap        [SWAP]                   0c15e2b2-4ffd-xxx
    └─giada--vg-home   253:3    0 429.6G  0 ext4        /home                    26d6d09a-7dca-xxx

ll /boot/grub/
total 2.4M
drwxr-xr-x 5 root root 1.0K 2020-08-09 .
drwxr-xr-x 4 root root 1.0K 2020-08-08 ..
drwxr-xr-x 2 root root 1.0K 2020-02-04 fonts
-r--r--r-- 1 root root 8.0K 2020-08-08 grub.cfg
-rw-r--r-- 1 root root 1.0K 2020-02-04 grubenv
drwxr-xr-x 2 root root  10K 2020-02-04 i386-pc
drwxr-xr-x 2 root root 1.0K 2020-02-04 locale
-rw-r--r-- 1 root root 2.3M 2020-02-04 unicode.pf2

# grub2 main config file:
cat /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_TIMEOUT=1
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT=""
# if the user wants to disable ipv6
GRUB_CMDLINE_LINUX="ipv6.disable=1"

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
#GRUB_GFXMODE=640x480

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

# there are a massive amounts of grub commands
grub-bios-setup
grub-glue-efi
grub-menulst2cfg
grub-mkimage
grub-mkrelpath
grub-ntldr-img
grub-script-check
grub-editenv
grub-install
grub-mkconfig
grub-mklayout
grub-mkrescue
grub-probe
grub-set-default
grub-file
grub-kbdcomp
grub-mkdevicemap
grub-mknetdir
grub-mkstandalone
grub-reboot
grub-syslinux2cfg
grub-fstest
grub-macbless
grub-mkfont
grub-mkpasswd-pbkdf2
grub-mount
grub-render-label

reinstall grub

grub-install /dev/sda

what is one’s default boot entry?

to see the default entry that is being booted at startup run:

# apt/Debian/Ubuntu based
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/grub/grub.cfg 
0 : Debian GNU/Linux
# rpm/Fedora/Centos/Redhat based
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg

to regenerate grub:

# rpm/Fedora/Centos/Redhat based
grub2-mkconfig -o /boot/grub2/grub.cfg

links:

https://askubuntu.com/questions/1134349/permanently-solve-grub-was-previously-installed-to-a-disk-that-is-no-longer-pre

off topic:

it is really hard to find the rss feed of Hartmann’s blog (no updates since 2019, probably abandoned) http://www.kroah.com/log/

here it is: http://www.kroah.com/log/index.rss

another older blog?

http://www.kroah.com/log/diary/


				
									
admin