HOMEPAGE FORUMS NEWS DOCUMENTATION SCREENSHOTS
SystemRescueCd forums
View unanswered posts | View active topics It is currently 25 May 2013, 06:26



Post new topic Reply to topic  [ 5 posts ] 
 Booting SystemRescueCd from the network using NBD devices 
Author Message

Joined: 17 Jun 2008, 08:05
Posts: 22
Location: Rumilly, France
Post Booting SystemRescueCd from the network using NBD devices
Hi,

Well I work with this solution for LTSP servers but also thinclients made with debian... It didn't consume a lot of memory and it light for the network.

Tree files are added in the intrd (but present in the squashfs file) :
usr/sbin/nbd-client
lib/modules/2.6.31.12-std135/kernel/drivers/block/nbd.ko

The MY_HWOPTS variable's was modified in the etc/initrd.defaults file :
Code:
...
MY_HWOPTS='modules pata sata scsi usb firewire dmraid mdadm fs net nbd'
...



Create the etc/modules/nbd file
contain only "nbd"

The modifications of init script in the intram
Code:
455a456,473
> # connect the NBD device
> sysresccd_nbdboot()
> {
>    REAL_ROOT="nbd"
>    NBD_DEVICE="/dev/nbd0"
>
>         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/.*://')
>
>    # connect nbd device
>    /usr/sbin/nbd-client "${NBD_SERVER}" "${NBD_PORT}" "${NBD_DEVICE}" -persist
>
>    # mount rofs
>    mkdir /rofs
>    mount ${NBD_DEVICE} /rofs
> }
>
489a508
> NBD_ROOT=''
574a594,598
>       nbdroot\=*)
>          NBD_ROOT=`parse_opt "${x}"`
>          LOADNET='1'
>          CDROOT='0'
>       ;;
758a783,788
> # ---- 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
>
786c816
< if [ -n "${NETBOOT}" ]
---
> if [ -n "${NETBOOT}" ] || [ -n "${NBD_ROOT}" ]
1130a1164,1169
> # create the nbd device on demand
> if [ -x /usr/sbin/nbd-client ] && [ -n "${NBD_ROOT}" ]
> then
>    sysresccd_nbdboot # boot with nbd device
> fi
>
1220c1259
<       elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "http" ] || [ "${REAL_ROOT}" = "tftp" ]
---
>       elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "http" ] || [ "${REAL_ROOT}" = "tftp" ] || [ "${REAL_ROOT}" = "nbd" ]
1231c1270
<    if [ "${CDROOT}" = '1' ] && [ "${got_good_root}" = '1' ]
---
>    if [ "${CDROOT}" = '1' ] && [ "${got_good_root}" = '1' ] || [ "${REAL_ROOT}" = "nbd" ]
1507a1547,1554
> # If cdroot is unset determine and nbdboot is define try to mount root
> if [ ${CDROOT} = '0' ] && [ "${REAL_ROOT}" = "nbd" ]
> then
>    mkdir /rwfs
>    mount -t tmpfs tmpfs /rwfs
>    mount -t aufs -o dirs=/rwfs=rw:/rofs=ro aufs ${NEW_ROOT}
> fi
>
ltsp-server:/var/lib/tftpboot/sysrcd/initram_custom# diff -cB init.ORI init
*** init.ORI   2010-02-20 16:38:34.000000000 +0100
--- init   2010-02-20 18:13:28.000000000 +0100
***************
*** 453,458 ****
--- 453,476 ----
     echo "netconfig1: ${ipcmd_add} --> ${res}"
  }
 
+ # connect the NBD device
+ sysresccd_nbdboot()
+ {
+    REAL_ROOT="nbd"
+    NBD_DEVICE="/dev/nbd0"
+
+         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/.*://')
+
+    # connect nbd device
+    /usr/sbin/nbd-client "${NBD_SERVER}" "${NBD_PORT}" "${NBD_DEVICE}" -persist
+
+    # mount rofs
+    mkdir /rofs
+    mount ${NBD_DEVICE} /rofs
+ }
+
  # Clean input/output
  exec >${CONSOLE} <${CONSOLE} 2>&1
  [ ! -f /dev/urandom ] && busybox mknod /dev/urandom c 1 9 2>/dev/null
