PXE // GENTOO

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

Requirements

Get the latest Minimal or Admin CD

cd /data/ISO-IMAGES/
#wget https://bouncer.gentoo.org/fetch/root/all/releases/amd64/autobuilds/20200226T214502Z/install-amd64-minimal-20200226T214502Z.iso
wget https://bouncer.gentoo.org/fetch/root/all/releases/amd64/autobuilds/20200226T214502Z/hardened/admincd-amd64-20200226T214502Z.iso

THE WRONG WAY — Embed the image into the ramdisk

draft — fails against newer install-amd64-minimal-20200226T214502Z.iso — it is wrong anyway as it is way to large to be pushed through PXE/tftp or PXE/nfs

mkdir -p /tftpboot/gentoowrong/
cd /tftpboot/gentoowrong/

#wget https://pub.nethence.com/bin/gentoo/pxe-craft-initrd.patch.patch
vi pxe-craft-initrd

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

chmod +x pxe-craft-initrd

#patch -p0 < ../pxe-craft-initrd.patch
./pxe-craft-initrd ./ /data/ISO-IMAGES/install-amd64-minimal-20190327T214503Z.iso 

THE RIGHT WAY – Fetch the image from the network

draft — woops this does not work anymore — wget cannot fetch as dhcp was not done at this stage

Mount the LiveCD and get the files ready

mkdir -p /tftpboot/gentoo/
cd /tftpboot/gentoo/

mkdir lala/
mount -o loop,ro /data/ISO-IMAGES/install-amd64-minimal-20200226T214502Z.iso lala/
#mount -o loop,ro /data/ISO-IMAGES/admincd-amd64-20200226T214502Z.iso lala/
cp -f lala/image.squashfs ./
cp -f lala/boot/gentoo kernel
cp -f lala/boot/gentoo.igz ./
umount lala/

Now tweak the init from within the RAMDISK

cd lala/
xz -dc ../gentoo.igz | cpio -id

In case you’ve got a patch already

wget https://pub.nethence.com/bin/gentoo/network.patch
patch -p0 < network.patch

otherwise proceed manually

cp -pi init init.orig
vi init

(proceed with the changes according to last available patch)
(AND ALSO FIX THE HARD-CODED IP AND PATH TO SQUASHFS IMAGE)

Eventually deliver a new patch for that

diff -Naur init.orig init > ../network.20200226T214502Z.patch

Pack it back

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

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

rm -rf lala/

Ready to go

vi /tftpboot/pxelinux.cfg/default

label gentoo rescue wrong
        kernel ../gentoowrong/kernel
        append initrd=../gentoowrong/initrd root=/dev/ram0 init=/linuxrc loop=/image.squashfs looptype=squashfs cdroot=1 real_root=/

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

Additional notes

from tdr on IRC

#Gentoo
LABEL new_pxe
    menu default
    MENU LABEL new pxe boot
    TIMEOUT 10000
    TOTALTIMEOUT 10000
    kernel pxe-kernel
    append initrd=pxe.gz rd.ip=dhcp root=x.x.x.x:/path/to/chroot

#Arch
LABEL Rescue64
    MENU LABEL system rescue
    kernel rescue64
    append initrd=initram.igz rd.ip=dhcp nfsboot=x.x.x.x:/path/to/chroot

Resources

Diskless install using PXE and kernel/initrd/squashfs from the LiveCD https://wiki.gentoo.org/wiki/Installation_alternatives#Diskless_install_using_PXE_and_kernel.2Finitrd.2Fsquashfs_from_the_LiveCD

Making the initrd https://wiki.gentoo.org/wiki/Old_Fashioned_Gentoo_Install#Making_the_initrd

initramfs https://wiki.gentoo.org/wiki/Initramfs

Custom Initramfs https://wiki.gentoo.org/wiki/Custom_Initramfs

troubles

Skip kernel module at boot https://superuser.com/questions/153792/skip-kernel-module-at-boot


HOME | GUIDES | BENCHMARKS | html