Boot Manjaro ISO from Grub2 loopback

grub

#1

First of all, thanks to Manjaro’s development team for a great distribution.

I’m developing a program to support booting Manjaro from USB and HDD. This software is AIO Boot. I also use Grub2 as bootloader.

Manjaro 17 also uses Grub2, I noticed there is a problem here that its loopback feature does not work.

We can not use this feature because the fromiso parameter does not work. Manjaro is based on Arch Linux, I think we need to use the img_dev and img_loop parameters. img_dev is the partition containing the ISO file. img_loop is the ISO file path.

Line 514 of the /boot/grub/grub.cfg file is as follows:
auto="${auto} fromiso=${iso_path}"

I think we should edit it, for example:
auto="${auto} img_dev=/dev/disk/by-uuid/${rootuuid} img_loop=${iso_path}"
rootuuid is the value exported from the previous Grub2 configuration file.

I have tried to not edit any of the files and the following code works. But if possible, I suggest we change the line 514 of the grub.cfg file as above.

set iso_path="/manjaro-xfce-17.0.5-stable-x86_64.iso"
set cfg_path="/boot/grub/loopback.cfg"
export iso_path
set timeout=0
menuentry "Manjaro" --hotkey=1 {
	loopback loop ${iso_path}
	set root=loop
	source /boot/grub/variable.cfg
    loaded=true
	export loaded
	set auto="img_dev=/dev/disk/by-uuid/${rootuuid} img_loop=${iso_path}"
	export auto

    if keystatus --shift; then
        disable_gfxterm=true
    fi

    if [ "${disable_gfxterm}" != "true" ]; then
        if loadfont /boot/grub/unicode.pf2 ; then
            if [ -z "$gfxmode" ] ; then
                gfxmode=1280x1024,1024x768,800x600
                gfxpayload=keep
            fi
            if keystatus --ctrl; then
                gfxok=""
                pager=0
                while [ -z "$gfxok" ]; do
                    echo "gfxmode=$gfxmode"
                    echo "Input new mode or Enter to confirm"
                    prompt
                    read gfxmodein
                    if [ -n "$gfxmodein" ]; then
                        gfxmode="$gfxmodein"
                        echo ""
                    else
                        gfxok="true"
                    fi
                done
            fi
            insmod all_video
            insmod gfxterm
            if terminal_output --append gfxterm; then
                terminal_output --remove console
            else
                disable_gfxterm=true
            fi
        else
            disable_gfxterm=true
        fi
    fi

    if [ "${disable_gfxterm}" != "true"  -a -f "${grub_theme}" ]; then
        insmod gfxmenu
        themedir=""
        regexp -s themedir '^(.*)/.*$' "${grub_theme}"
        for themefont in $themedir/*.pf2 $themedir/f/*.pf2; do
            if [ -f "${themefont}" ]; then
                loadfont "${themefont}"
            fi
        done
        for imagetype in jpg jpeg png tga; do
            for themeimage in ${themedir}/*.${imagetype}; do
                if [ -f "${themeimage}" ]; then
                    if [ "${imagetype}" = "jpg" ]; then
                        insmod jpeg
                    else
                        insmod $imagetype
                    fi
                fi
            done
        done
        theme=${grub_theme}
        export theme
    fi

    menu_color_normal=cyan/blue
    menu_color_highlight=white/blue
	
	configfile $cfg_path
	loopback -d loop
}

Thanks!


#2

This may help.
Careful that you note which versions of iso (17.0.1 or 17.0.5) so you can use the appropriate parameters.

ps: I never liked “/dev/disk/by-uuid/”; why can’t we use plain “UUID=xxxxxxxxxxxxxxxxxx”.
Perhaps you can help me understand why it needs to be so.
I am under the impression that Red Hat/gnome developers favour it and Linux Foundation is …
‘amenable’ to them. Hope you can help me dispel that notion or confirm its truth. I can handle it.


#3

Manjaro supports loopback, which means we will use Manjaro’s configuration file instead of having to write the menus. Includes Manjaro’s theme, menus, and parameters.

Manjaro has menus to change language, keyboard layout and time zone and driver (free or non-free).
Of course, we will use the appropriate parameters for each ISO file.

But in general, I want to use Manjaro’s configuration file instead of manually writing.

https://i.imgur.com/JebwkDj.jpg


#4

Maybe you could open a pull request in the appropriate git repo? The change seems to make sense to me.


#5

Hi,

I created a new pull request as requested.


#6

It seems it got merged. Yey!


#7

Manjaro 17.0.6 has support for booting from ISO files using Manjaro’s Grub2 menu in the ISO file.

menuentry "Manjaro XFCE 17.0.6 64-bit" {
	iso_path="/manjaro-xfce-17.0.6-stable-x86_64.iso"
	export iso_path
	search --set=root --file $iso_path
	probe -u -s rootuuid $root
	export rootuuid
	loopback loop $iso_path
	root=(loop)
	configfile /boot/grub/loopback.cfg
	loopback --delete loop
}

#8

@nguyentu

Nice. Good work.

Can you please explain what this last command do.

loopback --delete loop

It seems to work without it as well. Thanks.