Hi folks,

I had first written about my attempts here: https://lemmy.zip/post/24041939

I got to learn a lot thanks to some very helpful lemmyist (thank you @[email protected] !), but I ran into a wall and tried to persist alone for a while.

While my initial goal is still the same, I’m right now focusing on seeing whether I can rebuild an initramfs myself, excluding any customizations.

My setup is the following:

  • OS: Alpine Linux
  • Bootloader: Grub
  • OpenRC (no systemd)
  • Root in a LUKS encrypted partition
  • EFI firmware

When booting using the default initramfs:

mytestalpine:~# lsblk -o NAME,FSTYPE,FSVER,LABEL,UUID,FSAVAIL,FSUSE%,MOUNTPOINTS
NAME     FSTYPE      FSVER LABEL UUID                                 FSAVAIL FSUSE% MOUNTPOINTS
sda                                                                                  
├─sda1   vfat                    515E-70E4                             238.9M    20% /boot
├─sda2   swap                    667a53d2-dc82-4d2a-a121-63a75da51c24                [SWAP]
└─sda3   crypto_LUKS             73cada8c-5885-4334-b72b-b09b7f919d66                
  └─root ext4                    8613c4fe-dbc2-4a4e-9d41-3e7eaa8acf18      5G     3% /
sr0                                                                                  
mytestalpine:~# blkid
/dev/sda3: UUID="73cada8c-5885-4334-b72b-b09b7f919d66" TYPE="crypto_LUKS" PARTUUID="a900120b-4b78-4164-add8-f6a88eadb219"
/dev/sda1: UUID="515E-70E4" BLOCK_SIZE="512" TYPE="vfat" PARTUUID="83a340a7-ec05-4452-a775-178b5d3ea96e"
/dev/sda2: UUID="667a53d2-dc82-4d2a-a121-63a75da51c24" TYPE="swap" PARTUUID="cdddf0ec-5b8d-448f-a1c6-c9a97af06709"
/dev/mapper/root: UUID="8613c4fe-dbc2-4a4e-9d41-3e7eaa8acf18" BLOCK_SIZE="4096" TYPE="ext4"

Where I’m at:

  • I’ve created a custom dracut configuration file /etc/dracut.conf.d/base-initramfs.conf containing:
add_dracutmodules+=" crypt dm rootfs-block "
kernel_cmdline+=" rd.luks.uuid=luks-73cada8c-5885-4334-b72b-b09b7f919d66 "
  • I ran dracut --regenerate-all --force which yielded the following initramfs: -rwxr-xr-x 1 root root 10734241 Nov 27 22:56 /boot/initramfs-6.6.58-0-lts.img
  • I did not touch /etc/default/grub which contains:
GRUB_TIMEOUT=2
GRUB_DISABLE_SUBMENU=y
GRUB_DISABLE_RECOVERY=true
GRUB_CMDLINE_LINUX_DEFAULT="modules=sd-mod,usb-storage,ext4 cryptroot=UUID=73cada8c-5885-4334-b72b-b09b7f919d66 cryptdm=root rootfstype=ext4"
  • I entered my custom boot entry in /etc/grub.d/40_custom:
mytestalpine:~# cat /etc/grub.d/40_custom
#!/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 'Dracut entry' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-lts-advanced-8613c4fe-dbc2-4a4e-9d41-3e7eaa8acf18' {
	load_video
	insmod gzio
	insmod part_gpt
	insmod fat
	set root='hd0,gpt1'

	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1  515E-70E4
	else
	  search --no-floppy --fs-uuid --set=root 515E-70E4
	fi

	#search --no-floppy --fs-uuid --set=root 515E-70E4
	echo	'Loading Linux lts ...'
	linux	/vmlinuz-lts root=UUID=8613c4fe-dbc2-4a4e-9d41-3e7eaa8acf18 ro  modules=sd-mod,usb-storage,ext4 cryptroot=UUID=73cada8c-5885-4334-b72b-b09b7f919d66 cryptdm=root rootfstype=ext4 rd.shell rd.debug log_buf_len=1M 
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-6.6.58-0-lts.img
}

