How to create linux kernel and initramfs.img for PXE boot

Issues related to applications and software problems and general support
Post Reply
hiro@atech
Posts: 5
Joined: 2022/07/20 08:56:33

How to create linux kernel and initramfs.img for PXE boot

Post by hiro@atech » 2022/07/20 10:00:15

Hi,

I tried to set up CentOS 9 Stream PXE boot environment with the "genuine" repository(below) and saw CentOS successfully launch on remote UEFI based machine.

wget -P /var/lib/tftpboot/ \
http://mirror.stream.centos.org/9-strea ... OOTX64.EFI \
http://mirror.stream.centos.org/9-strea ... rubx64.efi \
http://mirror.stream.centos.org/9-strea ... T/grub.cfg

wget -P /var/lib/tftpboot/centos-st9/ \
http://mirror.stream.centos.org/9-strea ... ot/vmlinuz \
http://mirror.stream.centos.org/9-strea ... initrd.img

As my next step, I would like to update its kernel version. What I tried to do for this is..

1. build Linux kernel 5.18.12 from scratch. I confirmed it successfully ran on local CentOS 9 Stream machine.
2. simply add menuentry section in grub.cfg like below(the 2nd entry) with the newly created kernel and initramfs.img file:
3. As a result, boot process started but didn't end up in success like the attached picture.

# with original vmlinuz and initrd.img. Successfully run
menuentry 'Start CentOS 9 Stream [via PXE NFS]' --class centos --class gnu-linux --class gnu --class os {
linuxefi /centos-st9/vmlinuz root=nfs:192.168.20.1:/var/lib/tftpboot/centos-st9/root rw selinux=0 ip=dhcp
initrdefi /centos-st9/initrd.img
}

# with newly created kernel and initramfs.img file. boot process started but FAILED
menuentry 'Start CentOS 9 Stream with kernel 5.18.12 [via PXE NFS]' --class centos --class gnu-linux --class gnu --class os {
linuxefi /centos-st9/root/boot/vmlinuz-5.18.12 root=nfs:192.168.20.1:/var/lib/tftpboot/centos-st9/root rw selinux=0 ip=dhcp
initrdefi /centos-st9/root/boot/initramfs-5.18.12.img
#initrdefi /centos-st9/initrd.img
}
IMG_2198.JPG
Any comments would be appreciated.

Thanks and regards,

hiro@atech
Posts: 5
Joined: 2022/07/20 08:56:33

Re: How to create linux kernel and initramfs.img for PXE boot

Post by hiro@atech » 2022/07/20 16:36:45

Hi

I forgot to upload the picture. Please find the attached showing the boot failure case.
IMG_2198.JPG
IMG_2198.JPG (105.04 KiB) Viewed 2803 times
Regards

User avatar
TrevorH
Site Admin
Posts: 33202
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: How to create linux kernel and initramfs.img for PXE boot

Post by TrevorH » 2022/07/20 16:50:13

That's the panic you get when you don't have a driver for the hard disk controller the install is on. So either you didn't build it or didn't include it in the initramfs or the initramfs is corrupt. Start by building using a copy of the original distro config file from /boot/config-$version.

Why are you even doing this?
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hiro@atech
Posts: 5
Joined: 2022/07/20 08:56:33

Re: How to create linux kernel and initramfs.img for PXE boot

Post by hiro@atech » 2022/07/21 05:40:46

Thanks for the reply.
I would like to change linux kernel for testing the I/O device connected to the remote machine.
(I need to re-build linux kernel for the I/O device support)

Meanwhile, I tried using the "proven" pre-built kernel / initramfs.img coming with CentOS 9 Stream.
without saying they run on local drive without any problems. However in PXE environment, I encountered different error log as attached.

Any comments / suggestions would be appreciated.

Regards,
IMG_0018.jpg
IMG_0018.jpg (239.2 KiB) Viewed 2771 times

hiro@atech
Posts: 5
Joined: 2022/07/20 08:56:33

Re: How to create linux kernel and initramfs.img for PXE boot

Post by hiro@atech » 2022/07/23 02:56:36

Hi

I tied re-generating initramfs.img with the following command:
dracut -f /boot/initramfs-[kernel version].img [kernel-version]

before executing the above command, I initially set the following dracut configuration into /etc/dracut.conf.d/pxeNFS.conf.

dracutmodules+=" nfs "
add_dracutmodules+=" nfs "
filesystems+=" nfs vfat msdos isofs ext4 xfs "

With this renewed initramfs.img, the dracut FATAL message vanished but boot up process is stuck at "Reached target multi-user system" prompt
IMG_0018.jpg
IMG_0018.jpg (190.72 KiB) Viewed 2730 times
Any comments would be appreciated.

Regards,

hiro@atech
Posts: 5
Joined: 2022/07/20 08:56:33

Re: How to create linux kernel and initramfs.img for PXE boot

Post by hiro@atech » 2022/07/24 06:31:05

Hi,

I have finally solved the problem with /etc/dracut.conf.d/pxeNFS.conf silightly modified as follows:

filesystems+=" nfs "
add_dracutmodules+=" nfs "

Now linux kernel 5.18.14 successfully PXE-boots.

Thanks for all having interest in this topic.

Regards,

Post Reply