Linux diskless boot method detailed

  

diskless boot everyone should have heard of it, and now many Internet cafes and enterprises have used this technology, but those diskless systems are mostly windows, today I will introduce to you Linux diskless boot method.

Diskless boot means that a client computer
does not have any disk storage media when booting the operating system
. In this case, the computer
can load the kernel and root file system from the remote NFS server over the network. In this process, a variety of different methods may be used to load the kernel and root file system from the NFS server: RARP, BOOTP or DHCP. In this tutorial

, I will use the BOOTP/DHCP protocol because they are supported by most network cards.


The advantages of a diskless computer Imagine having 30 computers in your office, each of which requires the same application. What do you do if you are the administrator of managing these computers? If you install the application on every computer, it is just wasting your time. On the other hand, a diskless system can solve your problem. With a diskless system, you only need to install the required programs on the central NFS server and then boot the 30 clients over the network. What two or more Linux computers are required to be equipped with a DHCP-enabled network card. These computers that will play the role of NFS server should be equipped with hard disks, and other clients do not need any hard disks. Servers and clients need to be connected to the same local network. It takes a total of five steps to set up a diskless system. Installing the required package configuration TFTP server configuration DHCP server configuration NFS server startup diskless client In this tutorial, I assume that the computer running the server is Ubuntu. How you are using other Linux distributions, the principle is the same. Step 1: Install the required packages Use the apt-get command to install all the required packages like this. $ sudo apt-get install dhcp3-server tftpd-hpa syslinux nfs-kernel-server initramfs-tools Step 2: Configure the TFTP server The TFTP server is a small FTP server that needs to be used by clients and servers on the local network. The startup file is automatically transferred between. Add the following line to /etc/default/tftpd-hpa: RUN_DAEMON=”yes”OPTIONS=”-l -s /var/lib/tftpboot/” Next, create a startup folder. $ sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg Copy the bootloader image. $ sudo cp /usr/lib/syslinux/pxelinux.0 /var/lib/tftpboot Create a default startup configuration file like this. $ sudo vi /tftpboot/pxelinux.cfg/defaultLABEL UbuntuKERNEL vmlinuzAPPEND root=/dev/nfs initrd=initrd.img nfsroot=10.10.101.1:/nfsroot ip=dhcp rw Note: “root=/dev/nfs” indicates on the server Network file system (no need to modify). “initrd=initrd.img” is a startup script for system startup. “nfsroot=10.10.101.1/nfsroot” indicates the IP address of the server and the name of the NFS shared folder. Replace the IP address with your server address. “ip=dhcp” indicates that the client computer uses a DHCP addressing scheme. “rw” indicates that the NFS share is readable/writable. Finally, restart the TFTPD service. Sudo /etc/init.d/tftpd-hpa restart Step 3: Configure the DHCP service You also need to configure the DHCP service on the NFS server to allow booting with /var/lib/tftpboot/pxelinux.0. Assuming you are using 10.10.101.0 as a subnet, your configuration might look like this. $ sudo vi /etc/dhcp3/dhcpd.confallow booting;allow bootp;subnet 10.10.101.0 netmask 255.255.255.0 {range 10.10.101.2 10.10.101.254;option broadcast-address 10.10.101.255;option routers 10.10.101.1;filename “ /pxelinux.0″;} Then restart the DHCP service. $ sudo service isc-dhcp-server restart Step 4: Configure the NFS server to create a folder to save the client root file system directory. $ sudo mkdir /nfsroot Next, set up the NFS server to export the client root file system. Add the following line to /etc/exports to implement. /nfsroot *(rw,no_root_squash,async,insecure,no_subtree_check) Run the following command to reload the modified /etc/exports. $ sudo exportfs -rv By default, Ubuntu does not provide network boot support in the initrd image. So you need to create a new initrd.img file. First add the following line to /etc/initramfs-tools/initramfs.conf. BOOT=nfsMODULES=netboot Then run the following command to create a new initrd.img. $ sudo mkinitramfs -o /var/lib/tftpboot/initrd.img Copy the new kernel image file to /var/lib/tftpboot. $ sudo cp /boot/vmlinuz-`uname -r` /var/lib/tfftpboot/vmlinuz It's time to copy the entire root filesystem to /nfsroot. Assuming you are using a brand new Ubuntu server installation, you only need to copy the file system to the root of NFS. $ sudo cp -ax //nfsroot Then open /nfsroot/etc/fstab in a text editor and add the following line. /dev/nfs /nfs defaults 1 1 folder /var/lib/tftpboot should have global read and write permissions. Otherwise the client cannot boot from the network. $ sudo chmod -R 777 /var/lib/tfftpboot Finally, in order to avoid any server setup errors, I recommend using a static IP for the NIC running the DHCP service. For example, if the NIC is named eth0, your configuration in /etc/network/interfaces should look like this: iface eth0 inet staticaddress 10.10.101.1netmask 255.255.255.0broadcast 10.10.101.255network 10.10.101.0 Step 5: Start the diskless client After starting your configuration on the server, boot your client from the network. To boot from the network, you only need to modify the boot priority in the BIOS settings. If the client is successfully booted, your diskless environment is configured. You can add one or more client computers at will without any modifications.

Copyright © Windows knowledge All Rights Reserved