This was closely matched to the original boot entry.

  • I then ran grub-mkconfig -o /boot/grub/grub.cfg (at this point, not sure whether normal or not, I see mention of the original initramfs, but not mine:
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-lts
Found initrd image: /boot/initramfs-lts
Warning: os-prober will not be executed to detect other bootable partitions.
Systems on them will not be added to the GRUB boot configuration.
Check GRUB_DISABLE_OS_PROBER documentation entry.
Adding boot menu entry for UEFI Firmware Settings ...
done
  • When attempting to boot into my entry in grub, I get a blank screen which hangs indefinitely where the only text visible is:
Loading Linux lts ...
Loading initial ramdisk ...
_
EFI stub: Loaded initrd from LINUX_EFI_INITRD_MEDIA_GUID device path

I’ve tried looking up the message but nothing seems to be giving hints at how I can fix it.

Is there something visibly wrong with what I’m doing? I’ve removed the quiet parameter and added debug flags to the kernel parameters but I’m doing able to get more information from the failed boot… Thanks!

Below is my entire grub conf:

/boot/grub/grub.cfg
mytestalpine:~# cat /boot/grub/grub.cfg
#
# DO NOT EDIT THIS FILE
#
# It is automatically generated by grub-mkconfig using templates
# from /etc/grub.d and settings from /etc/default/grub
#

### BEGIN /etc/grub.d/00_header ###
if [ -s $prefix/grubenv ]; then
  load_env
fi
if [ "${next_entry}" ] ; then
   set default="${next_entry}"
   set next_entry=
   save_env next_entry
   set boot_once=true
else
   set default="0"
fi

if [ x"${feature_menuentry_id}" = xy ]; then
  menuentry_id_option="--id"
else
  menuentry_id_option=""
fi

export menuentry_id_option

if [ "${prev_saved_entry}" ]; then
  set saved_entry="${prev_saved_entry}"
  save_env saved_entry
  set prev_saved_entry=
  save_env prev_saved_entry
  set boot_once=true
fi

function savedefault {
  if [ -z "${boot_once}" ]; then
    saved_entry="${chosen}"
    save_env saved_entry
  fi
}

function load_video {
  if [ x$feature_all_video_module = xy ]; then
    insmod all_video
  else
    insmod efi_gop
    insmod efi_uga
    insmod ieee1275_fb
    insmod vbe
    insmod vga
    insmod video_bochs
    insmod video_cirrus
  fi
}

if loadfont unicode ; then
  set gfxmode=auto
  load_video
  insmod gfxterm
fi
terminal_output gfxterm
if [ x$feature_timeout_style = xy ] ; then
  set timeout_style=menu
  set timeout=2
# Fallback normal timeout code in case the timeout_style feature is
# unavailable.
else
  set timeout=2
fi
### END /etc/grub.d/00_header ###

### BEGIN /etc/grub.d/10_linux ###
menuentry 'Alpine Linux v3.20, with Linux lts' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-lts-advanced-8613c4fe-dbc2-4a4e-9d41-3e7eaa8acf18' {
	load_video
	insmod gzio
	insmod part_gpt
	insmod fat
	set root='hd0,gpt1'
	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1  515E-70E4
	else
	  search --no-floppy --fs-uuid --set=root 515E-70E4
	fi
	echo	'Loading Linux lts ...'
	linux	/vmlinuz-lts root=UUID=8613c4fe-dbc2-4a4e-9d41-3e7eaa8acf18 ro  modules=sd-mod,usb-storage,ext4 cryptroot=UUID=73cada8c-5885-4334-b72b-b09b7f919d66 cryptdm=root rootfstype=ext4
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-lts
}

### END /etc/grub.d/10_linux ###

### BEGIN /etc/grub.d/20_linux_xen ###
### END /etc/grub.d/20_linux_xen ###

### BEGIN /etc/grub.d/25_bli ###
if [ "$grub_platform" = "efi" ]; then
  insmod bli
fi
### END /etc/grub.d/25_bli ###

### BEGIN /etc/grub.d/30_os-prober ###
### END /etc/grub.d/30_os-prober ###

### BEGIN /etc/grub.d/30_uefi-firmware ###
if [ "$grub_platform" = "efi" ]; then
	menuentry 'UEFI Firmware Settings' $menuentry_id_option 'uefi-firmware' {
		fwsetup
	}
fi
### END /etc/grub.d/30_uefi-firmware ###

### BEGIN /etc/grub.d/40_custom ###
# 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 'Dracut entry' --class gnu-linux --class gnu --class os $menuentry_id_option 'gnulinux-lts-advanced-8613c4fe-dbc2-4a4e-9d41-3e7eaa8acf18' {
	load_video
	insmod gzio
	insmod part_gpt
	insmod fat
	set root='hd0,gpt1'

	if [ x$feature_platform_search_hint = xy ]; then
	  search --no-floppy --fs-uuid --set=root --hint-bios=hd0,gpt1 --hint-efi=hd0,gpt1 --hint-baremetal=ahci0,gpt1  515E-70E4
	else
	  search --no-floppy --fs-uuid --set=root 515E-70E4
	fi

	#search --no-floppy --fs-uuid --set=root 515E-70E4
	echo	'Loading Linux lts ...'
	linux	/vmlinuz-lts root=UUID=8613c4fe-dbc2-4a4e-9d41-3e7eaa8acf18 ro  modules=sd-mod,usb-storage,ext4 cryptroot=UUID=73cada8c-5885-4334-b72b-b09b7f919d66 cryptdm=root rootfstype=ext4 rd.shell rd.debug log_buf_len=1M 
	echo	'Loading initial ramdisk ...'
	initrd	/initramfs-6.6.58-0-lts.img
}
### END /etc/grub.d/40_custom ###

### BEGIN /etc/grub.d/41_custom ###
if [ -f  ${config_directory}/custom.cfg ]; then
  source ${config_directory}/custom.cfg
elif [ -z "${config_directory}" -a -f  $prefix/custom.cfg ]; then
  source $prefix/custom.cfg
fi
### END /etc/grub.d/41_custom ###

Edit: corrected tagged user & formatting

  • mvirts@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    17 days ago

    If it hangs after grub’s EFI loader I would check the EFI grub install… But I don’t know luks so no idea what to look for.

    • The HobbyistOP
      link
      fedilink
      arrow-up
      2
      ·
      edit-2
      17 days ago

      Thanks for the reply! Can you tell me more about what you mean with “check the efi grub install”?

      Edit: to be clear, I have a vanilla initramfs booting properly, which is the one automatically built. I’m just trying to replicate it myself.

      • mvirts@lemmy.world
        link
        fedilink
        arrow-up
        2
        ·
        17 days ago

        I was thinking grub may be unable to find the correct initrd for some reason, like missing grub modules. This doesn’t make sense since it can boot your vanilla image and doesn’t print an error when booting your image.