PXE boot CentOS 7.2 diskless fails with “Failed to start Switch Root”

centos7dracutpxe-boot

I am setting up a CentOS 7.2 server so clients can boot a diskless CentOS 7.2 image. I have done this with CentOS 6.6 and it works fine over multiple servers and clients over many years. Using the same configuration parameters.
/var/lib/tftpboot/pxelinux.cfg/default contains:

default menu.c32
prompt 0
timeout 100
TOTALTIMEOUT 300
ONTIMEOUT CentOS
MENU TITLE Linux 7.2 PXE Boot Menu 
LABEL CentOS
        MENU LABEL CentOS 7.2 x86_64 em1
        KERNEL images/centos/x86_64/7.2/vmlinuz-3.10.0-327.el7.x86_64
        APPEND initrd=images/centos/x86_64/7.2/diskless_initrd.img ip=dhcp nfs=10.0.0.1:/diskless/centos/7.2/root rw  quiet

When PXE booting the client it gets quite far, but stops at:

Starting Switch Root...
Failed to switch root: Specified switch root path /sysroot does not seem to be an OS tree. os-release file is missing.
initrd-switch-root.service: main process exited, code=exited, status=1/FAILURE

This drops me into the emergency shell, and if I look at /sysroot it is an empty directory!

I saved the diskless_initrd.img using

dracut -f diskless_initrd.img `uname -r`

and copying it to the specified location. I also tried "dracut -d nfs -d network" which some suggested.

I don't understand why this works with my CentOS 6.6 server but not here in 7.2.

Best Answer

You still working through this? I was having the same problem with RHEL/Centos 7.x. Never had this issue on 5.x or 6.x. I tried both legacy and UEFI mode with the same result.

I found the problem in my process. Two things actually.

  1. I neglected to clean up /etc/sysconfig/network-scripts in my rsync'd filesystem. It still contained scripts from the source filesystem.

  2. We have multiple NICs on our diskless clients. We were missing certain boot parameters in the network boot configs, like so:

APPEND initrd=images/centos/x86_64/7.2/diskless_initrd.img ip=bond1:dhcp root=nfs:10.0.0.1:/diskless/centos/7.2/root bond=bond1:eth4,eth5:mode=1 biosdevname=0 net.ifnames=0 rw quiet

In your case you might not be using bonded network devices, but you may still need to specify the device name of the NIC that your diskless client obtains the filesystem on, like so...

APPEND initrd=images/centos/x86_64/7.2/diskless_initrd.img ip=eth3:dhcp root=nfs:10.0.0.1:/diskless/centos/7.2/root biosdevname=0 net.ifnames=0 rw quiet
Related Topic