***************
*** 487,492 ****
--- 505,511 ----
 
  CMDLINE="$(cat /proc/cmdline)"
  CDROOT='1'
+ NBD_ROOT=''
  REAL_ROOT=''
  SETKMAP=''
  MINISHELL=''
***************
*** 572,577 ****
--- 591,601 ----
           NETBOOT=`parse_opt "${x}"`
           LOADNET='1'
        ;;
+       nbdroot\=*)
+          NBD_ROOT=`parse_opt "${x}"`
+          LOADNET='1'
+          CDROOT='0'
+       ;;
        subdir\=*)
           SUBDIR=`parse_opt "${x}"`
        ;;
***************
*** 756,761 ****
--- 780,791 ----
     rm -f /etc/modules/net
  fi
 
+ # ---- 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
+
  # ---- load modules listed in MY_HWOPTS if /lib/modules exists
  if [ -d '/lib/modules' ]
  then
***************
*** 783,789 ****
  good_msg "Performing the network configuration..."
 
  # ---- force dhcp if booting via pxe and no static configuration specified
! if [ -n "${NETBOOT}" ]
  then
     if ! cat /proc/cmdline | busybox grep -q -E 'eth[x0-9]{1,2}=[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
     then
--- 813,819 ----
  good_msg "Performing the network configuration..."
 
  # ---- force dhcp if booting via pxe and no static configuration specified
! if [ -n "${NETBOOT}" ] || [ -n "${NBD_ROOT}" ]
  then
     if ! cat /proc/cmdline | busybox grep -q -E 'eth[x0-9]{1,2}=[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}'
     then
***************
*** 1128,1133 ****
--- 1161,1172 ----
     /bin/lvm vgchange -ay
  fi
 
+ # create the nbd device on demand
+ if [ -x /usr/sbin/nbd-client ] && [ -n "${NBD_ROOT}" ]
+ then
+    sysresccd_nbdboot # boot with nbd device
+ fi
+
  while true
  do
     while [ "${got_good_root}" != '1' ]
***************
*** 1217,1223 ****
           echo -n 'boot() :: '
           read REAL_ROOT
           got_good_root=0
!       elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "http" ] || [ "${REAL_ROOT}" = "tftp" ]
        then
           got_good_root=1
        else
--- 1256,1262 ----
           echo -n 'boot() :: '
           read REAL_ROOT
           got_good_root=0
!       elif [ -b "${REAL_ROOT}" ] || [ "${REAL_ROOT}" = "http" ] || [ "${REAL_ROOT}" = "tftp" ] || [ "${REAL_ROOT}" = "nbd" ]
        then
           got_good_root=1
        else
***************
*** 1228,1234 ****
        fi
     done
 
!    if [ "${CDROOT}" = '1' ] && [ "${got_good_root}" = '1' ]
     then
        # CD already mounted; no further checks necessary
        break
--- 1267,1273 ----
        fi
     done
 
!    if [ "${CDROOT}" = '1' ] && [ "${got_good_root}" = '1' ] || [ "${REAL_ROOT}" = "nbd" ]
     then
        # CD already mounted; no further checks necessary
        break
***************
*** 1505,1510 ****
--- 1544,1557 ----
     fi
  fi
 
+ # If cdroot is unset determine and nbdboot is define try to mount root
+ if [ ${CDROOT} = '0' ] && [ "${REAL_ROOT}" = "nbd" ]
+ then
+    mkdir /rwfs
+    mount -t tmpfs tmpfs /rwfs
+    mount -t aufs -o dirs=/rwfs=rw:/rofs=ro aufs ${NEW_ROOT}
+ fi
+
  verbose_kmsg
 
  # ------------------------------- chroot -------------------------------


So, for the nbd-server you can use a file ...
Code:
# /etc/nbd-server/config
[generic]
   user = nbd
   group = nbd
   listenaddr = 172.16.0.1
