сряда, 6 май 2020 г.

Slackware from BIOS to EFI

All this is needed if you have installation in BIOS boot mode and want to convert it to UEFI boot.

Backup - /boot directory
Get bootable Media for your distribution
- if your BIOS can add UEFI boot options from inside BIOS - use USB to BOOT in uEFI ( point 1. ) can be skipped.


Only for beginners:
Never Never delete you /root or /var or /home or /usr ... partitions to get space :) if you don't have BACKUP
root is /
root is "/dev/sdY4 on / type ext4 (rw)" or close to this
you can check where is it with command: mount
 
1. use USB to BOOT in uEFI mode
-without this EFI functionality is not working and you can't install UEFI boot menu for Slackware from HDD

a. prepare USB

fdisk /dev/sdX
- make 512mb FAT 32 partition - and 50mb will be enough.

mkfs.vfat -F 32 /dev/sdX1

mkdir /boot/efi
mount /dev/sdX1 -t vfat /boot/efi

b. install uEFI
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub --boot-directory=/boot/efi  --recheck --removable /dev/sdX

this mean USB will look:
\EFI\grub\grubx64.efi
\grub\grub.cfg
\grub\x86_64-efi
\grub\fonts
\grub\locale
...
there is many grub installations . And they have different files in them.
 --boot-directory=/boot/efi - option will install grub modules on USB !

EFI is in USB root !!!

c. You can prepare HDD/SSD before reboot - but you will loose bootable disk if you is not expirienced enough and need to boot from DVD or USB installation media or LIVE media.


2. Reboot and boot from USB !!!! In UEFI mode !!!

- some times BIOS need to add efi boot loader - \EFI\grub\grubx64.efi - for security reasons
- some times efi executable need to be in \EFI\BOOT\bootx64.efi format!
- grub will generate strange config or find it somehow! :)
Just boot in your Linux with you root.



3. prepare HDD/SSD

- if place is not enough or its taken delete swap and get space from him this can be done on running system without a problem for linux.
- if swap is next to boot partitions that must be in the beginning of the disk

swapoff -a - disable swap and etc .... if you are experienced user you know what to do.
if you do this - refresh partitions after creation ( hdparm -z /dev/sdY ) - before format fs - because linux will use old partition parameters other ways. And you can't reboot in this moment.

- try to install grub in bios mode again just to be sure you can boot from hdd/ssd
grub-install /dev/sdY - must be enough 

- If you see that fs not take all space in new partitions prepare USB and reboot.

- Then reformat /boot partition and recreate swap space.
( below is howto )


gdisk /dev/sdY - need to be GPT: present ( MBR: protective - only simulate MBR for compatabilitty )

- make 1st partition this is only need for old BIOS boot if any need . Because installation of BIOS boot can break next partition. so 50mb is just a precautions. Must be in the beginning of disk first 50mb .
50mb - EF02  BIOS boot partition

- make 2 part - there is grub installation and UEFI loaders
500mb - to 1gb - EF00  EFI System

mkfs.vfat -F 32 /dev/sdY? - ? is number of boot EFI partition usually 2

grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub --recheck --debug

- how boot partition look \EFI and \grub is in root of partition!!! partition is fat 32 formated
\EFI\grub\grubx64.efi
\grub\x86_64-efi
\grub\grub.cfg
...


c. this command must work only if you boot in uEFI mode and will add boot from hdd/ssd in Uefi BIOS:

modprobe efivars
efibootmgr -c -g -d /dev/sdY -p ? -w -L "Linux" -l '\EFI\grub\grubx64.efi'

- replace Y with boot disk
- ? boot partition
-  \EFI\grub\grubx64.efi some times it's Linux or BOOT not grub and efi executable some times is bootx64.efi or something other check and fix!

















Няма коментари: