Last active
November 6, 2024 18:09
-
-
Save mallardduck/9645ec7847e1743bef43dc0d456a9ac7 to your computer and use it in GitHub Desktop.
How to unpack and modify/customize the initrd (using zstd compression)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export LANG=C | |
TMP=`mktemp -d` | |
umask 022 | |
mkdir -p $TMP/earlycpio | |
mkdir $TMP/initramfs | |
umask 077 | |
cd $TMP/earlycpio | |
chmod 755 $TMP/earlycpio | |
cat /boot/initrd-5.14.21-150400.11-default | cpio -idmv | |
cd $TMP/initramfs | |
/usr/lib/dracut/skipcpio /boot/initrd-5.14.21-150400.11-default 2>/dev/null | unzstd -- |cpio -idvm | |
To repackage initrd: | |
cd $TMP/earlycpio | |
find . -print0| cpio -H newc --null -o > ../initrd.new | |
cd $TMP/initramfs | |
find . -print0| sort -z | cpio --null -H newc --quiet -o > ../initramfs.img | |
cd $TMP | |
cat initramfs.img |zstd >> initrd.new |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment