Previous | Next | Table of Contents

Introduction (i386-specific), Diskless NetBSD HOW-TO

There are several ways to load the NetBSD kernel for 'diskless' operation:

  1. Via netboot rom

    You will need a BIOS supporting boot from network and a matching network card. This is becoming more popular in new PCs, especially ones with build in network adapters. Setup a server on the network (see diskless(8)) and modify your BIOS settings to try the network boot first.

    If your BIOS does not support this, but you have a network card supported by NetBSD's 'netboot' bootloader, you can boot to DOS (see the discussion about below) and use '' to load your kernel over the network. To generate a suitable '' cd to /usr/src/sys/arch/i386/stand/netboot, edit the Makefile to define the options for your network adapter and run "make".

  2. Via PXE

    If your hardware is capable of netbooting using PXE, it first tries to acquire an IP address using the Dynamic Host Configuration protocol (DHCP). The dhcpd server uses the ethernet address (MAC) of the client machine to determine its IP address and a bootloader filename. If this request is successful, PXE expects to be able to download a second-stage boot program via the Trivial File Transfer Protocol (TFTP). It will do this by setting up a TFTP connection to the server that answered the earlier DHCP request, and asking for the file name returned by the server. The second-stage boot program then loads the kernel using NFS from the server and path specified by the DHCP request.

    There are two PXE bootloader files available in the /usr/mdec/ directory of base.tgz from the NetBSD distribution. pxeboot_ia32.bin should be used for most cases, since pxeboot_ia32_com0.bin will force the client to use its first serial port as the console. The serial console PXE file may be necessary for embedded systems (such as the Soekris line of hardware) which only have a serial console. Use 9600 8N1 settings.

    Something like the following can be used in /etc/dhcpd.conf:

    host pxehost {
      hardware ethernet 01:23:45:67:89:ab;       # MAC address of PXE host
      fixed-address;               # IP address of PXE host
      # stage 1: 
      filename "pxeboot_ia32.bin";               # relative to /tftpboot
      # stage 2:
      next-server;                  # IP of NFS server
      option root-path "/usr/tmp/pxestuff/root"; # path on NFS server

    As a shortcut, if you have a lot of PXE systems, you can set up /etc/dhcpd.conf to group them all together:

    class "pxe-clients-ia32" {
            match if substring (option vendor-class-identifier, 0, 20)
                     = "PXEClient:Arch:00000";
            filename "pxeboot_ia32_com0.bin";

  3. Via GRUB

    GRUB is a boot loader, that is capable of booting different OS types and some of them via network. GRUB itself is loaded from disk or network using a PXE or NBI (such as Etherboot) loader. Etherboot & GRUB supports many different NICs, more than the NetBSD's 'netboot' bootloader does. Note you'd need to use GRUB version 0.90 or later. GRUB and Etherboot require GCC and GNU Binutils 2.9.1 or later. They can be compiled on any system, they don't need to be compiled on NetBSD host.

    You'd need to setup environment so that EtherBoot would load and execute appropriate GRUB image, and configure GRUB so that it would load NetBSD kernel. The necessary steps are outlined below.

    1. Put appropriate EtherBoot EPROM image to your EPROM.
    2. Build GRUB 0.90. You need to configure it with options --enable-diskless and --enable-* appropriate for your NIC
    3. Put built GRUB stage2/nbgrub image on TFTP server.
    4. Configure dhcpd for the diskless machine, dhcpd entry could look like this:
       option option-150 code 150 = text;
       group {
        subnet netmask {
          option log-servers;
          option domain-name-servers;
          # location of GRUB configuration file
          option option-150 "/tftpboot/grub.conf";
          # NFS root path
          option root-path "/home/dolecek/netbsd-root";
          # path of image EtherBoot should load and execute
          filename "/tftpboot/nbgrub";
        host foobar { fixed-address foobar; hardware ethernet 00:c0:6c:76:17:46; }
    5. Create configuration file for GRUB and put it on TFTP server as configured in option-150 of dhcpd. An example configuration for NetBSD follows.
      # uncomment following two lines to use serial terminal
      # serial --unit=0 --speed=57600
      # terminal --timeout=0 serial
      # Boot automatically after 5 secs.
      timeout 5
      # By default, boot the first entry.
      default 0
      # Fallback to the first entry.
      fallback 0
      # For booting the NetBSD
      title NetBSD
      kernel --type=netbsd /tftpboot/netbsd
    6. GRUB doesn't pass boot information to NetBSD. Thus, if you want to be able to autoboot NetBSD, you'd need to configure kernel's root explicitly, like:
      config netbsd root on ? type nfs
      Then, build the kernel and put it on TFTP server as configured in GRUB configuration file.
    7. If you want to use serial console, you'd need to configure both GRUB and kernel to use it. To use serial line for GRUB, uncomment the serial and terminal entries in above example GRUB configuration. To use serial line as NetBSD console, add option like
      options "CONSDEVNAME=\"com\"",CONADDR=0x2f8,CONSPEED=57600
      to your kernel configuration.
    8. That should be it!

  4. From floppy disk

    The kernel on the floppy may be configured to mount the root filesystem over the network by using this in your kernel config file:

    	config netbsd root on ? type nfs
    If you have not compiled a kernel before you should see the notes on how to build a kernel.

  5. Via "" for DOS or Windows (not NT)

    NetBSD compiles a special version of the bootloader into a small DOS program, called "". This is located in /usr/mdec on installed systems or in the base.tgz set. To use, copy both and your kernel onto a FAT (msdos) partition, and boot to DOS.

    • Windows 95 or 98

      Press F8 while the string "Loading Windows XX" is displayed to enter the boot menu. The menu items displayed there will depend on your installation.

      You may need to avoid loading the HIMEM.SYS driver and the EMM386.SYS driver. In this case choose "Step-by-step confirmation" and answer all questions with "n" or ESC.

      If you don't mind HIMEM.SYS getting loaded, choose "Command prompt only".

    • DOS or Windows 3.1

      Hold down the SHIFT key when the computer is booting to skip config.sys and autoexec.bat.

    At the DOS prompt, change into the directory where you have put "" and the kernel. Enter "dosboot" to boot "netbsd", or "dosboot filename" if your kernel file has a different name.

    The dosboot utility is able to handle extended memory, as provided by the HIMEM.SYS driver. Unfortunately this gets into the way if NetBSD is going to make calls to the APM BIOS. There is no problem if you don't have an APM BIOS, or your NetBSD kernel does not use it (no "apm0 at mainbus0"). If you are going to use APM, don't load HIMEM.SYS when using dosboot.

    If you wish to create a customised version of, cd to /usr/src/sys/arch/i386/stand/dosboot, edit the Makefile for special options (serial console, ...) and run "make".

  6. Via the NT boot selector

    NT's boot selector can be used to directly bootstrap NetBSD. For more details see the Adding NetBSD to the Windows NT boot menu section in the NetBSD/i386 FAQ.

Begin setting things up (suggested order):

  1. dhcpd
  2. tftpd (PXE)
  3. nfs
  4. client filesystem
  5. finishing up

Previous | Next | Table of Contents
NetBSD Home Page
NetBSD Documentation top level

(Contact us) $NetBSD: intro.i386.html,v 1.4 2007/08/01 15:36:02 kano Exp $
Copyright © 1998-2004 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.