Booting Linux

https://www.happyassassin.net/posts/2014/01/25/uefi-boot-how-does-that-actually-work-then/

There are two main ways of booting (Linux) on a computer. The old way, where the BIOS of your computer blindly executes what can be found at the begining of your harddisk at specific adress. Many Linux installers would put a boot manager like grub or lilo there. And Windows would than replace it from time to time with its own boot code and you have to restore the boot manager.

Then there is the now, the EFI way. Where your BIOS expects that there will be a Fat formated partion at the beginning of the disk, mount it, read the files there and then boots something out of it. Different OS can put their code there and it is somehow much smarter. Do do not really need a boot manager, your BIOS will most likely provide one, but you can of course still have one, e.g. https://www.rodsbooks.com/refind/

Backup your Bootsector

if=/dev/hda of=/tmp/mbrbackupwithouttable.img bs=446 count=1
if=/dev/hda of=/tmp/mbrbackupwithtable.img    bs=512 count=1

Get into system if no longer boots

blkid
mount /dev/sdXX /mnt
mount /dev/sdXX /mnt/boot
mount /dev/sdXX /mnt/boot/efi
for i in dev dev/pts proc sys sys/firmware; do mount --bind /$i /mnt/$i; done
chroot /mnt

Refind

You should be in a system where /boot/efi/ is already mounted.

refind-install

There are 2 configuration files This contains how to boot your system, if missing will be created by refind-install /boot/refind_linux.conf

The second one can be used to manually define what to boot but usually it is just left as it is /boot/efi/EFI/refind/refind.conf

Update it from time to time with /boot/efi/EFI/refind/refind.conf-sample

Lilo

Boot from Floppy/CD, mount /dev/linuxrootpartition /mnt; chroot /mnt; lilo; exit; umount /mnt; reboot

Grub

  • Start the Grub shell
  • Find out where your Linux partition is (e.g. use find to search one of your files) and tell grub with the root command where it is.
grub> find /boot/grub/stage1
grub> root (hd0,3)
  • Write Grub into the masterbootsector or in one of your partitions
grub> setup (hd0)
grub> setup (hd0,3)

Kernel

Build Kernel (Traditionally)

nice --5 make dep clean bzImage modules bzlilo modules_install

Kernel Bootparameter

/usr/src/linux/Documentation/kernel-parameters.txt