DisklessUbuntuHowto


What is diskless booting?

Diskless booting is using a remote system or systems to store the kernel and the filesystem that will be used on other computer(s).

Why do it?

Imagine my case I admin about 25 public workstations for a local library, if they want something changed across the board I can either go sit at each PC and spend X minutes on it, adding up to who knows how many hours, or I can simply make the change at any one of the 25 systems and have it affect every system equally. The same goes for updates and many other operations. It really eases support issues.

How is this different than ThinClientHowto?

Thin clients use some of the same principles but they also connect to a remote X session, which means everything runs on the remote server – all applications will consume the servers resources, such as RAM and CPU cycles.

Diskless Booting simply uses the remote server for storage and still runs all applications on the local client station. This works better if you have full powered PC's to work with, and are working with a large number of clients that would require too much CPU and RAM to run all their applications on one server.

It is different enough to have multiple machines mounting the same root filesystem as opposed to simply being a remote monitor and keyboard to warrant a separate how-to I think.

Oliver Grawert says :- you could have achieved this easier by following the thin client howto, remove the ltsp-client package from the chroot and install ubuntu-desktop (or whatever desktop you want) there, would save you a lot of configuration work 😉

How does it work?

There are a lot of parallels to ThinClientHowto, diskless booting requires a DHCP server which a bootable PXE network card will query to get its configuration and location of the file to tftp from the server, after booting the PXE image the client will tftp and boot the kernel image(with args specified in the pxe config), those args will tell the kernel how to configure itself, and the path to mount the NFS share where its / directory is located.

Requirements

  • An Ubuntu system with (preferably) nfs-kernel-server and tftpd server (the server)
  • At least one PXE-bootable system (the client)
  • It helps to have the client set up in its final configuration before you start
  • Enough disk space on the server to hold the client filesystem
  • A fast network connection between the client and the server
  • A DHCP server which is capable of supporting PXE clients, or a separate network segment where you can run a dedicated DHCP server
  • A good understanding of Linux

Getting Started

Naming Conventions

Client: A diskless system that you wish to boot via a network connection
Server: An always-on system which will provide the neccesary files to allow the client to boot over the network

Set up your Server

  1. Install the required packages
    1. Ubuntu 14.04
      • sudo apt-get install isc-dhcp-server tftpd-hpa syslinux nfs-kernel-server initramfs-tools

    2. Ubuntu 14.10 and after
      • sudo apt-get install isc-dhcp-server tftpd-hpa syslinux pxelinux nfs-kernel-server initramfs-tools

  2. Configure your DHCP server

    You need to set up the DHCP server to offer /tftpboot/pxelinux.0 as a boot file as a minimum. You also assign a fixed IP to the machine you want to boot with PXE (the client). A range of other options are also available but are beyond the scope of this article. Your /etc/dhcp/dhcpd.conf might look like this assuming your subnet is 192.168.2.0

    allow booting; allow bootp;  subnet 192.168.2.0 netmask 255.255.255.0 {   range 192.168.2.xxx 192.168.2.xxx;   option broadcast-address 192.168.2.255;   option routers 192.168.2.xxx;   option domain-name-servers 192.168.2.xxx;    filename "/pxelinux.0"; }  # force the client to this ip for pxe. # This is only necessary assuming you want to send different images to different computers. host pxe_client {   hardware ethernet xx:xx:xx:xx:xx:xx;   fixed-address 192.168.2.xxx; }

    NOTE 1: You will need to replace the 'xx:xx:xx:xx:xx:xx' and the '192.168.2.xxx' with your own values
    NOTE 2: the filename is a relative path to the root of the tftp server.

    Restart DHCP Server using the command

    sudo service isc-dhcp-server restart

  3. Configure the TFTP Server

    We need to set tftp-hpa to run in daemon mode and to use /tftpboot as its root directory.
    Here is an example /etc/default/tftpd-hpa file

    #Defaults for tftpd-hpa RUN_DAEMON="yes" OPTIONS="-l -s /tftpboot"

  4. Configure your tftp root directory
    1. Create directories
      sudo mkdir -p /tftpboot/pxelinux.cfg

    2. Copy across bootfile
      1. Ubuntu 14.04:
        • sudo cp /usr/lib/syslinux/pxelinux.0 /tftpboot

      2. Ubuntu 14.10 and after:
        • sudo cp /usr/lib/PXELINUX/pxelinux.0 /tftpboot sudo mkdir -p /tftpboot/boot sudo cp -r /usr/lib/syslinux/modules/bios /tftpboot/boot/isolinux

    3. Create default configuration file /tftpboot/pxelinux.cfg/default
      LABEL linux KERNEL vmlinuz-2.6.15-23-686 APPEND root=/dev/nfs initrd=initrd.img-2.6.15-23-686 nfsroot=192.168.2.2:/nfsroot ip=dhcp rw

      NOTE1: your nfs server IP address, kernel name, and initrd name will likely be different. If you have a preconfigured system the names should be the names of the kernel and initrd (see below) on the client system
      NOTE2: to find the vmlinuz type uname -r
      NOTE3: There are more options available such as MAC or IP identification for multiple config files see syslinux/pxelinux documentation for help.
      NOTE4: Newer distributions might require that you append “,rw” to the end of the “nfsroot=” specification, to prevent a race in the Upstart version of the statd and portmap scripts.

    4. Set permissions
      sudo chmod -R 777 /tftpboot

      NOTE:If the files do not have the correct permissions you will receive a “File Not Found” or “Permission Denied” error.

    5. Start the tftp-hpa service:
      sudo /etc/init.d/tftpd-hpa start

  5. Configure OS root
    1. Create a directory to hold the OS files for the client
      sudo mkdir /nfsroot

    2. configure your /etc/exports to export your /nfsroot
      /nfsroot             192.168.2.xxx(rw,no_root_squash,async,insecure)

      NOTE: The '192.168.2.xxx' should be replaced with either the client IP or hostname for single installations, or wildcards to match the set of servers you are using.

      Note: In versions prior to Ubuntu 11.04 the option ',insecure' is not required after async.

    3. sync your exports
      sudo exportfs -rv

Creating your NFS installation

There are a few ways you can go about this:

  • debbootstrap (as outlined at Installation/OnNFSDrive)

  • copying the install from your server
  • install [lk]ubuntu on the client from CD, after you've got your system installed and working on the network mount the /nfsroot and copy everything from your working system to it.

This tutorial will focus on the last option. The commands in this section should be carried out on the client machine unless it is explicitly noted otherwise. You should ensure that the following package is installed on the client nfs-common

  1. Copy current kernel version to your home directory.
    • uname -r will print your kernel version, and ~ is shorthand for your home directory.

    sudo cp /boot/vmlinuz-`uname -r` ~

  2. Create an initrd.img file
    1. Change the BOOT flag to nfs in /etc/initramfs-tools/initramfs.conf

      # # 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

    2. Change the MODULES flag to netboot in /etc/initramfs-tools/initramfs.conf

      # # MODULES: [ most | netboot | dep | list ] # # most - Add all framebuffer, acpi, filesystem, and harddrive drivers. # # dep - Try and guess which modules to load. # # netboot - Add the base modules, network modules, but skip block devices. # # list - Only include modules from the 'additional modules' list #  MODULES=netboot

      NOTE: if you have anything in /etc/initramfs-tools/conf.d/driver-policy, this line will be ignored.

    3. Check which modules you will need for your network adapters and put their names into /etc/initramfs-tools/modules (for example forcedeth , r8169 or tulip)
    4. Run mkinitramfs
      mkinitramfs -o ~/initrd.img-`uname -r`

  3. Copy OS files to the server
    mount -t nfs -onolock 192.168.1.2:/nfsroot /mnt cp -ax /. /mnt/. cp -ax /dev/. /mnt/dev/.

    NOTE: If the client source installation you copied the files from should remain bootable and usable from local hard disk, restore the former BOOT=local and MODULES=most options you changed in /etc/initramfs-tools/initramfs.conf. Otherwise, the first time you update the kernel image on the originating installation, the initram will be built for network boot, giving you “can't open /tmp/net-eth0.conf” and “kernel panic”. Skip this step if you no longer need the source client installation.

  4. Copy kernel and initrd to tftp root.

    Run these commands ON THE SERVER

    sudo cp ~/vmlinuz-`uname -r` /tftpboot/ sudo cp ~/initrd.img-`uname -r` /tftpboot/

  5. Modify /nfsroot/etc/network/interfaces

    When booting over the network, the client will already have carried out a DHCP discovery before the OS is reached. For this reason you should ensure the OS does not try to reconfigure the interface later.
    You should set your network interface to be “manual” not “auto” or “dhcp”. Below is an example file.

    # 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

    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”)
    NOTE: If you use dnsmasq for your boot client (instead of dhcp), you will need to provide nameserver(s) information in /etc/resolvconf/resolv.conf.d/base. For instance,
    nameserver 192.168.0.xxx (You will need to replace the '192.168.0.xxx' with your own values.)

  6. Configure fstab

    /nfsroot/etc/fstab contains the information the client will use to mount file systems on boot, edit it to ensure it looks something like this ('note no swap')

    # /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 none            /tmp            tmpfs   defaults        0       0 none            /var/run        tmpfs   defaults        0       0 none            /var/lock       tmpfs   defaults        0       0 none            /var/tmp        tmpfs   defaults        0       0 /dev/hdc        /media/cdrom0   udf,iso9660 user,noauto 0       0

    NOTE: if you have entries for other tmpfs that's fine to leave them in there

  7. Disable Grub update

    Since diskless systems don't need grub to boot, disable update scripts to prevent glitches during further software updates. Comment out exec update-grub in /etc/kernel/postinst.d/zz-update-grub



Impactos: 0

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *