Booting SystemRescueCD ISO from EFI on Fedora 28 Linux
Introduction
Yesterday I noticed that my Thinkpad X1 laptop had assigned too little diskspace to its OS partition. As it was running in a physical partition and not a logical one, it was time to move it to LVM. Unfortunately I had no USB sticks anymore.
As such I decided to move the whole system partition to LVM by using the SystemRescueCD (sysrcd) livecd booting directly from the disk itself.
It was quite a puzzle to get this done, therefore I decided to write it down for whoever might need to do the same thing.
Steps
- Confirm startup mode and disk layout
- Download sysrcd and copy to the right location
- Configure grub2 to read the sysrcd iso
- Update grub2
- Update EFI/BIOS boot settings
- Boot into sysrcd
Checking startup mode and disk layout
As its possible to run modern systems in EFI and BIOS mode and this tutorial is mode specifically for systems in EFI mode with GPT disk layout check these before you continue.
Check EFI or BIOS
To check if you are running in EFI, you can use the following commands
# if this folder exists you're running in EFI mode
$ ls /sys/firmware/efi/config_table
efivars esrt fw_platform_size fw_vendor runtime runtime-map systab
# this command will show output when running in EFI mode (not installed by default)
$ efibootmgr
BootCurrent: 0012
Timeout: 0 seconds
BootOrder: 0012,0013,0000,0001,0002,0003,000C,0007,0008,0009,000A,000B,000D
Boot0000 Setup
Boot0001 Boot Menu
Boot0002 Diagnostic Splash Screen
Boot0003 Lenovo Diagnostics
---
Boot0012* Fedora
Boot0013* Windows Boot Manager
Check disk layout
EFI systems support the classical disk layout (MBR or master boot record layout), but also a modern one which is called the GPT or GUID Partition Table layout. There are quite some differences between both, one of them being that MBR only supports 4 primary partitions with sizes up to 2 TB, GPT can go up to at least 128 and up to 1 ZB partition size (256 TB on Windows). As GRUB2 addresses these layouts differently it’s important to ensure you’re using GPT before we continue (if you’re not using GPT, just use the normal instructions described on the Ubuntu GRUB2 Example pages.
$ gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.3
Partition table scan:
MBR: protective
BSD: not present
APM: not present
GPT: present
Found valid GPT with protective MBR; using GPT.
Output of gdisk when ran against a GPT formatted disk.
Download sysrcd and copy to the right location
The first step is to download the SystemRescueCD from the website here: Download. For GRUB2 to be able to read the ISO file, it needs to be placed on the same partition as the /boot partition. In my case this is the system partition itself. For convenience I follow the instructions described on the SystemRescueCD documentation page and place the ISO in:
/boot/sysrcd/systemrescuecd-x86-x.y.z.iso
Now let’s continue to the next step and configure GRUB2
Configuring GRUB2
Before making changes to GRUB2, we need to dive a bit into how GRUB2 is actually setup in Fedora systems.
The GRUB2 system can be quite daunting and complex, but for this tutorial you only need to know the following commands and locations:
# write a new Grub2 EFI configuration for fedora on EFI
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
# location of default grub configuration settings
/etc/default/grub
# location of grub2 configurable OSes
/etc/grub.d/
# final location of compiled grub2 configuration (!do not edit this file directly!)
/boot/efi/EFI/fedora/grub.cfg
Now let’s create our new GRUB2 configuration, by creating a new grub configuration in
/etc/grub.d/20_sysrcd
#!/bin/sh
exec tail -n +3 $0
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry 'SystemRescueCD (64-bit) ' {
set root='hd0,gpt6'
set isofile="/boot/sysrcd/systemrescuecd-x86-5.2.2.iso"
loopback loop (hd0,gpt6)$isofile
linuxefi (loop)/isolinux/rescue64 setkmap=us isoloop=$isofile docache
initrdefi (loop)/isolinux/initram.igz
}
After writing the file, don’t forget to make it executable
chmod +x /etc/grub.d/20_sysrcd
Update EFI/BIOS boot settings
Now run the update grub command for Fedora on EFI
grub2-mkconfig -o /boot/efi/EFI/fedora/grub.cfg
This command writes a new configuration to /boot/efi/EFI/fedora/grub.cfg, a new section in this file should pop-up now:
### BEGIN /etc/grub.d/20_sysrescd ###
# This file provides an easy way to add custom menu entries. Simply type the
# menu entries you want to add after this comment. Be careful not to change
# the 'exec tail' line above.
menuentry 'SystemRescueCD (64-bit) ' {
set root='hd0,gpt6'
set isofile="/boot/sysrcd/systemrescuecd-x86-5.2.2.iso"
loopback loop (hd0,gpt6)$isofile
linuxefi (loop)/isolinux/rescue64 setkmap=us isoloop=$isofile docache
initrdefi (loop)/isolinux/initram.igz
}
### END /etc/grub.d/20_sysrescd ###
After restarting the system you should now be able to select “System Rescue CD” as a boot option, this will only work when you have disabled “secure boot” in your BIOS!