NBD mounting by name

Questions related to network booting via PXE
eworm
Posts: 27
Joined: 29 Jan 2008, 08:21
Location: Oberhausen
Contact:

NBD mounting by name

Postby eworm » 21 Jul 2011, 10:33

Hello everybody!

New nbd is supposed to mount shares via name. I would like to nuke "oldstyle" from my nbd server's config file... How about supporting this?

I would suggest something like this:

Code: Select all

--- init        2011-07-21 12:10:30.261550417 +0200
+++ init        2011-07-21 12:13:58.566401605 +0200
@@ -961,8 +961,13 @@ sysresccd_stage2_nbd()
         sysresccd_panic "Error: cannot load nbd kernel module"
     fi

+    if printf "%d" "${NBD_PORT}" 2>/dev/null >/dev/null; then
+       good_msg "Port is not a numeric value, using NBD new style, mounting by name..."
+       NBD_STYLE="-name"
+    fi
+
     good_msg "Setting up the NBD boot device..."
-    if ! ${NBD_PROG} "${NBD_SERVER}" "${NBD_PORT}" "${NBD_DEVICE}" -persist
+    if ! ${NBD_PROG} "${NBD_SERVER}" "${NBD_STYLE}" "${NBD_PORT}" "${NBD_DEVICE}" -persist
     then
         sysresccd_panic "Error: nbd-client failed to connect to ${NBD_SERVER}:${NBD_PORT}"
     else


Regards,
Chris

eworm
Posts: 27
Joined: 29 Jan 2008, 08:21
Location: Oberhausen
Contact:

Re: NBD mounting by name

Postby eworm » 21 Jul 2011, 11:15

Uh, named exports were introduced in nbd 2.9.17... Could we get an update, please? ;)

eworm
Posts: 27
Joined: 29 Jan 2008, 08:21
Location: Oberhausen
Contact:

Re: NBD mounting by name

Postby eworm » 27 Jul 2011, 08:05

Ok, I added an up to date nbd-client myself. This is my script:

Code: Select all

#!/bin/sh

INITRD="/srv/tftp/sysrcd/initram.igz"
TMPDIR="/tmp/.initrd-${RANDOM}"
NBD="http://www.archlinux.org/packages/community/i686/nbd/download/"

rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}
cd ${TMPDIR}

xzcat ${INITRD} | cpio -id
wget -O - ${NBD} | xzcat | tar x usr/sbin/nbd-client
mv usr/sbin/nbd-client sbin/
sed -i '/${NBD_PROG}/s/\(-name \)*"${NBD_PORT}"/-name "${NBD_PORT}"/' init

( find .; echo /dev/console; echo /dev/null ) | cpio --owner=root:root -H newc -o | lzma > ${INITRD}
rm -r ${TMPDIR}


Nevertheless I would like to get an up to date nbd-client by default. ;)

dcdaggett
Posts: 1
Joined: 11 Oct 2013, 10:52

Re: NBD mounting by name

Postby dcdaggett » 11 Oct 2013, 11:05

UP !

I need this as well as the NBD client in the current (3.8.0) System Rescue CD 's initrd does still not support connecting to NBD shares by their name.

Using port is kind of old stuff ("oldstyle" parameter in the /etc/nbd-server/config file).


Anyway, thanks eworm : your little bash script handles the job perfectly, but there was a change in nbd-client's path (I also added OLD_PATH).

Here is the script updated :

Code: Select all

#!/bin/sh

INITRD="/srv/tftp/sysrcd/initram.igz"
TMPDIR="/tmp/.initrd-${RANDOM}"
NBD="http://www.archlinux.org/packages/community/i686/nbd/download/"

OLD_PATH=$(pwd)
rm -rf ${TMPDIR}
mkdir -p ${TMPDIR}
cd ${TMPDIR}

xzcat ${INITRD} | cpio -id
wget -O - ${NBD} | xzcat | tar x usr/bin/nbd-client
mv usr/bin/nbd-client sbin/
sed -i '/${NBD_PROG}/s/\(-name \)*"${NBD_PORT}"/-name "${NBD_PORT}"/' init

( find .; echo /dev/console; echo /dev/null ) | cpio --owner=root:root -H newc -o | lzma > ${INITRD}
cd $OLD_PATH
rm -r ${TMPDIR}


If anyone want to keep the "oldstyle" after having run this shell script, you must edit the init script in initram.igz by adding the diff code from eworm.

Bye for now,
Dag

silvertip257
Posts: 1
Joined: 08 Dec 2013, 15:02

Re: NBD mounting by name

Postby silvertip257 » 08 Dec 2013, 15:22

+1

It would be beneficial to have System Rescue CD support "newstyle" NBD named exports as opposed to oldstyle.
Otherwise it is necessary to set the "oldstyle = true" in the [generic] section and specify a port in the individual export section(s). [0] [1]

In the meantime, I'd suggest notes be added to [2] and possibly a hyperlink on [3] back to [2]. Documenting this likely discrepancy helps new users (or someone new to NBD) avoid the hassle of a version/style mismatch.

Thanks for supporting NBD exports! :)


[0] viewtopic.php?f=5&t=3014
[1] https://bbs.archlinux.org/viewtopic.php ... 07#p996007
[2] http://www.sysresccd.org/Sysresccd-manu ... NFS_or_NBD
[3] http://www.sysresccd.org/Sysresccd-manu ... _using_PXE


Return to “Network Boot via PXE”

Who is online

Users browsing this forum: No registered users and 2 guests