From Mageia wiki
Jump to: navigation, search


Drakconf multiflag.png
Other languages
English ;
Synopsis:
This page describes how to configure grub2 to boot Mageia from a Mageia Live ISO saved on disk. No Live Boot DVD or USB are needed.


See also


Assumptions and scope

The method described here depends on having:

  • Boot system set for Legacy/BIOS or UEFI.
  • Grub2 for booting. This is the default since Mageia 6.
  • A separate disk filesystem partition /mnt/live-boot.
  • A copy of Mageia Live ISO file in /mnt/live-boot.

Recommendation: trial first using Virtual Box!

Benefits

Firstly, no Live boot media is needed: not DVD nor USB.

Secondly, it is a method of booting a Live system limited only by disk speed and hardware.

Thirdly, post boot, the Live system can be used recover and save to external devices important documents and files that are unable to be accessed from a damaged and unbootable system and can also be used to repair an unbootable installed system, typically by "chroot"ing into the damaged system.

Note:
If the Live System in booted from hardware that has only 1 internal storage device, and even though this is a Live system, and the "Install onto Disk" icon is active, attempting to install will fail.

You will need to cancel the install.

Note:
If the Live System in booted from hardware that has 2 or more internal storage device, planning is required prior such that the Live installer is able to install or re-install the system, should it be required to do so. As this is a Live system, and the "Install onto Disk" icon is active, install or re-install is able to be completed with no special commands.

Overview

  1. Create a partition /mnt/live-boot for storing the live ISO files.
  2. Download and verify a Mageia Live ISO file.
  3. Open a root virtual terminal and edit /etc/grub.d/40_custom using a text editor: eg # kwrite /etc/grub.d/40_custom and save.
  4. Then update grub2: # update-grub2.
  5. Reboot and select your new grub boot option for "Live Boot".

Preparation

Step-1: Create local disk filesystem partition /mnt/live-boot

Use diskdrake to create a new btrfs partition mounted at /mnt/live-boot on your disk drive. Should the Live-booted system be required to reinstall a failed system due to it being damaged beyond repair, this partition must be on a different internal storage device than the main system, ie sdb1.

Ideally, /mnt/live-boot partition should be large enough for two full Live images which is about 10gb.

The reason of having capacity for two live images is that we require to use 1 Live.iso and also the extracted contents of same.

The label for this partition requires to be the name of the Live.iso (eg:Mageia-8-Live-Plasma-x86_64) and this is too many characters for an ext2/3/4 type partition filesystem, hence btrfs.

Label the partition NAME_OF_LIVE.iso to make it easier to find and reference, and it is a requirement of the Live boot method used.

Tip: if you make the live-boot a size like 10Gb (10240Mb) it will be easier to find if required during the re-install process when the list of partitions are shown.

For example:

I downloaded "Mageia-8-Live-Plasma-x86_64.iso" and so must label the partition "Mageia-8-Live-Plasma-x86_64" (for example, using the gparted or diskdrake programs).

Check if the partition label is truncated, i.e: "Mageia-8-Live-Pl". This is a clue that the partition filesystem type is incorrect.

[root@localhost ~]# lsblk -o NAME,LABEL /dev/sda
NAME    LABEL
sda     
├─sda1  Clonezilla
├─sda2  swap
├─sda3  M8_main_root
├─sda4  M8_main_home
~
├─sda19 
└─sda20 Mageia-8-Live-Plasma-x86_64

Note:
Be sure that btrfs (Journalised FS: btrfs) is set for the filesystem type for this partition.

Step-2: Download and verify a Mageia Live ISO file

See Installing Mageia from ISO images on disk using grub2 for an overview. The same steps are required for the Live.isos

Step-3: Preparation of the Live.iso

Copy the downloaded and verified Live.iso into /mnt/live-boot.

Extract the contents of the Live.iso such that the result is the following set of files.

Any archive manager is able to do this for you.


[Mageia-8-Live-Plasma-x86_64]$ ls
autorun.inf  boot.catalog  dosutils/  loopbacks/
boot/        DATE.txt      EFI/       Mageia-8-Live-Plasma-x86_64.iso

Note:
Be sure that the LABEL for this partition matches exactly the name of the Live.iso

Step-4: Add entry to grub2 configuration file for booting the Mageia Live ISO image

Lets look inside the /boot/grub2/grub.cfg of the Live to glean some clues as to what is required in this grub enty:


