This chapter will cover how to install Ubuntu Server by using different methods. We will have a look at how to install Ubuntu Server in the manual and automated mode by using a simple or an advanced installation.
To reach this goal, we will follow this plan:
Preparation before the installation
The manual installation
The automated installation
I started writing this book just after Ubuntu 15.04 (Vivid Vervet) was released on April 23, 2015. Currently, there are two major releasesâthe LTS one that was released last year (LTS stands for long-term support), which is version 14.04, and the latest version 15.04. It is not a big deal if you choose either of these two versions to perform the tasks in the coming chapters, since it will make no difference. So, we decided to use the latest version as a reference for our samples, especially because the next LTS release will be based on it. (Note that only the LTS releases are supported for 5 years by Canonical, and the non-LTS releases have a support of only 9 months. That's why we normally choose the LTS versions for Ubuntu Server deployments.) When there is a notable difference between these two versions, we will mention it.
It uses Linux kernel 3.19, which brings a lot of improvements in terms of performance as well as network facilities for both servers and cloud.
15.04 is the first Ubuntu version that features LXD.
It replaced the service manager and the standard boot
upstart boot still exists under Ubuntu. You can use it by opening the GRUB boot menu, choosing Advanced options for Ubuntu, and then clicking on Ubuntu, with Linux (upstart).
If you would like to switch permanently to the
upstart boot, you can install the
upstart-sysv package, which will remove
System requirements depend on the services that may need to be deployed in the future and installed on the server. For demonstration/test purposes, we need a minimal configuration of 300 MHz CPU, 192 MB of RAM, and a 1.5 GB hard disk. This light configuration allows us to deploy Ubuntu Server on an old computer or even a little virtual machine. This limited footprint is basically due to the absence of the X Windows System (graphic interface), which is not needed in a server environment.
In a production environment, you should be careful about your actual needs in terms of resources (the CPU, RAM, and hard disk) and the estimation growth of those needs. To do this, you need to make a good measure of dimensions based on the services that you are going to deploy.
In the case of the samples in this book, we will use the 64-bit version of Ubuntu Server 15.04, and we will install it on a virtual box machine that has 1 GB of RAM and 2 TB of hard disk.
Note that if you are using a used computer/server, you should back up your data before installing or upgrading Ubuntu. Partitioning tools used in the installation process are reliable and can be used for many years without any problems in general, but sometimes, they can perform catastrophic actions.
This book comprises only the essentials. It contains exactly what you need to know to perform a specific task. If you need more information about and an in-depth understanding of Ubuntu, you can have a look at the official documentation by visiting https://help.ubuntu.com.
You should download the CD image according to your system architecture. The whole list exists at http://releases.ubuntu.com/15.04/.
In this section, we will have a look at how to install Ubuntu Server manually, either from the CD or the USB key. Here, we will only cover the installation from the CD; the same procedure applies for the installation from the USB key. In the latter case, you should configure your computer (using the BIOS interface) to boot from USB.
There is another way to manually install Ubuntu Server, which is via network, but since we will see this procedure in depth in the next Automated installation section, we will not cover it here.
The procedure for installing Ubuntu from a CD is the same as that for most of the Linux distributions. So, if you are familiar with this, you can save time and move directly to the next section. If you are a newbie in this field, please follow this section closely, since the next sections (advanced installation and automated installation) will be based on this. Note that for Ubuntu Server edition, there is no graphical environment like the one in the desktop edition. So, you will need to use only the keyboard and not the mouse. The stepwise procedure to install Ubunto from CD is as follows:
First of all, download the installation CD image that matches your CPU architecture from the download page at http://releases.ubuntu.com/15.04/ and burn it on to an empty CD.
Secondly, verify that your server BIOS is configured to boot on a CD-ROM drive; if this isn't the case, take care that you change it.
Just after the boot process starts, you will be asked to select the installation language. Choose the one that you want. Don't worry if you choose some other language by mistake. You will soon learn how to change the settings.
Now, you will get the following interface:
You can see a lot of options that cater to your needs:
If you just press the Enter key when selecting the default Install Ubuntu Server option, you will start the installation process.
The second option, Multiple server install with MAAS, will be covered later in the chapter when talking about virtualization and cloud.
The fourth option, Test memory, is very helpful, especially when your server starts crashing and you suspect a RAM-related problem.
You can use the fifth option, Boot from first hard disk, to bypass the boot from the CD in case you forgot it by mistake in the CD-ROM driver.
Finally, the last option, Rescue a broken system, turns a CD into a rescue disk that is useful for backup and recovery.
In most of the cases, all that you need to do is launch the installation by pressing the Enter key when selecting the default Install Ubuntu Server option, but there are some cases where you need some special options, either because of some specific hardware-related need of your machine, or because you need to customize the kernel parameters of the server for future use. For this purpose, Ubuntu gives you a lot of possibilities via the bottom menu on the boot splash screen, which can be accessed via the function keys.
If you press F1, you will see an interactive help screen with documentation for the rest of the options.
If you accidentally chose the wrong language at the time of booting, press F2 to change it. The boot screen will automatically choose a keyboard mapping based on your language.
If you want a different mapping (for example, in my case, I am preparing screenshots for this book in English but I am using a French keyboard), press F3 to choose from a list of keyboard mapping options. The boot screen also has a lot of great accessibility options.
The F4 key displays a list of installation modes from which you can choose to install Ubuntu Server by using an OEM installation, a minimal system, and a minimal virtualization guest. The OEM installation is available for manufacturers. The minimal virtualization guest gives you an easy way to install a virtualized version of Ubuntu.
The real power and control over the boot process is available once you press the F6 key. Here, you can see a menu of the common arguments that help the CD boot on difficult hardware. If you press the Esc key, you will move from this menu to the boot prompt. You can type extra kernel boot parameters that you might need for your hardware, as shown in the following screenshot:
Just after launching the installation process, you will be asked to choose the language of the installation procedure, which will be the default language of the server that you wish to install. Select the one that you want by using the up/down arrow keys on your keyboard and then press the Enter key. You will also be asked for the location of the server (based on this, the system will fix the server time settings). Then, you have a choice of either letting the installer detect your keyboard layout, or you entering it manually.
After performing these steps, the installer starts the installation process by detecting the hardware and loading some packages. Then, it moves on to configure the network settings by using DHCP (Dynamic Host Configuration Protocol) and asking for the hostname that you would like to give to your server. If you wouldn't like to use DHCP for network configuration, choose go back or simply press the Esc button to go to the first interface of network configuration, where you will find the Configure the network manually option, as shown in the following screenshot:
By making this choice, you will be asked via different interfaces to enter your IP address, Netmask, the default Gateway, and DNS.
Note that if you enter wrong information by mistake and you realize just after pressing the Enter key, don't worry. You can go back easily to the previous interface and re-enter the correct data. All that you need to do is choose Go Back or simply press the Esc button.
Also note that this data is not a tattoo, and you can change it later. We will have a look at how to do this in the next chapter.
At this point, we have almost finished the network settings part. We will be asked for the hostname in the next screen, and then we will move on to the user settings. First of all, you will be asked about the full username. Then, you will get an interface that asks for the Ubuntu username, which will be used for authentication with a proposition derived from the full username that you entered before. You can accept the proposition or modify it. Finally, you will be asked to enter and re-enter a password for this user. Be careful in this step because the keys entered will be hidden, as shown in the following screenshot. Therefore, it is important to remember the keys that you have entered:
Next, you will be asked whether you would like to encrypt your home directory. Don't do that unless you know what you are doing. At the end of this step, you will be asked to check your time zone. Change it in case it is incorrect.
Now, the most critical part of the installation arrivesâpartitioning! If you are using a new hard disk, you will see a screen, as shown in the following screenshot:
If you are using a used hard disk, you will receive an interface that is a little different. It contains in general the same four options with the options related to the reuse of the existing partitions. The first three options are the recommended ones for a newbie. In our case, we will choose the Guidedâuse entire disk and set up LVM option. The Manual option will be covered in the Advanced installation section.
On pressing the Enter key, you will be taken to the next screen, where you will be asked to choose the disk that you would like to partition. You will then be taken to an interface, which will ask for your permission to write changes on the disk with the No option selected. We of course need to make changes to the disk. We should just verify that we created a backup of our data on the disk before moving on. The next step is to select the Yes option and press the Enter key. Before you finish this step, you will be asked to enter the size of each volume group that you will be using for this partitioning. You can answer with a number followed by a symbol such as MB, GB, and TB, or simply use a percentage. Finally, you will get a summary of the partitioning step, which needs to be confirmed before it is applied, as shown in the following screenshot. Select the Yes option and press the Enter key:
At this point, the real installation process starts. During the installation, the installer needs only the CD, but if there is an Internet connection, it can be used to download software lists and install the latest updates. For that, it will ask you to either enter the proxy settings if you have one, or to keep this field empty.
After this step, the installer will start downloading the software list (we will cover this later in the next chapter). This step can take some time, depending on your Internet speed:
After a few minutes, the installation process starts:
During this step, you will be asked about the update policy. Personally, I recommend that you deactivate the automatic installation of updates. It is better when the administrator manages the installation of updates manually depending on the servers that are running on Ubuntu Server.
One of the useful facilities that are given by the Ubuntu installer is the ability to choose to install server packages such as the SSH and DNS server. You can choose one of them by pressing the space bar, and you can continue the installation process by pressing the Enter key. In our case, we will decide not to install a server at this step. We will have a look at how to do this in a later chapter:
In case you have an existing Ubuntu Server and you would like to upgrade it to the newest release, you can use the
do-release-upgrade command. This command is a part of the
update-manager-core package; it does not have any graphical dependencies and is installed by default.
You can check the options list associated with this command by running the following:
You will find the following options very useful:
do-release-upgrade --check-dist-upgrade-only: The
--check-dist-upgrade-onlyoption checks for a new version. If a new version is found, it is displayed as a result in the terminal. Once executed, this command performs only a verification job; no upgrade is made.
do-release-upgrade --sandbox: The
--sandboxoption is used to test an upgrade in a protected environment. This is particularly useful if you wish to test the deployment of an upgrade prior to its application in the production environment.
do-release-upgradetool researches and makes an upgrade to the next LTS or stable version available, if it exists.
The upgrade policy used by the
do-release-upgrade tool is defined in the
/etc/update-manager/release-upgrades file. The prompt variable at the end of the file indicates whether only the LTS versions will be considered or all the versions (the LTS ones as well as the regular ones) will be searched for when asking for an upgrade. The prompt variable can take as values
lts for the LTS versions,
normal for all versions, and
never to never search for new versions.
Much of the Ubuntu Server installation process fulfils a majority of user needs, and it is used in the same manner by most of the users (newbie or advanced), but the part that requires much more attention and which is customized by many advanced system administrators depending on their needs is the partitioning step. In this section, we will have a look at how to perform an advanced partitioning for a specific hard disk schema.
The RAID technology (an acronym for Redundant Array of Inexpensive Disks) refers to the techniques used to distribute data across multiple hard drives (creating a storage unit from several hard disks). The unit thus created has an improved fault tolerance (high availability) or a greater performance (the capacity/write speed). The distribution of data on several hard drives allows you to increase the safety and reliability of the associated services.
For more information about this technology, you can take a tour at http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html.
In the Partition disk step, select manual. Then, select one by one all the disks that you want and which should be a part of the RAID partitions (in our case, only two disks). For each disk, create a new empty partition table on it.
Select the free space on the first drive. Then, choose Create a new partition. Set the size that you want for Swap; it should be twice the RAM size and up to 2 GB. Then, choose Primary and select Beginning. The physical volume for RAID option should be chosen in the Use as: line. Finally, select Done setting up partition.
With the remaining free space, perform the same steps for the root partition. The only exception is that after setting the size, choose Continue and then select Primary. Also, select the Bootable flag: line to change the value to on.
Return to the Partition Disks step and select Configure Software RAID at the beginning of the page. Then, choose yes to write the modifications to disk.
In the Create MD device setup and for this example, choose RAID1, but if you are applying another architecture, choose the one that fits your needs.
Now, enter the number of hard drives that you have chosen for the array (in our case, we have two active devices). Then, select Continue.
Next, enter the number of spare devices (choose the default setting for RAID1, which is 0) and then select Continue.
At this step, choose the partitions that you wish to use. For the Swap partition, choose sda1 and sdb1. Select Continue to go to the next step.
Repeat steps 3 to 7 to prepare the root partition, and at the end, choose sda2 and sdb2. Finally, select Finish.
We should now have a list of RAID devices and hard drives. The next remaining steps are required to format and set the mount point for the RAID devices. Deal with the RAID devices as a local hard disk; format and mount accordingly:
Getting back to the initial partitioning page again, we will see our newly created RAID devices #0 and #1 partitions.
In the Use as: file, select swap area and then apply this partition by using the Done setting up partition entry.
Under the RAID1 device #1 partition, select #1 and press the Enter key.
In the Use as: file, select Ext4 journaling file system.
In the Mount point field, choose / (the root file system). You can change the other options as you wish. Then, apply that partition by using the Done setting up partition entry.
Finally, select Finish partitioning and write changes to disk.
LVM (Logical Volume Manager) allows the creation and the management of logical volume on Linux. The use of logical volumes somehow replaces the disks' partitioning. This is a much more flexible system as it allows you, for instance, to reduce the size of a file system to expand another one regardless of their location on disks.
For more information about this technology, you can take a tour at http://tldp.org/HOWTO/LVM-HOWTO/.
In this section, we will have a look at the partitioning step of Ubuntu Server installation process with the /srv partition mounted on a LVM volume. This section will be divided into two partsâthe first part is during the Ubuntu installation within only one PV (physical volume), which will be a part of the VG (volume group), and the second part will be after the Ubuntu installation. While performing this process, we will demonstrate how to add a second PV to the VG:
In the Partition disks screen, choose Manual.
Select the hard disk. Then, choose Yes to confirm the Create a new empty partition table on this device order.
Next, create standard swap and / partitions with the file system that you want.
/srvLVM partition, create a new logical partition and change the Use as field to physical volume for LVM. Then, select Done setting up the partition.
Now, choose Configure the Logical Volume Manager and select Yes.
Return to the LVM configuration action page and select Create logical volume. Choose the newly created VG and name the new LV. Then, choose a size and at the end, select Finish. You will be taken to the main Partition Disks page again.
Now, let's add a file system to our new LVM. To do this, select the partition under the LVM that you created and set up the file system that you want and choose /srv as the mount point. Next, select Done setting up the partition.
Finally, apply the Finish partitioning and write changes to disk order. Then, confirm the changes and continue your installation.
Now, we will continue with the second part that started after the Ubuntu Server installation and which covers adding a second hard disk, creating a PV, adding it to the existing VG, extending LV with the srv command, and finally extending the file system. In this part, we will use a second hard disk named
/dev/sdb, and we will use it entirely as a PV. You can configure and use as much of PV as you want:
First of all, create the PV using the following command:
sudo pvcreate /dev/sdb
Next, extend the VG (called
vg01in our example), as follows:
sudo vgextend vg01 /dev/sdb
vgdisplaycommand to find out the size that you can allocate (for free physical extents, see the Free PE / size line). We will assume in our example a free size of 511 PE (which is equivalent to 2 GB with a size of 4 MB PE), and we will use the entire available free space.
We can now use the PE to extend the LV via the following command (there are other methods, but they are beyond the scope of this book):
sudo lvextend /dev/vg01/srv -l +511
We used the
-loption here to extend the LV using PE. If you want to extend using MB, GB, and TB, you can use the
Before expanding an
ext4file system, it is recommended that you unmount it before hand (as best practice). In case you want to reduce an LV, it will be mandatory to unmount it. The following commands unmount the partition and then check it:
sudo umount /srv sudo e2fsck -f /dev/vg01/srv
sudo resize2fs /dev/vg01/srv
mount /dev/vg01/srv /srv && df -h /srv
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 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.0 file; 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.
First of all, install the DHCP server by using the
sudo apt-get install isc-dhcp-server -ycommand, and then configure it by using the
/etc/default/isc-dhcp-serverfile to use the network that you want for listening (such as
/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
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
RUN_DAEMON="yes" OPTIONS="-l -s /var/lib/tftpboot"
Also, add the following line at the end of the
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 restartcommand.
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/defaultPXE 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.
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
virtualbox instance to test this kind of installation:
Create the virtual machine with the characteristics that you want via the
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:
Finally, start your VM. You will see the following interface:
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
preseed file. A good starting point for working with
kickstart is https://help.ubuntu.com/community/KickstartCompatibility.
For details regarding the installation of the Ubuntu desktop from a PXE server, visit https://help.ubuntu.com/community/Installation/LocalNet. You can use the same procedure to install Ubuntu Server.
To learn how to prepare a PXE server that allows you to boot multiple distributions (Ubuntu, Debian, Fedora, CentOS, and openSUSE), visit https://help.ubuntu.com/community/PXEInstallMultiDistro.
For those of you searching for how to set up a MAAS server that will deploy a Ubuntu system through
netboot, a very good guide is available at http://maas.ubuntu.com/docs/install.html.