24/7/365 Support

Automated Ubuntu installation

Sometimes, we have a large number of servers to install. In this case, the manual installation will take a lot of time to perform a repetitive task. To solve this problem, there is the automation installation, or what we call the network boot.

For this, we need a machine equipped with a DHCP server and a TFTP server that

will provide us the services and configuration files that we need for the system

to be installed.

The PXE process

The client computer (our future server) will boot its network interface in the PXE (Preboot Execution Environment) mode. Then, the DHCP present on the network will send it the pxelinux.0file; this will be explained later. Thus, the client computer accesses the pxelinux.cfg configuration file via TFTP, which contains the necessary information required to launch the installation process.

The PXE installation procedure

Let's start with the server installation:

1. First of all, install the DHCP server by using the sudo apt-get install isc-dhcp-server -y command, and then configure it by using the /etc/default/isc-dhcp-server file to use the network that you want for listening (such as eth0).

In the /etc/dhcp/dhcpd.conffile, you should configure some parameters

such as the subnet and the address range. Then, restart it by using the following command:

sudo service isc-dhcp-server restart

2. After this, install the following packages that are necessary if you wish to set up the PXE environment:

sudo apt-get install apache2 tftpd-hpa inetutils-inetd

Now, it is time to configure the TFTP service. To do this, add the following two lines to the /etc/default/tftpd-hpa file:

RUN_DAEMON="yes"

OPTIONS="-l -s /var/lib/tftpboot"

Also, add the following line at the end of the /etc/inetd.conf file:

tftp dgram udp wait root /usr/sbin/in.tftpd /usr/sbin/in.tftpd -s /var/lib/tftpboot

Then, reboot the service using the sudo /etc/init.d/tftpd-hpa restart command.

3. Now, we need to copy the installation files to the PXE server. In our example, I used the ISO image that I have in my home directory. First of all, mount it by using the following command:

sudo mount loop /home/abdelmonam/ubuntu-15.04-server-amd64.iso /mnt

Then, copy the required files to the server by using the following commands:

cd /mnt sudo cp -fr install/netboot/* /var/lib/tftpboot/ sudo mkdir /var/www/Ubuntu sudo cp -fr /mnt/* /var/www/ubuntu/

After doing this, modify the /var/lib/tftpboot/pxelinux.cfg/default PXE config file by adding the following lines at the end:

label linux 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 -

Be careful when adding the IP address.

4. The last step required to set up the PXE server is to add the following lines at

the end of the /etc/dhcp/dhcpd.conf file:

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";

Then, reboot the DHCP server by using the following command:

sudo service isc-dhcp-server restart

Let's move on to the client configuration. In our case, I used a virtualboxinstance to test this kind of installation:

  1. Create the virtual machine with the characteristics that you want via the virtualbox manager.
  2. Then, go to the Settings of the machine and select the System tab. In the Boot Order part, deselect all options and select Network, as shown in the following screenshot:
  3. Select the Network tab and configure the network adaptor to act as a bridge.
  4. Finally, start your VM. You will see the following interface:

Enjoy watching the server installation if you were doing it locally from a CD.

The PXE installation can be used to install a lot of machines in parallel as

well as to install Ubuntu Server on machines without a CD-ROM driver. The installation process will be entirely automated if you combine the PXE method with a kickstartand/or preseedfile. A good starting point for working with kickstartis https://help.ubuntu.com/ community/KickstartCompatibility .

Additional resources

Since this book consists of the essentials for the Ubuntu Server, we can't cover topics in depth. Therefore, here are some useful links that will help you go as far as you want in this subject:

Summary

In this article, we had a look at how to install Ubuntu Server in different modes—manually and automated—with the help of a simple or an advanced installation.

Now, we can start managing our server, which is the subject that we will cover in the next article.

Help Category:

What Our Clients Say