2015/09/01

Install And Configure PXE Server On Ubuntu 14.04

My PXE server is building in VirtualBox. The details are given below:
  • OS: Ubuntu 14.04 LTS server.
  • VirtualBox Network Interface 1: Bridge mode; mapping to Ubuntu Eth0
  • VirtualBox Network Interface 2: Internal mode, Set Name as "MAAS"; mapping to Ubuntu Eth1
  • IP Address: 192.168.1.1
  • DHCP: isc-dhcp-server (The detailed settings please refer to here)
  • TFTP: xinetd (The detailed settings please refer to here)

The detailed installation and configuration of PXE Server on Ubuntu by below steps.

Install and configure apache2 package


In this example, we'll use an WWW (apache) server as an installation server.
  1. At a terminal prompt, enter the following command to install apache2:
    sudo apt-get install apache2
  2. Modify /etc/apache2/apache2.conf file and add the following line into it:
    sudo vim /etc/apache2/apache2.conf
    ServerName localhost
  3. Restart the apache service
    sudo service apache2 restart

Config xinetd tftp


  1. Edit file /etc/default/xinetd,
    sudo vim /etc/default/xinetd
  2. Add the following lines to enable TFTP server.
    RUN_DAEMON="yes"
    OPTIONS="-l -s /tftpboot"

  3. Edit file /etc/xinetd.conf and scroll down to the end. Modify or add the following line.
    sudo vim /etc/xinetd.conf
    tftp dgram udp wait root /usr/sbin/xinetd /usr/sbin/xinetd -s /tftpboot
  4. Restart tftp service:
    sudo service xinetd restart

Copy Ubuntu Installation files to PXE Server


  1. Click insert ubuntu-14.04.3-server-amd64.iso file into CD-ROM from VirtualBox control panel.
  2. Mount /dev/cdrom on /mnt directory
    mount /dev/cdrom /mnt
  3. Copy the required files from the ISO image to /tftpboot directory.
    cd /mnt
    sudo cp -fr install/netboot/* /tftpboot/

  4. Create a directory called ubuntu in the apache root document folder.
    sudo mkdir /var/www/ubuntu
  5. Copy all the files from the Ubuntu ISO to the apache root document folder.
    sudo cp -fr /mnt/* /var/www/ubuntu/
  6. Change the authority of syslinux.cfg
    sudo chmod 777 /tftpboot/ubuntu-installer/amd64/boot-screens/syslinux.cfg
  7. Edit file /var/lib/tftpboot/pxelinux.cfg/default and add the following contents at the end. Make sure you’ve replaced the IP address with your own.
    sudo vim /tftpboot/pxelinux.cfg/default
    [...]
    MENU TITLE Welcome to PXE Server System

    LABEL linux
            MENU LABEL Install Ubuntu from PXE server
            kernel ubuntu-installer/amd64/linux
            append ks=http://192.168.1.1/ks.cfg vga=normal initrd=ubuntu-installer/amd64/initrd.gz
    ramdisk_size=16432 root=/dev/rd/0 rw --

  8. Note: If you use 32-bit edition, you should change the kernel path in the about directory with correct path.

DHCP Server Configuration


We have to configure the DHCP server to work with PXE server.
  1. Edit file /etc/dhcp/dhcpd.conf,
    sudo vim /etc/dhcp/dhcpd.conf
  2. Add the following lines at the end. Make sure you’ve replaced the IP address with your own.
    allow booting;
    allow bootp;
    option option-128 code 128 = string;
    option option-129 code 129 = text;
    next-server 192.168.1.1;
    filename "pxelinux.0";

  3. Restart DHCP server
    sudo service isc-dhcp-server restart

VirtualBox PXE Client Configuration


I create a Virtual Machine client on my VirtualBox.
  1. Open VirtualBox and click on the New button in the menu bar.

  2. Enter the Virtual machine name "Ubuntu 14.04 PXE Client".

  3. Enter the RAM size to the Virtual machine.

  4. Select "Create a virtual hard drive now" option and click Create.

  5. Select the "VDI (VirtualBox Disk Image)" option and click Next.

  6. Select "Dynamically allocated" since the new virtual hard drive file should grow as it is used.

  7. Enter default Virtual hard drive size "8G" option and click Create.

After create Virtual Machine, select this new Virtual Machine and click "Setting". We should modify certain options since we need to make the client to boot from the network.

  1. Select the System tab on the left, enable Network from the boot order option, and disable another boot order options on the right side.

  2. Select the Network tab on the left, enable Interface 1, select "Internal" from Attached to, select "MAAS" from Name list, and click OK.


Power on VirtualBox PXE Client


Power on the Virtual PXE client system. You should see the following screen.

And you could find the message "Welcome to PXE Server System" and the last one label "Install Ubuntu from PXE server" in the screen. That is what we add "MENU TITLE" and "MENU LABEL" in /tftpboot/pxelinux.cfg/default file.

Select "Install" label, you should see the following screen for a while. And you could install Ubuntu by default.


But if your select the label "Install Ubuntu from PXE server", you will see the following screen, since we didn't set Kickstart file (ks.cfg) yet. And I will edit Kickstart file (ks.cfg) in the next article.

  1. Unixmen -《Install And Configure PXE Server On Ubuntu 14.04 LTS
  2. 鳥哥的 Linux 私房菜 -《2. 用 kickstart 大量部署用戶端 Linux CentOS 系統

沒有留言:

張貼留言