GuestbookSign our guestbook ContactGet in touch with the authors ArchiveAll unixwerk articles since 2003
September 03, 2010

Setting up a Netinstall Server under Slackware

Contents

  1. Introduction
  2. Requirements
  3. Setting up DHCP
  4. Setting up TFTP
  5. Setting up NFS
  6. Installing Linux on a Client from the Netinstall Server
  7. Related Information

1. Introduction

Installing clients over the network rather than from CD/DVD is a common method in professional environments. For private use there never was a great benefit over installing from a physical media. But since netbooks become more and more popular booting and installing over network is an interesting option even for private use. That's because these computers often lack an integrated optical drive. On the other hand a network card is always there. This article shows how to create a netinstall server so you can install your netbook with Slackware or just boot a rescue linux image over the network.

2. Requirements

In order to build a Netinstall Server suitable for installing Linux over the network you need to setup three services:

3. Setting up DHCP

First we have to configure a basic /etc/dhcpd.conf:

# dhcpd.conf
#
# Configuration file for ISC dhcpd (see 'man dhcpd.conf')
#
authoritative;
ddns-update-style none;
allow bootp;

# Point to the TFTP server:
next-server 192.168.1.43;

# Default lease is 1 week (604800 sec.)
default-lease-time 604800;
# Max lease is 4 weeks (2419200 sec.)
max-lease-time 2419200;

subnet 192.168.1.0 netmask 255.255.255.0 {
    option domain-name "somedomain.net";
    option broadcast-address 192.168.1.255;
    option subnet-mask 255.255.255.0;
    option domain-name-servers 192.168.1.43;
    option routers 192.168.1.1;
    range dynamic-bootp 192.168.1.224 192.168.1.254;
    use-host-decl-names on;
    if substring (option vendor-class-identifier, 0, 9) = "PXEClient" {
      filename "/slackware-13.1/pxelinux.0";
    }
}

The above configuration is an example taken from my computer. It's for a network 192.168.1.0/24, a netinstall server with the IP 192.168.1.43, and a default gateway 192.168.1.1. The DHCP range is configured from 192.168.1.224 to 192.168.1.254. Adapt these values to your network and needs. The filename /slackware-13.1/pxelinux.0 is used for the TFTP server configuration below. Adapt it to your needs if you want.

Basically that's it for the DHCP server. Unfortunately Slackware doesn't provide a start script for dhcpd - so we have to start it manually:

instserver# touch /var/state/dhcp/dhcpd.leases
instserver# /usr/sbin/dhcpd -q eth0

Of course you want to put it into a small script /etc/rc.d/rc.dhcpd

#!/bin/sh
# Start/stop/restart the DHCP Server (dhcpd)
#
# Written for Slackware Linux by Erik Jan Tromp
# Added a touch to dhcpd.leases, aml 2010-09-03

dhcpd_start() {
  if [ -x /usr/sbin/dhcpd -a -f /etc/dhcpd.conf ]; then
    echo "Starting dhcpd:  /usr/sbin/dhcpd -q eth0"
    [ -e /var/state/dhcp/dhcpd.leases ] || touch /var/state/dhcp/dhcpd.leases
    /usr/sbin/dhcpd -q eth0
  fi
}

dhcpd_stop() {
  if [ -r /var/run/dhcpd.pid ] ; then
    kill `cat /var/run/dhcpd.pid`
  else
    killall dhcpd
  fi
}

dhcpd_restart() {
  dhcpd_stop
  sleep 1
  dhcpd_start
}

case "$1" in
'start')
  dhcpd_start
  ;;
'stop')
  dhcpd_stop
  ;;
'restart')
  dhcpd_restart
  ;;
*)
  echo "usage: $0 start|stop|restart"
  ;;
esac

4. Setting up TFTP

First we have to create a directory structure under /tftpboot

instserver# mkdir /tftpboot
instserver# mkdir /tftpboot/slackware-13.1
instserver# mkdir /tftpboot/slackware-13.1/pxelinux.cfg

