Book Image

Ubuntu Server Essentials

By : Abdelmonam Kouka
Book Image

Ubuntu Server Essentials

By: Abdelmonam Kouka

Overview of this book

Ubuntu is a Debian-based Linux operating system built on top of the Debian architecture. It is used to make operating systems for multiple platforms, including phones, desktops, TVs and mobiles. It has made some serious progress in the realms of efficiency and user friendliness. With evolving technology trends, demands on software have changed, with more and more skilled users. Over the past few years, services such as Facebook, Twitter, and push notifications on smartphones mean that users are used to being up to date with everything that happens all the time. With SignalR, the applications stay connected and will generate notifications when something happens either from the system or by other users. This provides new opportunities for the system administrators, to enter this new and exciting world of real-time application development. This is a concise and a cost-friendly guide, packed with up-to-date essentials on Ubuntu Server fundamentals. It will guide you through deploying and configuring Ubuntu servers in your office environments. You’ll start by installing Ubuntu Server, then move to the most useful aspect —the command-line interface inside it. You’ll extend your knowledge by learning how to administrate and configure Ubuntu Server. You will also see how to deploy services on Ubuntu Server and find out how to secure it. You’ll get to grips with the virtualization and cloud computing facilities provided by Ubuntu, and finally, you’ll gain some very useful tips.
Table of Contents (13 chapters)

The advanced installation

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.

Using RAID

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

In this section, we will see how to install Ubuntu Server using two RAID1 partitions on two different hard disks, one for the root and the other for Swap:

  1. 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.

  2. 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.

  3. 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.

  4. 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.

  5. 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.

  6. 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.

  7. Next, enter the number of spare devices (choose the default setting for RAID1, which is 0) and then select Continue.

  8. 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.

  9. 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:

  1. Getting back to the initial partitioning page again, we will see our newly created RAID devices #0 and #1 partitions.

  2. Under the RAID1 device #0 partition, select #1 and press the Enter key.

  3. In the Use as: file, select swap area and then apply this partition by using the Done setting up partition entry.

  4. Under the RAID1 device #1 partition, select #1 and press the Enter key.

  5. In the Use as: file, select Ext4 journaling file system.

  6. 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.

  7. Finally, select Finish partitioning and write changes to disk.

The installation process will then continue normally.

Using LVM

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

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:

  1. In the Partition disks screen, choose Manual.

  2. Select the hard disk. Then, choose Yes to confirm the Create a new empty partition table on this device order.

  3. Next, create standard swap and / partitions with the file system that you want.

  4. For our /srv LVM partition, create a new logical partition and change the Use as field to physical volume for LVM. Then, select Done setting up the partition.

  5. Now, choose Configure the Logical Volume Manager and select Yes.

  6. On the next screen and for LVM configuration action, select Create volume group. Name the VG (for example, vg01). Then, select the partition prepared for LVM and choose Continue.

  7. 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.

  8. 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.

  9. 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:

  1. First of all, create the PV using the following command:

    sudo pvcreate /dev/sdb
  2. Next, extend the VG (called vg01 in our example), as follows:

    sudo vgextend vg01 /dev/sdb
  3. Use the vgdisplay command 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.

  4. 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
  5. We used the -l option here to extend the LV using PE. If you want to extend using MB, GB, and TB, you can use the -l option.

  6. Before expanding an ext3 or ext4 file 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
  7. Finally, you can resize the file system by using the following command:

    sudo resize2fs /dev/vg01/srv
  8. Now, you can mount the partition and check its new size using the following command:

    mount /dev/vg01/srv /srv && df -h /srv