PXE // GENTOO

Requirements

Grab the latest Minimal Installation CD and/or Admin CD

cd /tftpboot/ISO-IMAGES/

wget https://bouncer.gentoo.org/fetch/root/all/releases/amd64/autobuilds/20210425T214502Z/install-amd64-minimal-20210425T214502Z.iso

wget https://bouncer.gentoo.org/fetch/root/all/releases/amd64/autobuilds/20210414T214503Z/hardened/admincd-amd64-20210414T214503Z.iso

Mount the ISO images

mkdir -p /tftpboot/gentoo/
cd /tftpboot/gentoo/
mkdir iso/
mount -o loop,ro /tftpboot/ISO-IMAGES/install-amd64-minimal-20210425T214502Z.iso iso/

mkdir -p /tftpboot/gentoo-rescue/
cd /tftpboot/gentoo-rescue/
mkdir iso/
mount -o loop,ro /tftpboot/ISO-IMAGES/admincd-amd64-20210414T214503Z.iso iso/

diff ../gentoo/iso/boot/gentoo iso/boot/gentoo # differ
diff ../gentoo/iso/boot/gentoo.igz iso/boot/gentoo.igz # differ

ls -lF ../gentoo/iso/boot/gentoo iso/boot/gentoo # rescue kernel is a bit larger
ls -lF ../gentoo/iso/boot/gentoo.igz iso/boot/gentoo.igz # install ramdisk is a bit larger

Diskless/NFS

boot time 36m30s

Here kernel and ramdisk are loaded through TFTP, then the LiveCD lives through read-only NFS.

cd /tftpboot/gentoo/
cd /tftpboot/gentoo-rescue/
rm -rf nfs/
cp -a iso/ nfs/
umount iso/
rmdir iso/

SquashFS/HTTP

boot time 37m40s

Here kernel and ramdisk are loaded through TFTP, then the system image is fetched through HTTP. We are tweaking the ramdisk for that purpose.

cd /tftpboot/gentoo/
cd /tftpboot/gentoo-rescue/
cp -f iso/boot/gentoo kernel
cp -f iso/boot/gentoo.igz ./
cp -f iso/image.squashfs ./
umount iso/
rmdir iso/

cd /tftpboot/gentoo/
cd /tftpboot/gentoo-rescue/
mkdir network/
cd network/
xz -dc ../gentoo.igz | cpio -id
#cp -pi init init.orig

Grab the patch and proceed

cd /tftpboot/gentoo/
wget https://pub.nethence.com/bin/gentoo/network-apr2021.patch.txt
patch -p0 < network-apr2021.patch.txt
vi network/init # FIX THE PXE-SERVER-ADDRESS

cd /tftpboot/gentoo-rescue/
diff ../../gentoo/network/init init # identical
patch -p0 < ../gentoo/network-apr2021.patch.txt
vi network/init # FIX THE PXE-SERVER-ADDRESS

Pack it back and clean-up things, once everything works as expected

cd /tftpboot/gentoo/network/
cd /tftpboot/gentoo-rescue/network/
find . -print | cpio -o -H newc | gzip -9 -c - > ../network.img
cd ../
ls -lhF kernel gentoo.igz network.img image.squashfs
rm -rf network/

Additional notes

Eventually deliver a new patch for that

cd /tftpboot/gentoo/
diff -Naur network/init.orig network/init > network-TAG.patch

Ready to go

vi /tftpboot/pxelinux.cfg/default

label gentoo install (nfs)
    kernel gentoo/nfs/boot/gentoo
    initrd gentoo/nfs/boot/gentoo.igz
    append root=/dev/ram0 loop=/image.squashfs looptype=squashfs cdroot=1 real_root=/dev/nfs nfsroot=192.168.1.20:/tftpboot/gentoo/nfs net.ifnames=0 ip=dhcp
    # console=ttyS1,57600

label gentoo install (squashfs/http)
    kernel gentoo/kernel
    initrd gentoo/network.img
    append root=/dev/ram0 loop=/image.squashfs looptype=squashfs cdroot=1 real_root=/ net.ifnames=0 ip=dhcp

label gentoo rescue (nfs)
    kernel gentoo-rescue/nfs/boot/gentoo
    initrd gentoo-rescue/nfs/boot/gentoo.igz
    append root=/dev/ram0 loop=/image.squashfs looptype=squashfs cdroot=1 real_root=/dev/nfs nfsroot=192.168.1.20:/tftpboot/gentoo/nfs net.ifnames=0 ip=dhcp

label gentoo rescue (squashfs/http)
    kernel gentoo-rescue/kernel
    initrd gentoo-rescue/network.img
    append root=/dev/ram0 loop=/image.squashfs looptype=squashfs cdroot=1 real_root=/dev/nfs nfsroot=192.168.1.20:/tftpboot/gentoo-rescue/nfs net.ifnames=0 ip=dhcp

Apparently not needed

# init=/linuxrc

Resources

Diskless install using PXE from the LiveCD https://wiki.gentoo.org/wiki/Installation_alternatives#Diskless_install_using_PXE_from_the_LiveCD

Revision history of “Installation alternatives” https://wiki.gentoo.org/index.php?title=Installation_alternatives&action=history

PXE https://wiki.gentoo.org/wiki/PXE

Gentoo PXE Server http://cvpcs.org/projects/linux/pxegen

Gentoo Cheat Sheet https://wiki.gentoo.org/wiki/Gentoo_Cheat_Sheet

index : proj/genkernel.git https://gitweb.gentoo.org/proj/genkernel.git/

diskless

Diskless install using PXE boot and NFS https://wiki.gentoo.org/wiki/Installation_alternatives#Diskless_install_using_PXE_boot_and_NFS

Diskless nodes https://wiki.gentoo.org/wiki/Diskless_nodes

PXE booting disk less Gentoo OS https://forums.gentoo.org/viewtopic-t-1115656-start-0.html

My Gentoo diskless install howto https://forums.gentoo.org/viewtopic-t-54293-start-75.html

HOWTO_Gentoo_Diskless_Install http://wikigentoo.ksiezyc.pl/HOWTO_Gentoo_Diskless_Install.htm

squashfs

SquashFS https://wiki.gentoo.org/wiki/SquashFS

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

link from 2008 http://blog.dastrup.com/?p=12

link from 2010 https://ercpe.de/blog/how-to-boot-a-gentoo-livecd-via-pxe / https://ercpe.de/media/2010-05-08/init.patch

[syslinux] PXE max boot image size? https://www.syslinux.org/archives/2002-March/000249.html

Maximum initrd.gz image size for netbooting… https://lists.debian.org/debian-boot/2004/02/msg00199.html

How can I boot a squashfs image on my hard drive? https://forums.gentoo.org/viewtopic-t-931250-start-0.html

boot Gentoo minimal install image with PXE instead of CD https://forums.gentoo.org/viewtopic-t-991658-start-0.html

gentoo-pxe-builder https://github.com/numberly/gentoo-pxe-builder –> same old patch

Gentoo Linux PXE builder https://ultrabug.fr/Tech%20Blog/2014/2014-12-20-gentoo-linux-pxe-builder/

–> refers to the above

Pxe-livecd¶ https://redmine.ekb-info.ru/projects/gentoo/wiki/Pxe-livecd –> same old patch

alternatives

netboot https://packages.gentoo.org/packages/sys-boot/netboot

troubles

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


GUIDES | LECTURES | BENCHMARKS | SMTP HEALTH