SDB:Booting from the Network with GRUB

Şuraya atla: kullan, ara

Version: 8.1


You want to use the boot manager GRUB to load the files needed for booting from the network.


The following instructions are intended for experienced users. You should be familiar with rpm, tar, source packages compilation, and the configuration of network services, as well as with the boot loader GRUB (see SDB:The Boot Manager Grub

In the following example scenario, a Linux installation or a recovery system is loaded from the network. For this purpose, a GRUB boot floppy is used to start a client. The files that Linux requires for booting (kernel, initrd) are transferred by GRUB through the tftp protocol. All other files are transferred from a server via ftp or nfs.

It would also be possible to load a Linux operating system and to operate the client as a diskless client. This configuration exceeds the scope of this article, however.

Step 1: Recompilation of the GRUB Package

Since GRUB is compiled by default without network card support, it must be recompiled first. For this purpose, install GRUB's source package from the directory /suse/src from the DVD or CD (CD 7 in the Professional Edition, CD 3 in the Personal Edition) by way of the rpm command:

rpm -Uhv /media/cdrom/suse/src/grub-0.92-69.src.rpm

Then you will find a tarball in the directory /usr/src/packages/SOURCES/. The file netboot/README.netboot in this tarball contains the parameters to compile the support for each network card. Extract this file to the directory /tmp by executing a command similar to the following one (you might have to adjust the GRUB package's version number):

tar -xOjf /usr/src/packages/SOURCES/grub-0.92.tar.bz2 grub-*/netboot/README.netboot >/tmp/README.netboot

For example, for an Intel Ethernet Pro 100 the parameter "--enable-eepro100" is required. It is advisable to activate only the drivers that are actually required, because too many compiled network card drivers might make GRUB crash.

Edit the spec file at /usr/src/packages/SPECS/grub.spec with an ASCII editor of your choice and insert the parameter for your network card support. For example:

%ifarch x86_64
  export CC='cc -m32'
-Wpointer-arith -fno-asynchronous-unwind-tables"  
./configure \
--prefix=/usr --infodir=%{_infodir} --mandir=%{_mandir} --datadir=/usr/lib/grub \
--disable-auto-linux-mem-opt --enable-diskless --enable-eepro100
  CFLAGS="$CFLAGS $RPM_OPT_FLAGS -DNDEBUG -W -Wall -Wpointer-arith" 
./configure    --prefix=/usr --infodir=%{_infodir} --mandir=%{_mandir} --datadir=/usr/lib/grub \ 
--disable-auto-linux-mem-opt --enable-diskless --enable-eepro100

Increase the release number at the top of the spec file, e.g.:

Release:      70

Then save the spec file and recompile:

rpm -bb /usr/src/packages/SPECS/grub.spec

and install the package:

rpm -Uhv /usr/src/packages/RPMS/i386/grub-0.92-70.i386.rpm

Now create a GRUB boot floppy as follows:

cd /usr/lib/grub/
dd if=stage1 of=/dev/fd0
dd if=stage2 of=/dev/fd0 seek=1

By executing these commands, GRUB's first and second level are directly written on a floppy disk in block form.

Step 2: Network Services Configuration

GRUB supports the file load from the network by means of the tftp protocol. For this purpose, install the package atftp on your Linux server. Create the directory /tftpboot in which to store the files of the tftp server then copy the kernel (file boot/loader/linux) and the initrd (file boot/loader/initrd) to this directory from the first installation CD or the DVD. To activate the tftp server, edit the file /etc/inetd.conf by inserting the following line:

tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/atftpd /tftpboot

The rescue system can be installed or loaded via ftp or nfs. The following lines describe the configuration of an FTP server. Install the packages vsftpd and ftpdir. To activate the FTP server, edit the file /etc/inetd.conf: remove the comment line from the entry

ftp stream tcp nowait root /usr/sbin/tcpd vsftpd

Activate the inetd by executing

rcinetd start

You can use the command insserv inetd or the runlevel editor to make inetd start automatically at the boot process. For more information about the configuration of server services, refer to the administration manual.

To release SuSE installation files for share, copy the content of the CD or DVD to the directory /srv/ftp/pub or to a subdirectory. Alternatively, the DVD or the first CD can be mounted at the mount point /srv/ftp/pub:

mount -t iso9660 -o ro /dev/cdrom /srv/ftp/pub/

Step 3: Testing the GRUB Boot Floppy on the Client

Start the client with the GRUB boot floppy. A sort of prompt will be displayed:

grub >

Inform GRUB about the client IP address, netmask, and server address with:

grub > ifconfig --address= --mask= --server=

If a DHCP, BOOTP, or RARP server is running on the server, you can automatically allocate the IP address, for example with the following command in the case of DHCP:

grub > dhcp

In the next step, inform GRUB that the boot files must be loaded from the network (nd stands for "network drive"):

grub > root (nd)

Now the kernel will be loaded. The installation source is provided to linuxrc by means of an additional parameter:

grub > kernel /linux install=

The kernel linux is loaded from the root directory of the tftp server. The installation files loaded via ftp from the directory /pub on the server with the IP

To load SuSE rescue system instead of the installation, append the parameter rescue=1 to the line. If the files should be loaded via NFS, the syntax is install=nfs://server/directory/. For some network cards, it might be necessary to load the network card module explicitly to start linuxrc. In this case, add the parameter insmod=module_name, replacing module_name with the corresponding kernel module. For example, for an Intel EtherExpress PRO/100:

grub > kernel /linux insmod=e100 install=

If the package linuxrc is installed, find additional parameters for the installation in the file [file:///usr/share/doc/packages/linuxrc/linuxrc.html usr/share/doc/packages/linuxrc/linuxrc.html].

The initrd is loaded after the kernel:

grub > initrd /initrd

Finally, boot the system with the command

grub > boot

If everything has been correctly configured, the installation or the rescue system should start now.

Step 4: Simplification of the Client Boot Process by Creating a Menu

To avoid having to enter every command separately, a menu can be loaded from the network. For this purpose, copy the files /boot/message and /boot/grub/menu.lst to the directory /tftpboot on the server so they can be loaded by GRUB via the tftp protocol. Adapt the file /tftpboot/menu.lst to your system according to the example below:

gfxmenu (nd)/message
color white/blue black/light-gray
default 1
timeout 8
title SuSE Linux Installation
   kernel (nd)/linux insmod=e100 install=
   initrd (nd)/initrd
title SuSE Linux Rescue System
   kernel (nd)/linux insmod=e100 install= rescue=1
   initrd (nd)/initrd
title Booting from local hard disk
   root (hd0)
   chainloader +1

Boot the client with GRUB boot floppy and configure the network by executing the usual ifconfig command:

grub > ifconfig --address= --mask= --server=

or by means of:

grub > dhcp

To load the menu, enter:

grub > configfile (nd)/menu.lst

Now, view the ordinary SuSE boot menu in which to select the requested option.

Step 5: Further Simplification of the Boot Process

This process can be simplified even more by saving the menu on the floppy disk, so the menu will be automatically loaded, rendering unnecessary any input from the user. Making a boot floppy is a little more complex now. First, a file system must be created on the floppy:

earth:~ # mke2fs -m 0 /dev/fd0

The floppy must be mounted so the necessary boot files can be copied:

earth:~ # mount /media/floppy/
earth:~ # cp /usr/lib/grub/stage1 /usr/lib/grub/stage2 /media/floppy/

Copy the file /tftboot/menu.lst previously created to the floppy. Adjust the newly-created file /media/floppy/menu.lst by inserting the network configuration at the top of the file (the dhcp or ifconfig command):

gfxmenu (nd)/message
color white/blue black/light-gray
default 1
timeout 8
title SuSE Linux Installation
   kernel (nd)/linux insmod=e100 install=
   initrd (nd)/initrd
title SuSE Linux Rescue System
   kernel (nd)/linux insmod=e100 install= rescue=1
   initrd (nd)/initrd
title Booting from local hard disk
   root (hd0)
   chainloader +1

To make the boot floppy bootable, enter the command grub in a shell:

earth:~ # grub

Now you are in a grub shell. By executing the following command, the file stage1 located on the floppy will be written to the floppy's boot sector. stage2 and the configuration file menu.lst, both also located on the floppy, are passed as parameters:

grub > install (fd0)/stage1 (fd0) (fd0)/stage2 p (fd0)/menu.lst

Quit the grub shell with:

grub > quit

Then unmount the floppy:

earth:~ # umount /media/floppy

If everything has worked, the configuration will be completely loaded from the floppy during the boot process.

For additional information about GRUB, refer to View the same information on your installed system by executing the command info grub in a shell. If the kernel sources are installed (package kernel-source), refer to the file [file:///usr/src/linux/Documentation/nfsroot.txt /usr/src/linux/Documentation/nfsroot.txt] for more information about a Linux start as a diskless client (kernel parameter to boot from NFS).

This subject exceeds the scope of the free-of-charge installation support.

SDB:The Boot Manager Grub