Page 1 of 1

PXE boot using NFS

Posted: 11 Nov 2008, 16:04
by techmad

I'm having an issue trying to add the SystemRescue cd to our PXE. Im using an NFS share, and the entry in the default file is as follows:

Code: Select all

label sysrescue
kernel release/sysrescuecd/rescuecd
append initrd=release/sysrescuecd/initram.igz root=/dev/ram0 init=/linuxrc video=ofonly vga=0 looptype=squashfs loop=sysrescuecd/sysrcd.dat setkmap=uk cdroot splash=silent nfsroot= real_root=/dev/nfs softlevel=pxe
It fails giving the following error:
'Device /dev/nfs is not a valid root device...
Running a mini shell (cannot complete the boot process)

Can anyone help with this? Im using the latest version (1.1.1)

Thanks :)

Posted: 12 Nov 2008, 08:02
by admin
NFS has never been supported. You have to use HTTP or TFTP as described in the handbook.

Posted: 14 Nov 2008, 16:23
by techmad
Thanks for the reply, gave up on NFS, using http now and alls working well :)

Posted: 28 Dec 2008, 21:42
by birdpower
Not Supported dos not mean it can be done.

Downloading the large sysrcd.dat to the computers memory (tmpfs) is not always the luxury available on all those sick computers.

Iif you looking for a non-supported feature like share sysrcd.dat though nfs and you have some time to spare there is a way ......

What you need is the nfs kernel modules (nfs.ko nfs_acl.ko,lockd.ko sunrpc.ko ) the portmap binary must be added to the initram.igz (these can found in the squashfs-ed sysrcd.dat)
some lines of code in the init script for loading these modules and mount the nfs share where the sysrcd.dat file is located, next the script continues like sysrcd.dat was downloaded
only 800Kb memory usage on kernel modules en portmap process

the code I used is not very portable, but start looking at the sysreccd_bootstrap_net routine
you will see that is not hard to add a extra type of url....

I don't know if there is more to squeeze on memory consumption. but this was for me the trick. o yah tmpfs default size is half the memory.. -o size=32m is more frendly.

still not convinced? for example started with a healthy 1Gb machine there was only 150Mb of active pages while X is running..... leaving 850MB....

Code: Select all

[email protected] /root % uname -a
Linux sysresccd #1 SMP Sat Dec 6 00:19:24 UTC 2008 i686 Intel(R) Pentium(R) 4 CPU 3.40GHz GenuineIntel GNU/Linux
[email protected] /root % df
Filesystem           1K-blocks      Used Available Use% Mounted on
tmpfs                    32768     26148      6620  80% /
                      64657408   4714304  56658624   8% /mnt/cdrom
/dev/loop0              204288    204288         0 100% /mnt/livecd
tmpfs                    32768     26148      6620  80% /mnt/memory
udev                     10240       172     10068   2% /dev

There was only one trick: add a loopback adapter before start the portmaper like this

ifconfig lo netmask up

Posted: 31 Dec 2008, 22:14
by admin
Yes it is possible to implement a boot using NFS. I did not because NFS is quite complex.

We could also do the same sort of thing using NBD (Network block device).

Re: PXE boot using NFS

Posted: 30 Jan 2010, 21:25
by richard
Hi admin,

You've advanced for isoloop and nfs solution but have you progressed for nbd's boot or have you a track to follow ?

best regards,

Re: PXE boot using NFS

Posted: 12 Feb 2010, 12:28
by admin
No NBD has not been implemented yet, but you can customize the "init" script in the initramfs if you have time.

Re: PXE boot using NBD

Posted: 19 Feb 2010, 22:32
by richard

I'd advance for NBD boot, so I would propose my contrib.

I've modified the init file in the initram.igz archive :

Code: Select all

> # connect the NBD device
> sysresccd_nbdboot()
> {
>         good_msg 'Executing nbd-client /dev/nbd0 to access nbd root'
>       NBD_SERVER=$(echo "${NBD_ROOT}" | sed 's/:.*//')
>       NBD_PORT=$(echo "${NBD_ROOT}" | sed 's/.*://')
>       /usr/sbin/nbd-client "${NBD_SERVER}" "${NBD_PORT}" /dev/nbd0 -persist
> }
>               nbdroot\=*)
>                       NBD_ROOT=`parse_opt "${x}"`
>                       REAL_ROOT="/dev/nbd0"
>                       LOADNET='1'
>                       CDROOT='0'
>               ;;
> # ---- don't load the nbd modules which is time consuming if nbd not involved
> if [ -z "${NBD_ROOT}" ]
> then
>       rm -f /etc/modules/nbd
> fi
< if [ -n "${NETBOOT}" ]
> if [ -n "${NETBOOT}" ] || [ -n "${NBD_ROOT}" ]
> # create the nbd device on demand
> if [ -x /usr/sbin/nbd-client ] && [ -n "${NBD_ROOT}" ]
> then
>       sysresccd_nbdboot # boot with nbd device
> fi
I add nbd-client binary in /usr/sbin/ directory and nbd.ko module in /lib/modules/... directory.

The nbd file in /etc/modules directory contain only "nbd" and I add "nbd" to the MY_HWOPTS variable in the /etc/initrd.defaults file, but my thin client didn't boot because the startup script checkroot want to mount the rootfs in read/write mode.

I'm stopped...

Re: PXE boot using NFS

Posted: 20 Feb 2010, 16:14
by richard
Ok, it works fine I post in contrib directory...

Re: PXE boot using NFS

