rewrite based on reference project from github

This commit is contained in:
2026-01-30 22:58:37 +01:00
parent 1e884eec99
commit 4790e69113
4 changed files with 74 additions and 18 deletions

View File

@@ -199,26 +199,21 @@ umount -l $BUILD_DIR/rootfs/proc
rm $BUILD_DIR/rootfs/setup.sh
# Build initramfs with dracut using the rootfs modules
echo "Building initramfs with dracut using rootfs kernel and modules..."
# Build initramfs with custom netboot hooks/scripts
echo "Building custom netboot initramfs..."
KERNEL_VERSION=$(ls -1 $BUILD_DIR/rootfs/boot/vmlinuz-* | sed 's|.*/vmlinuz-||' | head -1)
# Mount proc/sys temporarily for dracut if needed
mount -t proc proc $BUILD_DIR/rootfs/proc 2>/dev/null || true
dracut -f \
--add "network" \
--hostonly \
--hostonly-cmdline \
--include "/usr/share/initramfs-tools/hooks/rooturl" "/usr/share/initramfs-tools/hooks/" \
--include "/usr/share/initramfs-tools/scripts/local-top/rooturl" "/usr/share/initramfs-tools/scripts/local-top/" \
-k $KERNEL_VERSION \
-r $BUILD_DIR/rootfs \
$BUILD_DIR/rootfs/boot/initrd-netboot.img
umount -l $BUILD_DIR/rootfs/proc 2>/dev/null || true
echo "Initramfs build complete. Size: $(du -h $BUILD_DIR/rootfs/boot/initrd-netboot.img | cut -f1)"
# Use mkinitramfs with custom initramfs directory
INITRAMFS_CONFIG="/srv/netboot/initramfs"
if [ -d "$INITRAMFS_CONFIG" ]; then
mkinitramfs -d "$INITRAMFS_CONFIG" \
-k "$KERNEL_VERSION" \
-o $BUILD_DIR/rootfs/boot/initrd-netboot.img
echo "Initramfs build complete. Size: $(du -h $BUILD_DIR/rootfs/boot/initrd-netboot.img | cut -f1)"
else
echo "ERROR: Custom initramfs config not found at $INITRAMFS_CONFIG"
exit 1
fi
# Copy kernel and netboot initramfs
mkdir -p $IMAGE_DIR/$VERSION