Novell Home

HOWTO: Convert Ubuntu to Diskless

From Developer Community

This article is for Ubuntu Dapper Drake, see Edgy/HOWTO: Convert Ubuntu to Diskless for Ubuntu Edgy Eft.


Contents

Introduction

Following Ubuntu's DisklessUbuntuHowto first you need to setup the pre-requisites.


  • NAS
  • DHCP & TFTP server or a みる directory server
  • PC with a temporary HDD with Ubuntu installed (HOWTO: Install Ubuntu)


Throughout this article the following IP addresses are going to be used, adjust appropriately for your network.

IP address          Description
10.30.2.1           Router and DNS server or proxy
10.30.2.2           DHCP and TFTP server
10.30.2.10          NFS server
10.30.2.20          LTSP server
10.30.2.100-200     LTSP clients

You will also need to find the MAC address of your Ubuntu machine, this can usually find this by viewing the BIOS startup messages when you first switch on your machine, or via the ifconfig command in Linux.

$ ifconfig
eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:10.30.2.20  Bcast:10.30.2.255  Mask:255.255.255.0
          inet6 addr: fe80::230:1bff:feb7:a209/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1
          RX packets:7431458 errors:0 dropped:0 overruns:0 frame:0
          TX packets:8036876 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000
          RX bytes:3120402141 (2.9 GiB)  TX bytes:3281854310 (3.0 GiB)
          Interrupt:169

lo        Link encap:Local Loopback
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:16436  Metric:1
          RX packets:186875 errors:0 dropped:0 overruns:0 frame:0
          TX packets:186875 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:0
          RX bytes:5422502 (5.1 MiB)  TX bytes:5422502 (5.1 MiB)


We will also assume that the NAS device is exporting a directory we are going to use as NFS root for the Ubuntu machine called /mnt/nfsroot.


Configure DHCP & TFTP

Without a local HDD the Ubuntu server needs network services to assign it an IP address, provide it a kernel, and provide a root network file system. The IP address is provided by dhcpd, the kernel by tftp, and the root file system by nfs.


Preparation

We need to prepare a small directory structure to copy to the TFTP server, all the files provided by TFTP usually reside in a directory /tftpboot, we will first create one in /tmp.

$ mkdir -p /tmp/tftpboot/pxelinux.cfg
$ mkdir /tmp/tftpboot/ubuntu-dapper

To copy the PXE boot image we first need to install the syslinux package.

$ sudo apt-get install syslinux
$ sudo cp /usr/lib/syslinux/pxelinux.0 /tmp/tftpboot

Lets find which Linux kernel version we have and copy it in.

$ ls -ltr /boot/vmlinuz-*
-rw-r--r-- 1 root root 1414477 2006-05-24 00:56 /boot/vmlinuz-2.6.15-23-386 
$ cp /boot/vmlinuz-* /tmp/tftpboot/ubuntu-dapper

The Linux kernel no longer provides support for a root filing system, it has to be implemented in user space. This is a relatively standard procedure and uses an "initial root disk" or initrd image. We have to create a new image that supports network booting. First we duplicate the initramfs configuration.

$ sudo cp -Rp /etc/mkinitramfs /etc/mkinitramfs-pxe

Modify /etc/mkinitramfs/initramfs.conf to change BOOT=local to BOOT=nfs

#
# BOOT: [ local | nfs ]
#
# local - Boot off of local media (harddrive, USB stick).
#
# nfs - Boot using an NFS drive as the root of the drive.
#

BOOT=nfs

Create a new initramfs image, replace the version numbers as appropriate.

$ sudo mkinitramfs -d /etc/mkinitramfs-pxe -o /tmp/tftpboot/ubuntu-dapper/initrd.img-2.6.15-23-386 2.6.15-23-386

Finally create a PXE configuration file, (Ctrl+D) escapes cat.

$ cat > /tmp/tftpboot/pxelinux.cfg/default
LABEL ubuntu
       kernel ubuntu-dapper/vmlinuz-2.6.15-23-386
       append root=/dev/nfs nfsroot=10.30.2.10:/mnt/nfsroot/ubuntu-dapper ip=dhcp initrd=ubuntu-dapper/initrd.img-2.6.15-23-386 rw  --

PROMPT 1
TIMEOUT 0


The next step depends if you have a ocean server setup or another Linux machine with dhcpd and tftpd.


みる directory server

Configure the LAN IP address to be 10.30.2.2 using the console setup. Access the webGUI using a webbrowser. Enable the SSH server so that the tftpboot directory can be copied over.


Enable SSH daemon with checkbox and save changes
Enlarge
Enable SSH daemon with checkbox and save changes


For DHCP you need to configure several items.

  1. Set the range of IP addresses for dynamic clients: 10.30.2.100 to 10.30.2.200
  2. Set the PXE boot filename: pxelinux.0
  3. Add a static mapping for the diskless Ubuntu server, this requires your MAC address and the IP address to use: 10.30.2.20


