Network Booting Ubuntu using iPXE and NFS

                                

Network Booting

Using iPXE & NFS


Network Booting is a cool technique to boot the operating system in your machine from the network rather than the local hard drive. For example, in the above picture on the right is a desktop machine that does not have any hard drive, on the left we have a laptop. From the laptop, we will serve an OS over the network and the desktop machine will boot & run the OS completely over the network. The router will create the local network and act as a DHCP server. We will use iPXE & NFS mechanisms to do this. if you are interested to learn about the process in depth you can follow this link https://networkboot.org/fundamentals/ 


We will boot the Ubuntu 16.04.3 desktop version so firstly download the OS from http://releases.ubuntu.com/ and extract it. I am sharing my hands-on experience so my paths won't exactly match yours. My Host machine, which is the laptop in this case, is also running Ubuntu 16.04.3 desktop edition. 


First, install the dependencies 

~/diskless-node-pxe-setup$ sudo apt-get install liblzma-dev


Git clone the iPXE project’s source 

~/diskless-node-pxe-setup$ git clone git://git.ipxe.org/ipxe.git


~/diskless-node-pxe-setup$cd ipxe/src


Build the ROM for USB [for initial build test, later we will make the actual ROM] 

~/diskless-node-pxe-setup/ipxe/src$ make bin/ipxe.usb


We will use the NFS service to serve the OS so our host machine needs to have it 

Install NFS kernel Server 

~$sudo apt-get install rpcbind nfs-kernel-server


Open this file using gedit 

~$sudo gedit /etc/exports


Write the path of the extracted OS at the bottom of the file 

/home/hassin/Downloads/ubuntu-16.04.3-desktop-amd64     *(ro,async,no_wdelay,insecure_locks,no_root_squash,insecure,no_subtree_check)


Add NFS support to the PXE ROM 

~/diskless-node-pxe-setup/ipxe/src$ echo "#define DOWNLOAD_PROTO_NFS" >> config/local/general.h


Add script support to the ROM 

Open this file “ipxe/src/config/local/general.h

The IMAGE_SCRIPT macro should be defined [ not commented out] 


Take note of your host machine IP,

~$ ifconfig

for my machine, it was 192.168.0.100 


Create a script 

~/diskless-node-pxe-setup/ipxe-scripts$ cat > ubuntu16-live.ipxe


Open the script 

~/diskless-node-pxe-setup/ipxe-scripts$ gedit ubuntu16-live.ipxe


Add the following lines 

echo Hi, trying to boot ubuntu16-live
set server_ip 192.168.0.100
set nfs_path /home/ayx/Downloads/ubuntu-16.04.3-desktop-amd64
kernel nfs://${server_ip}${nfs_path}/casper/vmlinuz.efi || read void
initrd nfs://${server_ip}${nfs_path}/casper/initrd.lz || read void
imgargs vmlinuz.efi initrd=initrd.lz root=/dev/nfs boot=casper netboot=nfs nfsroot=${server_ip}:${nfs_path} ip=dhcp splash quiet -- || read void
boot || read void
echo Booting

Save it 


Now make the ROM by embedding the script 

~/diskless-node-pxe-setup/ipxe/src$ make bin/ipxe.usb EMBED=../../ipxe-scripts/ubuntu16-live.ipxe


Insert a pen drive, take note of its drive letter using the “Disks” utility app of ubuntu 

For my case, it was sdb 


~/diskless-node-pxe-setup/ipxe/src$ sudo dd if=bin/ipxe.usb of=/dev/sdb


Export the NFS shares of your host machine 

~$sudo exportfs -ra


Restart NFS-kernel-server 

~$sudo /etc/init.d/nfs-kernel-server restart


Remove the pen-drive , insert it into the desktop machine 

Make sure USB from the boot is enabled, 

Now everything okay then you will be able to use ubuntu over the network 


1 comment:

  1. JAVA303 Casino Online - JM Hub
    JAVA303 Casino Online. 구리 출장안마 JAVA303 Casino is 전주 출장샵 operated 천안 출장샵 by a Malta-based casino company with a gambling license in 안양 출장마사지 Malta. The casino is certified by 영천 출장안마 the Malta Gaming

    ReplyDelete

Categories

Pages

Firmware Engineer

My photo
Works on Firmware, Embedded Linux, Smart Metering, RTOS, IoT backend

Contact Form

Name

Email *

Message *

Copyrighted by Hassin. Powered by Blogger.