Posted: 28 Feb 2010, 18:03
by admin
Boot from NFS has been added to the official distribution, as well as boot from NBD, and it's available in SystemRescueCd-1.4.0 and more recent. ... NFS_or_NBD

Re: PXE boot using NFS

Posted: 01 Apr 2010, 14:43
by RyLoS
I'm trying to boot Sysrescd 1.5.1 using NFS but it isn't working:
the NFS share is succesfully mounted as the boot logs says...but loading of sysrcd.dat doesn't start.

The boot just stop forever on NFS share succesfully mounted....

(Obviously inside my nfs share there is sysrcd.dat and sysrcd.md5 with permissions for everyone 777).

Could you please check and fix it? (HTTP in RAM is not an option here)

Thank you in advance.

Re: PXE boot using NFS

Posted: 20 Apr 2010, 15:34
by jameslancaster

Is it actually frozen, or is it taking awhile to calculate the MD5 checksum?

Re: PXE boot using NFS

Posted: 24 Apr 2010, 12:11
by RyLoS
It is actually frozen. It stay in this state forever.

Re: PXE boot using NFS

Posted: 28 Apr 2010, 10:56
by admin
There is no support for NFS4 so please check you are using NFS3 on your server.

You can try with the following syntax:

Code: Select all

rescuecd ethx= netboot=nfs://
The nfs:// prefix is interpreted by the main boot script and only the text which comes after that prefix is passed to the mount command. This way all protocols can be used with the netboot options. It's a replacement for all protocol specific boot options.

I suggest that you run the nfs mount command by hand from the minimal environment to see what happens.

1) Boot with "rescuecd minishell"
2) Run ifconfig by hand to configure the network (and /etc/resolv.conf + route if necessary)
3) Run "mount -t nfs" manually to see what happens

You can create a temp directory and see if you can mount it:

Code: Select all

mkdir /nfstest
mount -t nfs -o intr,nolock /nfstest
FYI: here is the original code that is executed

Code: Select all

        nfsurl=$(echo ${NFSBOOT} | sed -e 's!nfs://!!g')

        good_msg "Mouting the NFS filesystem from ${NFSBOOT}"
        cmd="mount -t nfs -o intr,nolock ${nfsurl} ${BOOTPATH}"
        if ! ${cmd}
                sysresccd_panic "Cannot mount NFS: ${cmd}"
        good_msg "Successfully mounted the NFS filesystem"

        if [ ! -f "${BOOTPATH}/${SUBDIR}/${LOOPDAT}" ]
                sysresccd_panic "Cannot find the \"${SUBDIR}/${LOOPDAT}\" boot file."

        md5now=$(/bin/busybox md5sum ${BOOTPATH}/${SUBDIR}/${LOOPDAT} | cut -d ' ' -f1)
        md5orig=$(cat ${BOOTPATH}/${SUBDIR}/${LOOPMD5} | cut -d ' ' -f1)
        if [ "$md5now" = "$md5orig" ]
                good_msg "Successfully checked md5 sum of ${BOOTPATH}/${LOOPDAT}"
                sysresccd_panic "md5sum checksum is invalid on the root filesystem image"

Re: PXE boot using NFS

Posted: 02 Dec 2014, 11:04
by hrts

I managed to boot SystemRescueCD 2.4.1 over NFS version 4 like this:


Code: Select all

        MENU LABEL SystemRescueCD 2.4.1 - NFS
        kernel srcd/rescue64
        append netboot=nfs initrd=srcd/initram.igz nfsboot=a.b.c.d:/srcd ro dodhcp quiet --
Please note the difference from booting over tftp: netboot=tftp://a.b.c.d/srcd/sysrcd.dat!
With NFS you don't point toward sysrcd.dat anymore! The boot process finds sysrcd.dat by itself.

note: a.b.c.d is the IP of the NFS server.

Note: Version 4 uses authentication.

According to the ... _nfs_howto the nfs uses the hostname.
Also, in /var/log/messages i Discovered these error messages:

Code: Select all

Nov 20 22:17:52 filefire rpc.mountd[10019]: refused mount request from a.b.c.db for /srcd (/): unmatched host
If you did setup NFS to use any kind of authentication, you might want to replace the IP with its hostname. Do that if you see in /var/log/messages error messages about NFS requests from an UNMATCHED HOST - for me it solved the access.
But you have to have the host defined in /etc/hosts


Code: Select all

/srcd *(ro,no_subtree_check,all_squash,insecure,anonuid=1000,anongid=1000)
It works also if you add option fsid=0 (= this is "/")

My NFS server does not work with multiple level directories in /etc/exports. So I've simulated for the NFS server a directory under "/". (search for pseudofilesystem concept in NFS4)


In my case the srcd folder is located under /var/tftpboot/srcd. But if I put the whole path in /etc/exports, the client (SystemRescueCD 2.4.1) tells me "No directory". Using pseudofilesystem functionality build in NFS version 4 I can access srcd folder if /etc/exports contains an export for /srcd.

The trick I used is to create a symbolic link in "/", link that points to the srcd folded

Code: Select all

ln -s /var/tftpboot/srcd /srcd
Replace /var/tftpboot/srcd with the actual location of SystemRescueCD 2.4.1 files.


Code: Select all

chmod -R o+wx /srcd

Do not forget to allow access to portmap and nfsd (/etc/hosts.allow)!

NFS server used: 1.2.7 from ipFIRE implementation.

Hope that it helps.

PS: extra documentation used to reach above configuration. ... -0408.aspx