Skip to content

mxgrub: Include microcode updates in initramfs #11

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 41 additions & 0 deletions mxgrub/create_initramfs
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/sh

set -x

if [ -z "$1" ]; then
echo "You need to supply an initrd file name"
exit 1
fi

# Prepare microcode updates for AMD and Intel processors
DSTDIR=kernel/x86/microcode
INITRDNAME="$1"
INITRDPATH=/boot/grub/"$INITRDNAME".igz
INITRDDIR="$TMPDIR/$INITRDNAME"
mkdir -p "$INITRDDIR"
cd "$INITRDDIR"
mkdir -p "$DSTDIR"

if [ -d /lib/firmware/amd-ucode ]; then
cat /lib/firmware/amd-ucode/microcode_amd*.bin > "$DSTDIR"/AuthenticAMD.bin
fi

if [ -d /lib/firmware/intel-ucode ]; then
cat /lib/firmware/intel-ucode/* > "$DSTDIR"/GenuineIntel.bin
fi

ls -ltr "$TMPDIR"
find . | cpio -o -H newc > "$TMPDIR"/ucode.cpio
ls -ltr "$TMPDIR"

cd ..

# Clean up
rm -rf "$INITRDDIR"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A little bug in the lines above above or called without TMPDIR and the argument "/" or "." and the system is dead. I don't like rm -rf $SOMETHING.


cd /project/admin/initramfs
find .|cpio -H newc -o | gzip > "$TMPDIR/$INITRDNAME.igz"

#
cat "$TMPDIR"/ucode.cpio "$TMPDIR/$INITRDNAME.igz" > /boot/grub/"$INITRDNAME.igz"
rm "$TMPDIR"/ucode.cpio "$TMPDIR"/"$INITRDNAME.igz"
2 changes: 1 addition & 1 deletion mxgrub/mxgrub
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ sub cmd_update {
}

sub cmd_initramfs {
sys('bash','-c','cd /project/admin/initramfs;find .|cpio -H newc -o | gzip > /boot/grub/initramfs.igz');
sys('create_initramfs', 'initramfs');
}

our ($opt_list,$opt_update,$opt_initramfs,$opt_test);
Expand Down