morph027 / pve-iso-2-pxe

Create PXE bootable Proxmox installation
MIT License
408 stars 91 forks source link

Lift root requirement #17

Closed aadnehovda closed 3 years ago

aadnehovda commented 3 years ago

I had a stab at a version which does not require root access, and actually not even mounting or repackaging at all. Using isoinfo we can directly extract the kernel and the initrd. As it turns out (via https://unix.stackexchange.com/questions/243657) you can simply append another gzipped cpio archive to the original initrd.img and the kernel will happily read both archives and merge them together into the initramfs.

#!/bin/env bash

isoinfo -i proxmox.iso -R -x /boot/linux26 > linux26
isoinfo -i proxmox.iso -R -x /boot/initrd.img > initrd.img
echo 'proxmox.iso' | cpio -H newc -o | gzip --best >> initrd.img
morph027 commented 3 years ago

Thank you, this looks really good. Will implement this!

aadnehovda commented 3 years ago

The ISO is only slightly compressible even with gzip --best, only ~2%, so that step can probably be skipped too. (Taken from the SO link that the kernel accepts parts of the initrd.img that are either compressed or not. Not tested.)