Gentoo Rescue over PXE

INTOXICATED: When you feel sophisticated without being able to pronounce it.

Requirements

Get the latest Minimal CD

cd /data/ISO-IMAGES/
wget http://distfiles.gentoo.org/releases/amd64/autobuilds/20190327T214503Z/install-amd64-minimal-20190327T214503Z.iso

mkdir -p /tftpboot/gentoopxe/
cd /tftpboot/gentoopxe/

THE WRONG WAY – Embed the image into the ramdisk

vi pxe-craft-initrd

copy/paste from https://wiki.gentoo.org/wiki/Installation_alternatives

chmod +x pxe-craft-initrd

./pxe-craft-initrd ./ /data/ISO-IMAGES/install-amd64-minimal-20190327T214503Z.iso 

THE RIGHT WAY – Fetch the image from the network

Mount the LiveCD and get the files ready

rm -rf lala/ lili/
mkdir lala/ lili/
mount -o loop,ro /data/ISO-IMAGES/install-amd64-minimal-20190327T214503Z.iso lala/
cp -f lala/image.squashfs ./
cp -f lala/boot/gentoo kernel

Make sure you’ve got the patches ready

#wget http://tmp.nethence.com/gentoo/pxe-craft-initrd.patch.patch
wget http://tmp.nethence.com/gentoo/network.patch

Now tweak the init from within the RAMDISK

cd lili/
xz -dc ../lala/boot/gentoo.igz | cpio -id
#cp -pi init init.orig
#patch -p0 < ../pxe-craft-initrd.patch
patch -p0 < ../network.patch
#diff -Naur init.orig init > ../network.patch
vi init

FIX THE HARD-CODED IP AND PATH TO SQUASHFS IMAGE

find . -print | cpio -o -H newc | gzip -9 -c - > ../network
cd ../

Don’t forget to clean-up things once everything works as expected

umount lala/
rm -rf lala/ lili/

Ready to go

vi /tftpboot/pxelinux.cfg/ghostrescue

label gentoo rescue embed
        kernel gentoopxe/kernel
        append initrd=gentoopxe/initrd root=/dev/ram0 init=/linuxrc loop=/image.squashfs looptype=squashfs cdroot=1 rea
l_root=/

label gentoo rescue network
        kernel gentoopxe/kernel
        append initrd=gentoopxe/network ip=dhcp root=/dev/ram0 init=/linuxrc loop=/image.squashfs looptype=squashfs cdroot=1 real_root=/

Resources


Nethence | Doc | Pub | Lab | Pbraun | SNE Russia | xhtml