Skip to content

Commit

Permalink
mxgrub: Create microcode update images and pass them to GRUB
Browse files Browse the repository at this point in the history
The Linux kernel and the distributions prepend them to the possibly
compressed initrd image manually, but then you need a script like
`lsinitramfs` to view the content, if it’s compressed.

Using separate files uses possibly not well tested GRUB code paths, but
allows us to easily handle all the files.

[1]: https://docs.kernel.org/arch/x86/microcode.html
  • Loading branch information
pmenzel committed Aug 16, 2023
1 parent 20ed3ef commit 03518b7
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions mxgrub/mxgrub
Original file line number Diff line number Diff line change
Expand Up @@ -249,7 +249,7 @@ sub update_grub_cfg {

for my $label (@MARIUX) {
my $image=label_to_image($label);
$kernellist.="\tmenuentry \"$label\" --unrestricted { save_env chosen ; linux /boot/$image root=LABEL=root $KERNEL_PARAMETER ; initrd /boot/grub/initramfs.igz }\n";
$kernellist.="\tmenuentry \"$label\" --unrestricted { save_env chosen ; linux /boot/$image root=LABEL=root $KERNEL_PARAMETER ; initrd /boot/amd-ucode.img /boot/intel-ucode.img /boot/grub/initramfs.igz }\n";
}

my $GRUB_CFG_NEW=<<"EOF";
Expand All @@ -267,7 +267,7 @@ insmod all_video
if [ -e /etc/local/USB.usb ]; then
set default="mariuxUSB"
menuentry "mariuxUSB" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=rootusb rootdelay=5 $KERNEL_PARAMETER ; initrd /boot/grub/initramfs.igz }
menuentry "mariuxUSB" --unrestricted { save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=rootusb rootdelay=5 $KERNEL_PARAMETER ; initrd /boot/amd-ucode.img /boot/intel-ucode.img /boot/grub/initramfs.igz }
else
menuentry "$MARIUX_DEFAULT" --unrestricted { set chosen="$submenu>$MARIUX_DEFAULT" ; save_env chosen ; linux /boot/bzImage.x86_64 root=LABEL=root $KERNEL_PARAMETER ; initrd /boot/grub/initramfs.igz }
Expand Down Expand Up @@ -354,6 +354,8 @@ sub cmd_update {
}

sub cmd_initramfs {
sys('bash','-c','DSTDIR= "$TMPDIR/kernel/x86/microcode"; mkdir "$DSTDIR"; cd "$DSTDIR" ; cat /lib/firmware/amd-ucode/microcode_amd*.bin > $DSTDIR/AuthenticAMD.bin ; find . | cpio -o -H newc > /boot/amd-ucode.img ; rm -rf "$TMPDIR/kernel"');
sys('bash','-c','DSTDIR= "$TMPDIR/kernel/x86/microcode"; mkdir "$DSTDIR"; cd "$DSTDIR" ; cat /lib/firmware/intel-ucode/* > $DSTDIR/GenuineIntel.bin ; find . | cpio -o -H newc > /boot/intel-ucode.img ; rm -rf "$TMPDIR/kernel"');
sys('bash','-c','cd /project/admin/initramfs ; find . -name ".git*" -prune -or -print | cpio -H newc -o | gzip > /boot/grub/initramfs.igz');
}

Expand Down

0 comments on commit 03518b7

Please sign in to comment.