SliTaz SliTaz Forum

You are not logged in.

#1 2020-05-04 17:38:08

dkuchay
Member
Registered: 2020-04-30
Posts: 59

EFI stub -> efi executable?

Hello,

Have a new laptop on its way and had a neat idea. Since Slitaz packs rootfs into initrd would a full efi executable be possible?

Recently I have installed gentoo linux on a guide from sakaki. This method is a full encrypted lvm in a luks container and it utilizes a fat32 usb key to stick the efi kernel to. This set up is ideal for dual boot as if one removes the usb key we boot straight to (presumably) windows or whatever the other OS is. With this config there is no bootloader. If linux is set to top level in efi boot order it will boot to linux whenever usb is inserted and it can be removed once kernel is loaded.

I have set up a few laptops this way. Google Sakaki’s EFI install guide if curious. There is a subsection for putting minix on the usb key as a backup os. My thought was how hard would it be to build all of Slitaz as an efi file? Would need built in kernel command line with all boot arguments in kernel and it requires rebuilding kernel to change boot commands. I see objtool being used to scrape all items in to kernel when doing this in gentoo. I’m on about day 6 on getting familiar with Slitaz and had this thought/idea. Not sure how possible it is?

Offline

#2 2020-05-05 06:39:52

bellard
Administrator
Registered: 2011-03-28
Posts: 657

Re: EFI stub -> efi executable?

Look at /efi/boot directory in the cd-rom image:

$ ls efi/boot/

bootia32.efi  linux.cmdline  rootfs1.gz  rootfs2.gz  rootfs3.gz  rootfs4.gz

$ cat efi/boot/linux.cmdline

rw root=0x100 autologin initrd=\EFI\BOOT\rootfs4.gz initrd=\EFI\BOOT\rootfs3.gz initrd=\EFI\BOOT\rootfs2.gz initrd=\EFI\BOOT\rootfs1.gz

This image should boot with efi on a cd-rom or a usb key / memory card.

FYI: you can find the same into the /boot/isolinux/efi.img vfat image for the embedded gpt partition (fdisk -l slitaz-rolling.iso).

cmdline patch: http://hg.slitaz.org/wok/file/36e9a3dcd5de/linux/stuff/linux-efi.u#l146

Offline

#3 2020-05-05 12:41:07

dkuchay
Member
Registered: 2020-04-30
Posts: 59

Re: EFI stub -> efi executable?

What I am asking is can the rootfs be packed in to the EFI executable with objtool? That way your whole operating system would look at just one file.  Slitaz-v5.efi    No iso. Would make for good recivery image within EFI and if there was a hook for openssl one may be able to get secure boot working too.

Offline

#4 2020-05-05 13:51:57

bellard
Administrator
Registered: 2011-03-28
Posts: 657

Re: EFI stub -> efi executable?

You can set CONFIG_INITRAMFS_SOURCE="/path/to/rootfs" in the .config file of linux source.

You will get a single BOOTIA32.EFI or BOOTX64.EFI

You may need to set CONFIG_CMLINE_BOOL=y and CONFIG_CMDLINE="rw autologin lang=..."

According to usr/Kconfig:

[c]config INITRAMFS_SOURCE
        string "Initramfs source file(s)"
        default ""
        help
          This can be either a single cpio archive with a .cpio suffix or a
          space-separated list of directories and files for building the
          initramfs image.  A cpio archive should contain a filesystem archive
          to be used as an initramfs image.  Directories should contain a
          filesystem layout to be included in the initramfs image.  Files
          should contain entries according to the format described by the
          "usr/gen_init_cpio" program in the kernel tree.

          When multiple directories and files are specified then the
          initramfs image will be the aggregate of all of them.

          See <file:Documentation/early-userspace/README> for more details.[/c]
According to arch/x86/Kconfig:

[c]config CMDLINE_BOOL
        bool "Built-in kernel command line"
        ---help---
          Allow for specifying boot arguments to the kernel at
          build time.  On some systems (e.g. embedded ones), it is
          necessary or convenient to provide some or all of the
          kernel boot arguments with the kernel itself (that is,
          to not rely on the boot loader to provide them.)

          To compile command line arguments into the kernel,
          set this option to 'Y', then fill in the
          the boot arguments in CONFIG_CMDLINE.

          Systems with fully functional boot loaders (i.e. non-embedded)
          should leave this option set to 'N'.

config CMDLINE
        string "Built-in kernel command string"
        depends on CMDLINE_BOOL
        default ""
        ---help---
          Enter arguments here that should be compiled into the kernel
          image and used at boot time.  If the boot loader provides a
          command line at boot time, it is appended to this string to
          form the full kernel command line, when the system boots.

          However, you can use the CONFIG_CMDLINE_OVERRIDE option to
          change this behavior.

          In most cases, the command line (whether built-in or provided
          by the boot loader) should specify the device for the root
          file system.[/c]

Offline

#5 2020-05-05 16:15:08

dkuchay
Member
Registered: 2020-04-30
Posts: 59

Re: EFI stub -> efi executable?

Fabulous! Thank you.

Offline

Registered users online in this topic: 0, guests: 1
[Bot] ClaudeBot

Board footer

Powered by FluxBB
Modified by Visman

[ Generated in 0.017 seconds, 7 queries executed - Memory usage: 1.54 MiB (Peak: 1.77 MiB) ]