rancher / elemental-toolkit

:snowflake: The toolkit to build, ship and maintain cloud-init driven Linux derivatives based on container images
https://rancher.github.io/elemental-toolkit/docs/
Apache License 2.0
289 stars 49 forks source link

booting live iso to ram #1558

Open j-landru opened 2 years ago

j-landru commented 2 years ago

Is your feature request related to a problem? Please describe.

As stated in https://github.com/rancher/elemental-toolkit/issues/1271, I plan to use immutable elemental-toolkit derivative booting from a single live iso, with no install, for each cluster node. This card to document "to ram" live booting; also called toram on some distributions as well as docache under Gentoo:

Cons : ram space consumption on each node to store squashfs rootfs, so only usable for small sized iso file (about half GiB in my case for an alpine based elemental-toolkit derivative);

Pro :

Describe alternatives you've considered

As elemental build-iso initramfs is dracut based set rd.live.ram to 1 in grub.cfg kernel entry

Here my personalized grub.cfg overlayed on iso file using overlay-iso flag of elemental-build-iso tool.

search --no-floppy --file --set=root /boot/kernel.xz
set default=0
set timeout=10
set timeout_style=menu
set linux=linux
set initrd=initrd
if [ "${grub_cpu}" = "x86_64" -o "${grub_cpu}" = "i386" -o "${grub_cpu}" = "arm64" ];then
    if [ "${grub_platform}" = "efi" ]; then
        if [ "${grub_cpu}" != "arm64" ]; then
            set linux=linuxefi
            set initrd=initrdefi
        fi
    fi
fi
if [ "${grub_platform}" = "efi" ]; then
    echo "Please press 't' to show the boot menu on this console"
fi
set font=($root)/boot/${grub_cpu}/loader/grub2/fonts/unicode.pf2
if [ -f ${font} ];then
    loadfont ${font}
fi
menuentry "abcd4cirrus-os" --class os --unrestricted {
    echo Loading kernel...
    $linux ($root)/boot/kernel.xz cdroot root=live:CDLABEL=COS_LIVE rd.live.dir=/ rd.live.squashimg=rootfs.squashfs rd.live.ram=1 console=tty1 console=ttyS0
    echo Loading initrd...
    $initrd ($root)/boot/rootfs.xz
}

if [ "${grub_platform}" = "efi" ]; then
    hiddenentry "Text mode" --hotkey "t" {
        set textmode=true
        terminal_output console
    }
fi
frelon commented 1 year ago

Hi @j-landru, sorry for the delay on this.

I put up this issue to track in the elemental-cli https://github.com/rancher/elemental-toolkit/issues/1764 that should make this live-booting possible.