Differences

This shows you the differences between two versions of the page.

Link to this comparison view

en:linux:diskless_pxe_nfs [2020/05/06 04:00]
alex created
en:linux:diskless_pxe_nfs [2020/05/06 04:08] (current)
alex
Line 11: Line 11:
 Install necessary packages Install necessary packages
  
 +<​code>​
 # apt install isc-dhcp-server tftpd-hpa pxelinux nfs-kernel-server debootstrap # apt install isc-dhcp-server tftpd-hpa pxelinux nfs-kernel-server debootstrap
 +</​code>​
  
 Configure network interface (ref: [[https://​help.ubuntu.com/​lts/​serverguide/​network-configuration.html.en]]). ​ In this case, eno1 is the external interface (facing the internet) and eno2 is the internal interface (facing the PXE booted hosts).  ​ Configure network interface (ref: [[https://​help.ubuntu.com/​lts/​serverguide/​network-configuration.html.en]]). ​ In this case, eno1 is the external interface (facing the internet) and eno2 is the internal interface (facing the PXE booted hosts).  ​
  
-# vim /​etc/​netplan/​99_config.yaml+Edit ''​/​etc/​netplan/​99_config.yaml''​
  
 <​code>​ <​code>​
Line 31: Line 33:
 Configure DHCP (ref: [[https://​help.ubuntu.com/​community/​isc-dhcp-server]]) Configure DHCP (ref: [[https://​help.ubuntu.com/​community/​isc-dhcp-server]])
  
-# vim /​etc/​dhcp/​dhcpd.conf+Edit ''​/​etc/​dhcp/​dhcpd.conf''​
  
 <​code>​ <​code>​
Line 50: Line 52:
 </​code>​ </​code>​
  
-# vim /​etc/​dhcp/​reactor-host-dhcp.conf+Edit ''​/​etc/​dhcp/​reactor-host-dhcp.conf''​
  
 <​code>​ <​code>​
Line 64: Line 66:
 </​code>​ </​code>​
  
-# vim /​etc/​dhcp/​reactor-ilo-dhcp.conf+Edit ''​/​etc/​dhcp/​reactor-ilo-dhcp.conf''​
  
 <​code>​ <​code>​
Line 76: Line 78:
 </​code>​ </​code>​
  
-# vim /​etc/​default/​isc-dhcp-server+Edit ''​/​etc/​default/​isc-dhcp-server''​
  
 <​code>​ <​code>​
Line 84: Line 86:
 Start DHCP server Start DHCP server
  
-systemctl enable --now isc-dhcp-server+Run ''​systemctl enable --now isc-dhcp-server''​
  
 Configure TFTP Configure TFTP
Line 92: Line 94:
 Configure PXE Configure PXE
  
 +<​code>​
 # mkdir /​srv/​nfs/​ubuntu # mkdir /​srv/​nfs/​ubuntu
 # cd /​var/​lib/​tftpboot # cd /​var/​lib/​tftpboot
Line 97: Line 100:
 # cp /​usr/​lib/​PXELINUX/​pxelinux.0 /​var/​lib/​tftpboot # cp /​usr/​lib/​PXELINUX/​pxelinux.0 /​var/​lib/​tftpboot
 # cp -r /​usr/​lib/​syslinux/​modules/​bios /​var/​lib/​tftpboot/​boot/​isolinux # cp -r /​usr/​lib/​syslinux/​modules/​bios /​var/​lib/​tftpboot/​boot/​isolinux
-# vim pxelinux.cfg/​default+</​code>​ 
 + 
 +Edit ''/​var/​lib/​tftpboot/​pxelinux.cfg/​default''​
  
 <​code>​ <​code>​
Line 120: Line 125:
 </​code>​ </​code>​
  
 +<​code>​
 # mkdir ubuntu # mkdir ubuntu
 # mount --bind /​srv/​nfs/​ubuntu ubuntu # mount --bind /​srv/​nfs/​ubuntu ubuntu
 +</​code>​
  
-# vim /etc/fstab +Edit ''​/etc/fstab''​ to append
- +
-append+
  
 <​code>​ <​code>​
Line 138: Line 143:
 Export install and required mounts Export install and required mounts
  
-# vim /​etc/​exports+Edit ''​/​etc/​exports''​
  
 <​code>​ <​code>​
Line 146: Line 151:
 </​code>​ </​code>​
  
-exportfs -rv+Run ''​exportfs -rv''​
  
 ===== Client hosts ===== ===== Client hosts =====
Line 152: Line 157:
 Install ubuntu for net boot clients (ref: [[https://​help.ubuntu.com/​community/​Installation/​OnNFSDrive]]) Install ubuntu for net boot clients (ref: [[https://​help.ubuntu.com/​community/​Installation/​OnNFSDrive]])
  
 +<​code>​
 # mkdir /srv/nfs # mkdir /srv/nfs
 # cd /srv/nfs # cd /srv/nfs
-# vim run_debootstrap.sh+</​code>​ 
 + 
 +Edit ''​run_debootstrap.sh''​
  
 <​code>​ <​code>​
Line 162: Line 170:
 </​code>​ </​code>​
  
-bash run_debootstrap.sh+Run ''​bash run_debootstrap.sh''​
  
 Do not set /​srv/​nfs/​ubuntu/​etc/​hostname,​ hostname will come from DHCP Do not set /​srv/​nfs/​ubuntu/​etc/​hostname,​ hostname will come from DHCP
  
 +<​code>​
 # mount --bind /proc ubuntu/proc # mount --bind /proc ubuntu/proc
 # chroot ubuntu # chroot ubuntu
 +</​code>​
  
 Set up locales Set up locales
  
-# vi /​etc/​locale.gen+Edit ''​/​etc/​locale.gen'',​ uncomment locale (en_US.UTF-8)
  
-uncomment locale (en_US.UTF-8) +Run ''​locale-gen''​
- +
-locale-gen+
  
 Install kernel, nfs-common, and SSH server Install kernel, nfs-common, and SSH server
 Do not install grub if prompted to do so Do not install grub if prompted to do so
  
 +<​code>​
 # apt install linux-image-generic nfs-common openssh-server # apt install linux-image-generic nfs-common openssh-server
 # chmod a+r /​boot/​vmlinuz* # chmod a+r /​boot/​vmlinuz*
 # systemctl enable ssh # systemctl enable ssh
 +</​code>​
  
-Enable serial console +Enable serial console ​by running ''​systemctl enable getty@ttyS1''​
- +
-systemctl enable getty@ttyS1+
  
 Set up fstab Set up fstab
  
-# vi /etc/fstab+Edit ''​/etc/fstab''​
  
 <​code>​ <​code>​
Line 206: Line 214:
 Workaround for unreadable kernel image Workaround for unreadable kernel image
  
-# vi /​etc/​kernel/​postinst.d/​chmod-vmlinuz+Edit ''​/​etc/​kernel/​postinst.d/​chmod-vmlinuz''​
  
 <​code>​ <​code>​
Line 214: Line 222:
 </​code>​ </​code>​
  
-chmod a+x /​etc/​kernel/​postinst.d/​chmod-vmlinuz+Run ''​chmod a+x /​etc/​kernel/​postinst.d/​chmod-vmlinuz''​
  
 Edit initramfs settings for NFS boot Edit initramfs settings for NFS boot
  
-# vi /​etc/​initramfs-tools/​initramfs.conf+Edit ''​/​etc/​initramfs-tools/​initramfs.conf''​
  
 <​code>​ <​code>​
Line 224: Line 232:
 </​code>​ </​code>​
  
-Regenerate initramfs+Regenerate initramfs ​by running ''​update-initramfs -u''​
  
-# update-initramfs -u +Set root password and/or add users, install packages, etc.  Then:
- +
-Set root password and/or add users, install packages, etc.+
  
 +<​code>​
 # exit # exit
 # umount ubuntu/proc # umount ubuntu/proc
 +</​code>​
  
 At this point, it should be possible to boot a system over the network. At this point, it should be possible to boot a system over the network.
Line 241: Line 249:
 Note: make sure console is accessable over iLO just in case networking gets broken Note: make sure console is accessable over iLO just in case networking gets broken
  
-# vim /​etc/​default/​ufw+Edit ''​/​etc/​default/​ufw''​
  
 <​code>​ <​code>​
Line 247: Line 255:
 </​code>​ </​code>​
  
-# vim /​etc/​ufw/​sysctl.conf+Edit ''​/​etc/​ufw/​sysctl.conf''​
  
 <​code>​ <​code>​
Line 253: Line 261:
 </​code>​ </​code>​
  
-# vim /​etc/​ufw/​before.rules+Edit ''​/​etc/​ufw/​before.rules''​
 [place immediately after header comment] [place immediately after header comment]
  
Line 268: Line 276:
 </​code>​ </​code>​
  
 +<​code>​
 # ufw allow ssh # ufw allow ssh
 # ufw allow in on eno2 # ufw allow in on eno2
 # ufw enable # ufw enable
 +</​code>​