Then we have to populate the directories with files from the Slackware CD. Assuming the Slackware CD is mounted under /media/cdrom we copy the following files to /tftpboot:

instserver# cp /usr/share/syslinux/pxelinux.0 /tftpboot/slackware-13.1
instserver# cp /media/cdrom/isolinux/message.txt /tftpboot/slackware-13.1
instserver# cp /media/cdrom/isolinux/f2.txt /tftpboot/slackware-13.1
instserver# cp -a /media/cdrom/kernels /tftpboot/slackware-13.1
instserver# cp /media/cdrom/usb-and-pxe-installers/pxelinux.cfg_default /tftpboot/slackware-13.1/pxelinux.cfg/default
instserver# cp /media/cdrom/isolinux/initrd.img /tftpboot/slackware-13.1 

Now that we have everything in place we can start the TFTP server. Since the TFTP server is started from the Internet Superdaemon, we uncomment the following line in /etc/inetd.conf:

tftp  dgram   udp     wait    root    /usr/sbin/in.tftpd  in.tftpd -s /tftpboot -r blksize

and start the service by sending a hangup signal to inetd ¹

instserver# killall -HUP inetd

Please note: On a default Slackware distribution the TFTP daemon is now ready to work. But if you ever configured the hosts access files hosts.deny and hosts.allow the TFTP daemon might refuse any connection. You can see this when you watch the file /var/log/syslog. If you see lines like

Sep  3 18:43:01 instserver in.tftpd[4507]: connection refused from 0.0.0.0
Sep  3 18:43:03 instserver in.tftpd[4509]: connection refused from 192.168.1.43
Sep  3 18:43:07 instserver in.tftpd[4510]: connection refused from 192.168.1.43
Sep  3 18:43:13 instserver in.tftpd[4511]: connection refused from 192.168.1.43
Sep  3 18:43:21 instserver in.tftpd[4512]: connection refused from 192.168.1.43
Sep  3 18:43:31 instserver in.tftpd[4513]: connection refused from 192.168.1.43
Sep  3 18:44:07 instserver in.tftpd[4516]: connection refused from 192.168.1.43
Sep  3 18:45:19 instserver in.tftpd[4607]: connection refused from 192.168.1.43
Sep  3 18:47:07 instserver in.tftpd[4669]: connection refused from 192.168.1.43

then probably your access rules prevent your client from connecting. To solve this add a line

in.tftpd: ALL

to /etc/hosts.allow.


¹ If on your system inetd is inactive run chmod +x /etc/rc.d/rc.inetd && /etc/rc.d/rc.inetd start instead.

5. Setting up NFS

First we have to find a place where we want to put the Slackware installation files, e.g. /export/slackware.13.1. We copy the installation files there (still assuming that the Slackware CD is mounted under /media/cdrom):

instserver# mkdir /export/slackware.13.1
instserver# cd /media/cdrom
instserver# cp -a * /export/slackware.13.1

Then we have to export the installation files to our client(s). So we add a line

/export/slackware.13.1       *(ro,sync,no_root_squash,subtree_check,insecure)

to /etc/exports and run exportfs to actually export it ²

instserver# exportfs -a


² If you don't use nfs yet run chmod +x /etc/rc.d/rc.nfsd && /etc/rc.d/rc.nfsd start instead.

6. Installing Linux on a Client from the Netinstall Server

In order to boot over network you have to make sure that your PXE boot capable network interface is the first boot device. Check the BIOS settings. Then just start your client computer. It should boot straight into the Slackware installer.

Login as root and start the Slackware installer as usual:

# setup

Map your keyboard, add your swap partition and set up your target partitions as if you would have booted from CD or DVD. When it comes to select your source media choose option

The installer tries to configure your network card via DHCP (what should succeed since we just configured the DHCP server). Then you have to answer some questions:

From now on there is no difference to a normal CD/DVD installation.

A. Related Information