if [ -z $initialised ] ; then
    set grub2=/boot/grub2
    export grub2

    set kernel=no_choice
    export kernel

    search --no-floppy --set=overlay -l 'mgalive-persist'
    export overlay
    if [ ! -z $overlay ] ; then
        search --no-floppy --set=partition -f /memory/boot/vmlinuz --hint $overlay
        if [ x$partition == x$overlay ] ; then
            set kernel=latest
        fi
    fi

    if loadfont $grub2/fonts/unicode.pf2 ; then
        set gfxmode=1024x768,800x600,auto
        set gfxpayload=keep
        terminal_output gfxterm
    fi

    if [ $grub_platform == 'efi' ] ; then
        set theme=$grub2/themes/maggy/theme-efi.txt
    else
        set theme=$grub2/themes/maggy/theme.txt
    fi
    export theme
    loadfont $grub2/themes/maggy/MageiaLogoBold-16.pf2
    loadfont $grub2/themes/maggy/MageiaLogoBold-20.pf2
    loadfont $grub2/themes/maggy/MageiaLogoBold-28.pf2
    loadfont $grub2/themes/maggy/MageiaLogoRegular-20.pf2

    if [ $grub_platform == 'efi' ] ; then
        set linux=linuxefi
        set initrd=initrdefi
    else
        set linux=linux16
        set initrd=initrd16
    fi
    export linux
    export initrd

    set initialised=true
    export initialised
fi

set boot=/boot
if [ $kernel == 'latest' ] ; then
    set boot=($overlay)/memory/boot
fi

set default=0
set timeout=10

export lang
export lkbd

menuentry $"Boot Mageia Live" {
    $linux $boot/vmlinuz lang=$lang kbd=$kbd root=mgalive:LABEL=Mageia-8-Live-Plasma-x86_64 noiswmd audit=0 rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 vga=788 splash quiet noxconf xdriver=free
    $initrd $boot/initrd.img
}
menuentry $" + use non-free NVIDIA drivers (slower to boot)" {
    $linux $boot/vmlinuz lang=$lang kbd=$kbd root=mgalive:LABEL=Mageia-8-Live-Plasma-x86_64 noiswmd audit=0 rd.luks=0 rd.lvm=0 rd.md=0 rd.dm=0 vga=788 splash quiet nokmsboot xclone=1
    $initrd $boot/initrd.img
}

(review Installing Mageia from ISO images on disk using grub2)

modified entries for: linux($linux) and for initrd($initrd)

This is important: "root=mgalive:LABEL=Mageia-8-Live-Plasma-x86_64"


Lets open the /etc/grub.d/40_custom file to edit it:

In a root terminal: kwrite /etc/grub.d/40_custom


In Mageia 8, the default contains:

#!/usr/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.


Here is an example of: /etc/grub.d/40_custom{ where the ISO Live image is "Mageia-8-Live-Plasma-x86_64.iso" in partition /dev/sda20 mounted at /mnt/live-boot/ .

Take care to define the correct values for:

  1. set name=
  2. set isofile=
  3. loopback loop

In the example shown here for 64-bit, these are:

  1. set name=Mageia-8-Live-Plasma-x86_64
  2. set isofile="/$name.iso"
  3. loopback loop (hd0,20)$isofile

Explanation:

  1. "Mageia-8-Live-Plasma-x86_64" is the NAME of the Mageia Live image we downloaded (Mageia-8-Live-Plasma-x86_64.iso).
  2. The use of name facilitates the name of the iso, isofile, and root=mgalive:LABEL= entries where required and is the LABEL of the partition that contains the Live.iso and extracted files. This entry needs be correct, as it ties many elements together.
  3. 'hd0,20' means the first disk /dev/sda and the 20th partition. /dev/sda20 in this example (mounted as /mnt/live-boot/).


Note:
If the system recovery fails and a re-installation is done it is likely that any edit to /etc/grub.d/40_custom will be lost.

For this reason, create ${HOME}/etc_grub.d_40_custom on the assumption that /home/ will be preserved during the install then append ${HOME}/etc_grub.d_40_custom to /etc/grub.d/40_custom.

Do *not* overwrite any existing /etc/grub.d/40_custom


As this hardware only requires the free drivers we can ignore the second menuentry info regarding Nvidia.

Your requirements my differ.

"rd.live.image" is returned from many web searches regarding booting live images using Grub2.

So, the final /etc/grub.d/40_custom in this example looks like:


#!/usr/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 "Live Boot" {

set name=Mageia-8-Live-Plasma-x86_64
set isofile="/$name.iso"
loopback loop (hd0,20)$isofile
linux (loop)/boot/vmlinuz root=mgalive:LABEL=$name rd.live.image noiswmd vga=788 splash quiet noxconf
initrd (loop)/boot/initrd.img

}

To add the above entry to grub, we need to save our edit and exit kwrite.


Then, in root terminal: update-grub2.

Upon reboot, our new grub entry should be displayed as a boot option.

Review your ${HOME}/etc_grub.d_40_custom and verify that it is correct. In particular check the "name" entry is typed correctly, "loopback" line has the correct partition designation (hdX,X) and is not missing "/$isofile".

If the boot fails, edit the grub entry and delete "splash quiet noconf". this will give information as to why the boot failed. Be sure to check the set name entry is the correct name of of the Live.iso.