Skip to content

Instantly share code, notes, and snippets.

@schorschii
Created January 2, 2026 11:48
Show Gist options
  • Select an option

  • Save schorschii/447fb47850bf38ddae1b08d024c42ea5 to your computer and use it in GitHub Desktop.

Select an option

Save schorschii/447fb47850bf38ddae1b08d024c42ea5 to your computer and use it in GitHub Desktop.
Rebuild an existing Ubuntu initrd/initramfs
#!/bin/bash
set -e
# 1. extract initrd with: unmkinitramfs initrd.img...-generic extracted
# 2. cd extracted
# 3. make changes
# 4. then execute this script to repack
if [ "$1" == "" ]; then
echo "Enter target file name as first parameter!"
exit 1
fi
cd early
find . -print0 | cpio --null --create --format=newc > "../$1"
cd ../early2
find . -print0 | cpio --null --create --format=newc >> "../$1"
cd ../early3
find . -print0 | cpio --null --create --format=newc >> "../$1"
cd ../main
find . -print0 | cpio --null --create --format=newc >> "../$1"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment