Linux disk less system

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 computers.

What’s goodness ?

When you setup your own site servers, what’s needed ?

  1. DNS server(s).
  2. mail server(s).
  3. http server(s).
  4. storage system (nas).
  5. Development Workstations.

How many disk drive do you need ?

The answer is “Only One Drive” for minimum.

Setup Server

# apt install isc-dhcp-server tftpd-hpa syslinux pxelinux nfs-kernel-server initramfs-tools debootstrap

install packages dhcp server, tftp server, nfs server, pxe support files, and nfs boot files.

 

Setup DHCP Server

 

The isc-dhcp-server package is recommended. Here is a sample configuration file for it (see /etc/dhcp/dhcpd.conf):

option domain-name "example.com";
option domain-name-servers ns1.example.com;
option subnet-mask 255.255.255.0;
default-lease-time 600;
max-lease-time 7200;
server-name "servername";

subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.200 192.168.1.253;
option routers 192.168.1.1;
}

host j1900 {
# client mac address
 hardware ethernet 01:23:45:67:89:ab;
# client IP
 fixed-address 192.168.1.20;
# option can be set host-name,routers and so on.
 option host-name "pxe1";
 filename "pxelinux.0";
# tftp server IP, if not set tftp server is same IP as this dhcp server.
 next-server 192.168.16.7;
}

 

Setup tftp Server

  1. /etc/default/tftpd-hpa can be changed, if  want to change tftp root directory and so on.
    # /etc/default/tftpd-hpa
    
    TFTP_USERNAME="tftp"
    TFTP_DIRECTORY="/var/lib/tftpboot"
    TFTP_ADDRESS=":69"
    TFTP_OPTIONS="--secure"
  2. pxelinux is a Syslinux derivative, for booting Linux off a network
    server, using a network ROM conforming to the Intel PXE (Pre-Execution
    Environment) specification. *PXELINUX* is _*not*_ a program that is
    intended to be flashed or burned into a PROM on the network card; if
    you want that, check out Etherboot (http://www.etherboot.org/).
    Etherboot 5.4 or later can also be used to create a PXE-compliant boot
    PROM for many network cards. PXELINUX generally requires that full file pathnames are 127 characters or shorter in length.
  3. After attempting the file as specified in the DHCP or
    hardcoded options, PXELINUX will probe the following paths, prefixed
    with “pxelinux.cfg/”, under the initial current working directory:- The client UUID if provided by the PXE stack (note, some BIOSes don’t
    have a valid UUID, and you might end up with something like all 1’s.)
    This is in the standard UUID format using lower case hexadecimal digits,
    e.g. b8945908-d6a6-41a9-611d-74a6ab80b83d.- The hardware type (using its ARP type code) and address, all in lower
    case hexadecimal with dash separators; for example, for an Ethernet (ARP
    type 1) with address 88:99:AA:BB:CC:DD it would search for the filename
    01-88-99-aa-bb-cc-dd.

Example pxelinux.cfg/default

including fixed mac address configuration  such as ’01-88-99-aa-bb-cc-dd’.

LABEL linux
KERNEL vmlinuz-4.10.0-38-generic
APPEND root=/dev/nfs initrd=initrd.img-4.10.0-38-generic nfsroot=192.168.2.2:/nfsroot ip=dhcp rw

 

DHCP

DHCP is good choice easy to setup tftp sever setting.

ip=dhcp

 

Static IP

As described in #175324 ipconfig have problems with DHCP relays. Static IP is configured by parameter:

ip=<client-ip>:<server-ip>:<gw-ip>:<netmask>:<hostname>:<device>:<autoconf>
  1. <client-ip> IP address of the client. If empty, the address will

    1. either be determined by RARP/BOOTP/DHCP. What protocol

      is used de- pends on the <autoconf> parameter. If this parameter is not empty, autoconf will be used.

  2. <server-ip> IP address of the NFS server. If RARP is used to

    1. determine the client address and this parameter is NOT empty only replies from the specified server are accepted. To use different RARP and NFS server, specify your RARP server here (or leave it blank), and specify your NFS server in the `nfsroot’ parameter (see above). If this entry is blank the address of the server is used which answered the RARP/BOOTP/DHCP request.

  3. <gw-ip> IP address of a gateway if the server is on a different

    1. subnet. If this entry is empty no gateway is used and the server is assumed to be on the local network, unless a value has been received by BOOTP/DHCP.

  4. <netmask> Netmask for local network interface. If this is empty,

    1. the netmask is derived from the client IP address assuming classful addressing, unless overridden in BOOTP/DHCP reply.

  5. <hostname> Name of the client. If empty, the client IP address is

    1. used in ASCII notation, or the value received by BOOTP/DHCP.

  6. <device> Name of network device to use. If this is empty, all

    1. devices are used for RARP/BOOTP/DHCP requests, and the first one we receive a reply on is configured. If you have only one device, you can safely leave this blank.

  7. <autoconf> Method to use for autoconfiguration. If this is either

    1. ‘rarp’, ‘bootp’, or ‘dhcp’ the specified protocol is used. If the value is ‘both’, ‘all’ or empty, all protocols are used. ‘off’, ‘static’ or ‘none’ means no autoconfiguration.

 

Make root directory on NFS

1-1 make root file on nfs.

If export NFS is /srv/nas.

# mkdir /srv/nas/pxeroot

root directory name is your choice, pxeroot , hostname and so on.

 

# cd /srv/nas/pxeroot

# mknfsroot-file xenial /srv/nas/pxeroot user password

You can wget mknfsroot-file script from http://ntools.net/arc/nodisk/.

Of cause modify nfs root(srv/nas/pxeboot , user name(user) and password.

 

New machine configuration.

Adding a swap file and fix timezone

In case you do need or want to set up a swapfile, here’s what I did to get one working:

$ sudo apt-get install dphys-swapfile

this package sets up a swap file at /var/swap that is 2x your current ram. however, it still doesn’t setup the swapfile on its own, though it does try. to get the swap file working the rest of the way, do:

$ sudo vi /etc/dphys-swapfile

Edit ‘/etc/dphys-swapfile’ . If your PC memory capacity is 4G or more, should be fix ‘CONF_SWAPFACTOR=1’ and ‘CONF_MAXSWAP=xxxx’. xxxx is 8192 (8G), 16384(16G) and so on.

After fix ‘/etc/dphys-swapfile’,

$ sudo systemctl restart dphys-swapfile.service

Timezone change to somethin.

$ sudo dpkg-reconfigure tzdata

Download

pxelinux.0 including syslinux package tar.gz.

mknfsroot-file script.

http://ntools.net/arc/nodisk/