[SOLVED] boot the System Rescue .iso file (and not another .iso) on hard disk with a grub menu entry

Questions about Grub, UEFI,the liveCD and the installer
Forum rules
Before you post read how to get help. Topics in this forum are automatically closed 6 months after creation.
Locked
User avatar
spamhog
Level 3
Level 3
Posts: 145
Joined: Thu Dec 17, 2009 6:21 pm
Contact:

[SOLVED] boot the System Rescue .iso file (and not another .iso) on hard disk with a grub menu entry

Post by spamhog »

I can't claim I understood every single thing, but here you go.

Goal is to have
- System Rescue as a boot option
- started live
- from an .iso file on a hard disk, no need to keep an USB pendrive
- all loaded to RAM, no hard disk mounted
- with a keymap of choice.

It could be on any filesystem, I used a dedicated partition which could hold more than one live .iso image in the future.
The partition is on a separate HD with its own grub.
All this with legacy BIOS at the moment.

In my case
- 2 GB partition, labeled HDRESCUE
- ext4 filesystem also labeled HDRESCUE (made with Gparted on a 2nd drive)
- live boot image systemrescue-9.05-amd64.iso from https://www.system-rescue.org/
- started from instructions here: https://www.system-rescue.org/manual/In ... _the_disk/

I prepared a file called 25_system-rescue

Code: Select all

#!/bin/sh
exec tail -n +3 $0

menuentry "System-Rescue live systemrescue.iso fs label=HDRESCUE" {
    load_video
    insmod gzio
    insmod part_gpt
    insmod part_msdos
    search --no-floppy --label HDRESCUE --set=root
    loopback loop /systemrescue.iso
    echo   'Loading kernel ...'
    linux  (loop)/sysresccd/boot/x86_64/vmlinuz img_label=HDRESCUE img_loop=/systemrescue.iso archisobasedir=sysresccd copytoram setkmap=de_CH-latin1
    echo   'Loading initramfs ...'
    initrd (loop)/sysresccd/boot/x86_64/sysresccd.img
}
Once the file was ready I put it in /etc/grub.d/ made it executable with chmod +x and ran update-grub.
(I also installed grub in the other disk with grub-install /dev/sdb.)

I think this doesn't hardwire the enty into the menu, I suspect it's searched and added at boot time. Frankly not even sure update-grub is necessary. (Someone please confirm).

AFAIK, both --label HDRESCUE and img_label=HDRESCUE refer to the partition label, once to tell grub and once to tell the kernel.

The loopback loop /systemrescue.iso line tells grub to look into a live image file.
This image is renamed from systemrescue-9.05-amd64.iso to systemrescue.iso so upgrading System Rescue will just require copying a new image but leaving the file 25_system-rescue unaltered.

Both (loop)/sysresccd/boot/x86_64/vmlinuz and (loop)/sysresccd/boot/x86_64/sysresccd.img are System Rescue specific. The distro used to be called System Rescue CD, and that is still reflected in the internals of the .iso image, which contains a folder named sysrescd and an inner image called sysrescd.img. These might work changed to their equivalents in another live distro.

AFAIK, the image is loaded as an initramfs.img image would be, but that isn't the whole story, an initramfs.img is normally all loaded in RAM, but this one (700MB) is all loaded only if copytoram is included. I don't know if this is distro specific.

It woud be nice to have the latest Mint image ready to boot as well.

Also, left to do: some kind of boot password, as this menu entry will make you root no questions asked.

Notice that this entry won't be blocked by the root file system encryption offered in Linux Mint, but once booted System Rescue will still be unable to bypass that encryption without the passphrase.

It should be possible to put a password directly on the hard disk or on UEFI, I don't know the details or how the two interact. For good measure on a BIOS machine I added a boot password because System Rescue boots as root.

I found a ton of howto's to do this but all are cookbook recipes like "this works for me", "this works like a charm" ( 8) quite exact :D ), "just do this" but I couldn't find a systematic treatment of
- the schizoid semantics of grub & linux kernel partition identification
- literally, "who one is talking to", grub or kernel, in each line or part of a line
- a truly general way of adding custom boot entries.

The GRUB (2) manual is like hieroglyphics. I can't wait for grub-2 to become deprecated.

OTOH kudos to those who configure grub in distros! 8)
Last edited by LockBot on Fri May 26, 2023 10:00 pm, edited 1 time in total.
Reason: Topic automatically closed 6 months after creation. New replies are no longer allowed.
Locked

Return to “Installation & Boot”