準備:
1. Download Ubuntu desktop ISO
2. Download PXE bootloader
安裝:
1. DHCP Server
$ sudo apt-get install isc-dhcp-server2. TFTP Server
$ sudo apt-get install tftpd-hpa inetutils-inetd3. NFS Server
$ sudo apt-get install nfs-kernel-server配置:
1. DHCP Server:
$ sudo vi /etc/dhcp/dhcpd.conf
subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.200 192.168.1.253;
option domain-name-servers 8.8.8.8;
option routers 192.168.1.1;
option broadcast-address 192.168.1.255;
default-lease-time 600;
max-lease-time 7200;
next-server 192.168.1.254;
filename "pxelinux.0";
}
$ sudo systemctl restart isc-dhcp-server2. TFTP Server:
$ sudo vi /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"TFTP_ADDRESS=":69"
TFTP_OPTIONS="--secure"
RUN_DAEMON="yes"
OPTIONS="-l -s /var/lib/tftpboot"
$ sudo vi /etc/xinetd.conf
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
$ sudo systemctl restart tftpd-hpa3. PXE bootloader:
$ tar -xJf syslinux-6.03.tar.xz
$ cd syslinux-6.03
$ sudo cp bios/core/pxelinux.0 /var/lib/tftpboot
$ sudo cp bios/com32/lib/libcom32.c32 /var/lib/tftpboot
$ sudo cp bios/com32/libutil/libutil.c32 /var/lib/tftpboot
$ sudo cp bios/com32/elflink/ldlinux/ldlinux.c32 /var/lib/tftpboot
$ sudo cp bios/com32/menu/vesamenu.c32 /var/lib/tftpboot
$ mkdir /var/lib/tftpboot/pxelinux.cfg
$ sudo vi /var/lib/tftpboot/
pxelinux.cfg/default
DEFAULT vesamenu.c32* Remember to copy vmlinuz.efi and initrd.lz to the folder /var/lib/tftpboot from Ubuntu ISO.
MENU TITLE Network boot
LABEL ubuntu-mate-16.04.2-desktop-amd64
MENU LABEL ubuntu-mate-16.04.2-desktop-amd64
KERNEL vmlinuz.efi
APPEND initrd=initrd.lz root=/dev/nfs boot=casper netboot=nfs nfsroot=192.168.1.254:/var/nfs/ubuntu_desktop splash --
* 補充: 針對18.04要修改一下設定檔如下:
APPEND initrd=./u18/initrd_ubuntu18.04.lz root=/dev/nfs boot=casper netboot=nfs nfsroot=192.168.1.254:/var/nfs/ubuntu18.04 splash toram --
4. NFS file Server:
$ sudo mount -o loop ubuntu-16.04.3-desktop-amd64.iso /mnt/
$ sudo mkdir -p /var/nfs/ubuntu_desktop
$ sudo cp -rf /mnt/* /var/nfs/ubuntu_desktop/
$ sudo vi /etc/exports
/var/nfs/ubuntu_desktop *(ro,sync)
$ sudo systemctl restart nfs-kernel-server
$ showmount -e localhost
Export list for localhost:
/var/nfs/ubuntu_desktop *
Boot from Network boot:
Done!