Enable SSH daemon with checkbox and save changes
Enlarge
Enable SSH daemon with checkbox and save changes


Enable the TFTP server.


Enable TFTP server with checkbox and save changes
Enlarge
Enable TFTP server with checkbox and save changes


Now using the web interface upload all the files in the tftpboot directory.


Now proceed to the next section: Migrate to NFS


dhcpd and atftp

Create a dhcp configuration file /etc/dhcp3/dhcpd.conf.

# dhcpd.conf

# The ddns-updates-style parameter controls whether or not the server will
# attempt to do a DNS update when a lease is confirmed. We default to the
# behavior of the version 2 packages ('none', since DHCP v2 didn't
# have support for DDNS.)
ddns-update-style none;

# option definitions common to all supported networks...
option domain-name "example.com";
option domain-name-servers 10.30.2.1;

default-lease-time 600;
max-lease-time 7200;

# If this DHCP server is the official DHCP server for the local
# network, the authoritative directive should be uncommented.
authoritative;

# Use this to send dhcp log messages to a different log file (you also
# have to hack syslog.conf to complete the redirection).
log-facility local7;

# ltsp server network
subnet 10.30.2.0 netmask 255.255.255.0 {
        range 10.30.2.100 10.30.2.200;
        option routers 10.30.2.1;
        filename "pxelinux.0";
        next-server 10.30.2.2;

# ubuntu server
        host ubuntu {
                hardware ethernet xx:xx:xx:xx:xx:xx; ➊
                fixed-address 10.30.2.20;
                option host-name "ubuntu";
        }
}

➊ Replace with the ethernet address of your Ubuntu host.


Update the atftpd configuration in /etc/default/atftpd

USE_INETD=false
OPTIONS="--daemon --port 69 --retry-timeout 5 --mcast-port 1758 --mcast-addr 239.239.239.0-255 
--mcast-ttl 1 --maxthread 100 --verbose=5  /tftpboot"

Copy the /tmp/tftpboot directory to your DHCP/TFTP server and start both daemons.


Migrate to NFS

Setup NFS Client

Ubuntu comes with a NFS client but it does not have locking functionality unless an extra package is installed. Without this package the NFS mount process can take a very long time unless locking is explicitly disabled.

$ sudo apt-get install nfs-client


Mount NFS Share

We use the mount command and specify the NFS server, exported share, and local directory we want the share to appear. This directory must already exist, /mnt is a covenient choice.

$ sudo mount 10.30.2.10:/mnt/nfsroot /mnt

For a FreeNAS file server you should now create a new sub-directory for ubuntu, this will save the root directory for other versions, backups, or other shared documents.

$ sudo mkdir /mnt/ubuntu-dapper


Copy HDD to NFS

A simply copy, we specify "-x" to only copy one file system, we do not want to copy NFS into itself.

$ sudo cp -ax /. /mnt/ubuntu-dapper/.
$ sudo cp -ax /dev/. /mnt/ubuntu-dapper/dev/.


Update fstab

The /etc/fstab file contains static information about all the mounted file systems, it is read at boot time after the kernel as finished loading. As there no longer is a HDD we need to specify NFS as the root file system.

# /etc/fstab: static file system information.
#
# <file system>                 <mount point>   <type>          <options>                       <dump>  <pass>
proc                            /proc           proc            defaults                        0       0
/dev/nfs                        /               nfs             defaults                        1       1

# removable media
/dev/hdc                        /media/cdrom0   udf,iso9660     user,noauto                     0       0
/dev/fd0                        /media/floppy0  auto            rw,user,noauto                  0       0


With Ubuntu Dapper /var/run and /var/lock are automatically tmpfs file systems, it is possible to mount /tmp and/or /var/tmp in tmpfs too like Solaris but this is not recommended by the Linux developers, and /var/tmp on tmpfs violates the LSB.

none                            /tmp            tmpfs           defaults                        0       0
none                            /var/tmp        tmpfs           defaults                        0       0


Update interfaces

As NFS is used for the root file system the network interface (NIC) has already been configured and running. This means we no longer need to configure that interface as part of the usual boot process. In fact we have to change the configuration or else we will loose the root file system. Remove the default interface from /etc/network/interfaces.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface, commented out for NFS root
#auto eth0
#iface eth0 inet dhcp


A little side note: for Ubuntu 7.04 (Feisty Fawn) it seems the /etc/network/interfaces needs a little tweak, in order *not* to have the NetworkManager fiddle with the interface since it's already configured (see also bug #111227 : "NFS-root support indirectly broken in Feisty")

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface, commented out for NFS root
#auto eth0
#iface eth0 inet dhcp
iface eth0 inet manual

works for me now...


Finished

Reboot and confirm everything is working.

Novell® Making IT Work As One

© 2008 Novell, Inc. All Rights Reserved.