Tuesday, February 19, 2013

boot from PXE


  1. pxe client 選擇 pxe 開機, 透過 dhcp 取得本身 IP 與 某個 file, 這個 file 也就是 pxe server 希望 pxe client 拿到 IP 之後, 再向 pxe server 透過 tftp 下載這個 file, 一般為 pxelinux.0
  2. pxe client 拿到 pxelinux.0 之後, 會嘗試下載本身 ether mac address 相關的檔案, 直到 pxelinux.cfg/default
  3. pxe server 可以透過 pxelinux.cfg/default, 提供開機選單訊息
  4. 此次實驗, pxe server 希望 pxe client 透過 nfs 掛載 bt5r3


Take bt5r3 as the pxe server
1. apt-get install dhcp3-server
   /etc/dhcp3/dhcpd.conf
   subnet 192.168.0.0 netmask 255.255.255.0 {
        range 192.168.0.100 192.168.0.200;
        filename "pxelinux.0";
   }  
   設定本身 ip 為 192.168.0.100
 
   /etc/init.d/dhcp3-sever restart

2. apt-get install tftpd-hpa
3. apt-get install nfs-kernel-server
   /etc/export
   /tftpboot *(rw,sync,no_subtree_check,no_root_squash,insecure)
   /tftpboot/bt5r3 *(sync,insecure,no_root_squash,ro,no_subtree_check)

   portmap
   /etc/init.d/nfs-kernel-server restart
4. apt-get install syslinux
   取得 pxelinux.0 執行檔

 mount -t iso9660 -o loop bt5r3.iso /mnt
 mkdir -p /tftpboot/bt5r3
 cp -r /mnt/* /tftpboot/bt5r3

/tftpboot/pxelinux.0
 cp /usr/lib/syslinux/pxelinux.0 /tftpboot/

/tftpboot/isolinux.msg
 type bt5r3 to boot Backtrack 5 R3.

/tftpboot/pxelinux.cfg/default
 TIMEOUT 100
 DEFAULT bt5r3
 PROMPT 1
 DISPLAY /isolinux.msg
 LABEL bt4
   KERNEL bt5r3/casper/vmlinuz
   APPEND initrd=bt5r3/casper/initrd.gz BOOT=casper boot=casper nopersistent rw quiet vga=0x317 netboot=nfs nfsroot=192.168.0.100:/tftpboot/bt5r3

參考資料

  1. http://www.backtrack-linux.org/forums/showthread.php?t=1470
  2. https://help.ubuntu.com/community/PXEInstallServer