You are not logged in.

#1 2023-03-02 08:34:49

vecino
Member
Registered: 2022-12-10
Posts: 139

[SOLVED] grub2: boot arch iso from another disk

Hi, can someone please explain this behavior to me? What I want - I want to be able to boot via an ISO file in the system from another disk - in case of any problems / system rescue iso for quick fix.

If it is a standard Arch installation without sw raid mdadm, it works without problems. For example with this setting:

/etc/grub.d/40_custom

probe -u $root --set=rootuuid
set imgdevpath="/dev/disk/by-uuid/$rootuuid"

menuentry 'Arch Linux - ISO' {
        set isofile='/boot/archlinux-x86_64.iso'
        loopback loop $isofile
        linux (loop)/arch/boot/x86_64/vmlinuz-linux archisolabel=ARCH_202303 img_dev=$imgdevpath img_loop=$isofile
        initrd (loop)/arch/boot/x86_64/initramfs-linux.img
}

Now not working:

This is the setup where I use sw raid mdadm. I created a separate sda2 partition where I placed the arch iso file.

[root@myarch ~]# lsblk -f
NAME        FSTYPE            FSVER LABEL     UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                               
├─sda1      linux_raid_member 1.2   archiso:0 bd2b1780-37d2-6756-997e-2cf18ae4f937                
│ └─md0                                                                                           
│   └─md0p1 ext4              1.0             d2eaae20-15a9-4b92-a12d-2e8e66d278ad    3.9G    37% /
└─sda2      ext4              1.0             5d6d9404-165c-4e51-865e-5e35a6d5d9e7                
sdb                                                                                               
├─sdb1      linux_raid_member 1.2   archiso:0 bd2b1780-37d2-6756-997e-2cf18ae4f937                
│ └─md0                                                                                           
│   └─md0p1 ext4              1.0             d2eaae20-15a9-4b92-a12d-2e8e66d278ad    3.9G    37% /
└─sdb2                                            

I also edited the 40_custom file and added the new location of the iso file from where it should be used.

[root@myarch ~]# cat /etc/grub.d/40_custom 
#!/bin/sh
exec tail -n +3 $0
#
set imgdevpath="/dev/disk/by-uuid/5d6d9404-165c-4e51-865e-5e35a6d5d9e7"

menuentry 'Arch Linux - ISO' {
        set isofile='/boot/archlinux-x86_64.iso'
        loopback loop $isofile
        linux (loop)/arch/boot/x86_64/vmlinuz-linux archisolabel=ARCH_202302 img_dev=$imgdevpath img_loop=$isofile
        initrd (loop)/arch/boot/x86_64/initramfs-linux.img
}

With this setup, I have to have the file /boot/archlinux-x86_64.iso stored both in /boot/archlinux-x86_64.iso on /dev/md0 and on /dev/sda2 then it works.

Kernel command line: BOOT_IMAGE=(loop)/arch/boot/x86_64/vmlinuz-linux archisolabel=ARCH_202302 img_dev=/dev/disk/by-uuid/5d6d9404-165c-4e51-865e-5e35a6d5d9e7 img_loop=/boot/archlinux-x86_64.iso

If I have archlinux-x86_64.iso only on sda2:

error: file /boot/archlinux-x86_64.iso not found
error: no server is specified
error: you need to load the kernel first

And I can't boot only from /dev/md0 either because that field is not composed / not working at that moment.

I do not understand that.

Thanks

Last edited by vecino (2023-03-02 14:51:46)

Offline

#2 2023-03-02 11:54:19

nl6720
The Evil Wiki Admin
Registered: 2016-07-02
Posts: 667

Re: [SOLVED] grub2: boot arch iso from another disk

First off, you should remove "archisolabel". It won't do anything for this use case.

The errors come from GRUB, specifically these lines

vecino wrote:
        set isofile='/boot/archlinux-x86_64.iso'
        loopback loop $isofile

You're telling GRUB to set up a loop device for /boot/archlinux-x86_64.iso, but there is not /boot/archlinux-x86_64.iso in the current $root.
You need to insert

search --no-floppy --set=root --fs-uuid 5d6d9404-165c-4e51-865e-5e35a6d5d9e7

in the menu entry.

Starting with archlinux-2023.03.01-x86_64.iso, you can use img_dev=UUID=, so it can be simplified:

#!/bin/sh
exec tail -n +3 $0
#
set imgdevuuid='5d6d9404-165c-4e51-865e-5e35a6d5d9e7'

menuentry 'Arch Linux - ISO' {
        search --no-floppy --set=root --fs-uuid $imgdevuuid
        set isofile='/boot/archlinux-x86_64.iso'
        loopback loop $isofile
        linux (loop)/arch/boot/x86_64/vmlinuz-linux img_dev=UUID=$imgdevuuid img_loop=$isofile
        initrd (loop)/arch/boot/intel-ucode.img (loop)/arch/boot/amd-ucode.img (loop)/arch/boot/x86_64/initramfs-linux.img
}

Offline

#3 2023-03-02 14:43:01

vecino
Member
Registered: 2022-12-10
Posts: 139

Re: [SOLVED] grub2: boot arch iso from another disk

@nl6720: Thank you very much - it works perfectly for me now. I still have a lot to learn. smile

Offline

Board footer

Powered by FluxBB