[partimage]
   exportname = /mnt/cdrom/sysrcd.dat
   port = 2000


... or a command
Code:
root@sysresccd /root % nbd-server 2000 /mnt/cdrom/sysrcd.dat


In the default file of /tftpboot/pxelinux.cfg/default you can find :
Code:
default rescuecd
append initrd=initram-nbd.igz  setkmap=fr nbdroot=172.16.0.1:2000


Copy necessary files to /tftpboot directory :
/mnt/cdrom/isolinux/rescuecd
/mnt/cdrom/isolinux/initram-nbd.igz

Configure and start the dhcp and tftp server

Start your thins-clients

@+


20 Feb 2010, 16:51
Profile WWW
Site Admin

Joined: 17 Jul 2003, 09:44
Posts: 2693
Post Re: netboot with NBD
Thanks for your contribution.

Boot from NBD will be useful for users who want to boot SystemRescueCd on a computer that has not enough memory to store a copy of sysrcd.dat during a network boot done with the default boot option. With NBD/NFS it's possible to boot from the network even if the client computer has less than 512 MB of RAM.

I have added all the requirements and modifications to SystemRescueCd-1.4.0-beta8.
There are modifications in the "init" script to make it simpler, and the boot option is called "nbdboot=ip:port" for consistency with the existing options.

For new users:
All you have to do is to install an NBD server somewhere on your network that provides a copy of "sysrcd.dat", and to boot SystemRescueCd-1.4.0-beta8 or more recent with the appropriate options ("nbdboot=ip:port" and the options such as "ethx" or "dodhcp") that are required to configure the network during the boot process. The client will configure its network, connect to the NBD server that provides sysrcd.dat, mount that file through the NBD device, and then complete the boot process.

You can read the Manual about booting from NBD for more details.


21 Feb 2010, 21:21
Profile

Joined: 17 Jun 2008, 08:05
Posts: 22
Location: Rumilly, France
Post Re: Booting SystemRescueCd from the network using NBD device
Hi,

For complete, I send you the modifications for automated the nbd server.

file /etc/conf.d/pxebootsrv
Code:
34a35,36
> # Set to "yes" if you want this machine to act as an NBD server
> PXEBOOTSRV_DONBD="yes"


file /etc/init.d/pxebootsrv
Code:
53a54,65
>    if [ $PXEBOOTSRV_DONBD != "yes" ] && [ $PXEBOOTSRV_DONBD != "no" ]
>    then
>       eerror "Invalid value for PXEBOOTSRV_DONBD. Must be \"yes\" or \"no\" (lowercase)."
>       return 1
>    fi
>
>    if [ $PXEBOOTSRV_DONBD = "yes" ] && [ $PXEBOOTSRV_DONFSD = "yes" ]
>    then
>       eerror "You must choice between NFS or NBD server."
>       return 1
>    fi
>
123a136,143
>    # ---- start the NBD server
>    if [ $PXEBOOTSRV_DONBD == "yes" ]
>    then
>       PXEBOOTSRV_DOHTTPD="no"
>       /usr/bin/nbd-server $PXEBOOTSRV_LOCALIP:2000 /tftpboot/sysrcd.dat -r
>       sed -i -e "s!scandelay=[1-9] netboot=[a-z=\/:\.0-9\/]*!scandelay=1 netboot=nbd://$PXEBOOTSRV_LOCALIP:2000!g" /tftpboot/pxelinux.cfg/default
>    fi
>


Bye,


29 Jul 2010, 12:24
Profile WWW
Site Admin

Joined: 17 Jul 2003, 09:44
Posts: 2693
Post Re: Booting SystemRescueCd from the network using NBD device
Thanks, change applied in sysresccd-1.6.0-beta


29 Jul 2010, 18:58
Profile

Joined: 01 Dec 2010, 08:07
Posts: 3
Post Re: Booting SystemRescueCd from the network using NBD device
well its great information for me.


01 Dec 2010, 08:19
Profile WWW
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 


Who is online

Users browsing this forum: No registered users and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by Vjacheslav Trushkin for Free Forums/DivisionCore.