Before setting up Ubuntu/Fedora PXE boot, it needs to prepare several items on your PXE server:
- * The Ubuntu/Fedora rootfs on tftp/nfs server:
It can refer to the my article MIPS/ARM64 Debian/Ubuntu debootstrap for building the Ubuntu rootfs.
If want to build the Fedora rootfs, it can install a new system on qemu and copy it from the qcow2 image.
- * PXE Server:
You can refer my article ARM64 Centos8/Ubuntu PXE Boot Install on Ubuntu Server to build a PXE server.
- NFS Server:
Assume the rootfs for Ubuntu is on /nfs/ubuntu2204 and Fedora 36 is on /nfs/fedora36.
Ubuntu PXE Boot
Copy vmlinux and initramfs to tftp server. Copy your current system’s vmlinux to your tftpboot. For example, create a directory for Ubuntu 22.04 in /tftpboot/nfs/ubuntu2204, and copy the vmlinuz to the folder using the following command:
$ cp /boot/vmlinuz-$(uname -r) /tftpboot/nfs/ubuntu2204/vmlinuz
Copy the initrd.img to the folder using the following command:
$ cp /boot/initrd.img-$(uname -r) /tftpboot/nfs/ubuntu2204/initrd.img
Setup your PXE server’s grub.cfg and add a record. Use the following example for the record:
menuentry 'Ubuntu22.04 nfsboot' { linux nfs/ubuntu2204/vmlinuz ip=dhcp root=/dev/nfs nfsroot=<NFS server IP>:/nfs/ubuntu2204,nolock rw netboot=nfs initrd nfs/ubuntu2204/initrd.img }
Fedora PXE Boot
The procedure is similar to Ubuntu, but the default Fedora initramfs doesn’t support nfs boot.
1. Rebuild the initramfs with dracut. You need to add nfs and network support to your Fedora initramfs using the following command:
$ dracut --add nfs --add network --force
It will generate the same name vmlinuz and initramfs. Copy it to your directory just like Ubuntu.
2. Disable selinux.
Default Fedora selinux is enabled, but it cannot enable on nfs rootfs (or it can but needs to set up something). You can disable it by adding selinux=0 on boot kernel parameter. Use the following example for the record:
linux nfs/fedora36/vmlinuz boot=nfs root=/dev/nfs nfsroot=<NFS server IP>:/nfs/fedora36,nolock rw netboot=nfs ip=dhcp selitarnux=0
發佈留言