Install And Configure PXE Server On Ubuntu 15.04
This tutorial describes how to setup a PXE server on Ubuntu 15.04 server and how to configure a PXE client.
Now, let us start to setup and configure
PXE server on Ubuntu 15.04. This method should work on previous Ubuntu
versions like Ubuntu 14.10, 14.04 etc.
Scenario
My test box(pxe server) details are given below:
- Operating System: Ubuntu 15.04 server.
- IP Address: 192.168.1.101/24.
Install PXE Server
First, you should Install and configure DHCP server on your PXE server.
Install DHCP Server in Ubuntu
Let us see how to install and configure DHCP server in Ubuntu 15.04 64 bit server.
To install DHCP server on Ubuntu 15.04, enter the following command:
sudo apt-get install isc-dhcp-server
2.1 Configuration
DHCP
server configuration is not that difficult. First, we have to assign on
what interfaces should the DHCP server (dhcpd) serve DHCP requests. In
my case, I have only one Interface on my system (eth0), so I assigned eth0.
To do that, edit file /etc/default/isc-dhcp-server,
sudo vi /etc/default/isc-dhcp-server
Assign the network interface:
[...] INTERFACES="eth0"
Save and close the file.
Now, edit dhcpd.conf file,
sudo vi /etc/dhcp/dhcpd.conf
Make the changes as shown below.
Set the domain name and domain-name servers:
[...] # option definitions common to all supported networks... option domain-name "unixmen.local"; option domain-name-servers server.unixmen.local; [...]
If this DHCP server is the official DHCP server for the local network, you should uncomment the following line:
[...] authoritative; [...]
Define the sunbet, range of ip addresses, domain and domain name servers like below:
[...] # A slightly different configuration for an internal subnet. subnet 192.168.1.0 netmask 255.255.255.0 { range 192.168.1.20 192.168.1.30; option domain-name-servers server.unixmen.local; option domain-name "unixmen.local"; option routers 192.168.1.1; option broadcast-address 192.168.1.255; default-lease-time 600; max-lease-time 7200; } [...]
If you want to assign a fixed
IP address to your client, you should enter it’s MAC id and the IP
address in the following directive. For example, I want to assign a
fixed IP address 192.168.1.15 to my Ubuntu client, therefore I modified the following directive as shown below.
[...] host ubuntu-client { hardware ethernet 00:22:64:4f:e9:3a; fixed-address 192.168.1.15; } [...]
After making all the changes you want, save and close the file. Be mindful that if you have unused entries on the dhcpd.conf file, comment all of them. Otherwise, you’ll get issues while starting dhcp service.
Now, restart dhcp service:
In Ubuntu 15.04:
sudo systemctl restart isc-dhcp-server
In Ubuntu 14.04 and older systems:
sudo service isc-dhcp-server restart
Likewise, you can start/stop dhcp service as shown below:
In Ubuntu 15.04 systems:
sudo systemctl start isc-dhcp-server
sudo systemctl stop isc-dhcp-server
In Ubuntu 14.04 and older systems:
sudo service isc-dhcp-server start
sudo service isc-dhcp-server stop
3. Configure DHCP Clients
Now, go to the client configuration network settings and change the IP settings to Automatic (DHCP).
Here is my Lubuntu 14.04 settings:
Restart the network or reboot the client system to get IP address automatically from the DHCp server.
Now, you should see the IP address has been automatically assigned to the clients from the DHCP server.
Run the following command from the client system Terminal:
sudo ifconfig
DHCP Server will surely be providing IP to clients..
Now, install the following necessary packages for setting up PXE environment:
sudo apt-get install apache2 tftpd-hpa inetutils-inetd
Configure PXE Server
Edit file /etc/default/tftpd-hpa,
sudo nano /etc/default/tftpd-hpa
Add the following lines to enable TFTP server.
[...] RUN_DAEMON="yes" OPTIONS="-l -s /var/lib/tftpboot"
Then, edit file /etc/inetd.conf,
sudo nano /etc/inetd.conf
Scroll down to the end, and modify or add the following line.
tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot
Save and close the file. If you use IPv6, please change the word udp to udp4.
Restart tftp service:
sudo /etc/init.d/tftpd-hpa restart
Copying Ubuntu Installation files to PXE Server
You
can either mount the Ubuntu Installation ISO image and copy them to
your PXE server or can directly copy the files from your Installation
CD/DVD.
For the testing purpose, Here I am going to deploy Ubuntu 15.04 server OS on my PXE client, so I mounted the ISO image on /mnt directory.
I already have the ISO image on my home directory, so I ran the following command to mount it on /mnt directory.
sudo mount -o loop /home/sk/ubuntu-15.04-server-amd64.iso /mnt/
The Ubuntu 14.04 ISO image has been mounted successfully. Now, go to the /mnt/ directory, and copy the required files from the ISO image to /var/lib/tftpboot/ directory.
cd /mnt/
sudo cp -fr install/netboot/* /var/lib/tftpboot/
Create a directory called ubuntu in the apache root document folder.
sudo mkdir /var/www/html/ubuntu
Note: On Ubuntu 14.10 and previous versions, the apache root document folder is /var/www/.
Copy all the files from the Ubuntu ISO.
sudo cp -fr /mnt/* /var/www/html/ubuntu/
Now, edit file /var/lib/tftpboot/pxelinux.cfg/default,
sudo nano /var/lib/tftpboot/pxelinux.cfg/default
Add the following contents at the end. Make sure you’ve replaced the IP address with your own.
[...] label linux kernel ubuntu-installer/amd64/linux append ks=http://192.168.1.101/ks.cfg vga=normal initrd=ubuntu-installer/amd64/initrd.gz ramdisk_size=16432 root=/dev/rd/0 rw --
For 32bit PXE clients:
[...] label linux kernel ubuntu-installer/i386/linux append ks=http://192.168.1.101/ks.cfg vga=normal initrd=ubuntu-installer/i386/initrd.gz ramdisk_size=16432 root=/dev/rd/0 rw --
Replace 192.168.1.101 with your own PXE server’s IP address.
Save and close the file.
Configure DHCP Server
Now, we have to configure the DHCP server to work with PXE server.
Edit file /etc/dhcp/dhcpd.conf,
sudo nano /etc/dhcp/dhcpd.conf
Add the following lines at the end:
allow booting; allow bootp; option option-128 code 128 = string; option option-129 code 129 = text; next-server 192.168.1.101; filename "pxelinux.0";
Save and close the file.
Now, We have come to the end of the PXE server configuration. Restart DHCP server.
sudo service isc-dhcp-server restart
Congratulations! We have completed the PXE server configuration.
PXE Client Configuration
The client may be any system that has network boot enabled option (PXE boot). You can enable this option in your Bios settings.
Due to lack of resources, I have created a Virtual Machine client on my Oracle VirtualBox.
Open up the Oracle VirtualBox. Click on the New button in the menu bar.
Enter the Virtual machine name.
Enter the RAM size to the Virtual machine.
Select “Create a virtual hard drive now” option and click Create.
Select the Virtual hard drive file type. If you don’t know to what to select, leave the default option and click Next.
Select whether the new virtual hard drive file should grow as it is used or if it should be created as fixed size.
Enter the Virtual hard drive size.
That’s
it. Our Virtual Client machine has been created. Now, we should make
the client to boot from the network. To do that, go to the Vitual
machine Settings option.
Select the System tab on the left, and Choose Network from the boot order option, and un-check all the other options on the right side.
Then, go to the Network tab and select “Bridged Adapter” from the “Attached to” drop down box.
Once you done all the above steps, click OK to save the changes. That’s it. Now power on the Virtual client system. You should see the following screen.
That’s
it. The rest of the installation is same as the way we do in local
installation. Start installing Ubuntu on your client using the PXE
server.
Good luck!
Reference:
No comments:
Post a Comment