Chapter 1. Installation

I remember when it was quite the ordeal to install Linux. You had to download a complete set of floppy images and use some strange Linux or Windows tool to dump those images to floppies. After you had your set of floppies and started the installation process, you would quickly realize that the installation program assumed you already knew quite a bit about Linux and about computers in general. I am actively involved in a Linux users’ group, and a staple of Linux users’ groups is the install-fest—an event to which Linux newbies can bring their computers and have an expert walk them through the installation process.

Well, these days Linux distributions have made great strides to improve the install process. A desktop Ubuntu install asks very few questions that might stump a beginning user, and the server install (unlike some other server installs out there) doesn’t assume you are an experienced Linux system administrator either. While the server install is pretty easy to navigate when you just accept the defaults, you’ll find that it also allows the advanced administrator a lot of flexibility and control. What’s better, you can get this control without toggling an “expert mode” that forces you to answer detailed questions about every aspect of the install. When the default suits you, you can accept it and move on, and when it doesn’t, you can easily tweak only those settings you care about.

This chapter walks you through a standard Ubuntu install. Along the way, it covers each of the major parts of the installation process and also highlights areas where the experienced administrator can tweak and tune the settings for a custom server install.

Get Ubuntu

If you have this book, you should already have the Ubuntu install CD for Ubuntu 12.04 LTS, but just in case you don’t, or if you need an extra copy, it’s good to know how to get CDs from scratch. With some distributions you are required to register and log in to a Web site before you have access to CD images, but Ubuntu makes it relatively easy. At www.ubuntu.com/getubuntu/download you can access both desktop and server CDs for each of the platforms Ubuntu supports. Once you have downloaded the ISO image, you can burn it to a CD using your preferred CD-burning tool. Each program is different, so locate your program’s option to burn a CD image.

If you are already running an Ubuntu desktop, you can just double-click the ISO image after it is downloaded to start the CD/DVD Creator. If you don’t have the bandwidth to download the ISO image, you can also purchase CDs or request free CDs from the same page.

Boot Screen

Once you have your CD, insert it into your server’s CD-ROM slot and boot the server. Server BIOSs can be quite different from each other. In some cases they are already set up to boot from a CD-ROM if one is present. In other cases you might have to hit a key such as Esc, Del, F12, or others as the server boots so that it presents you with a list of devices from which you can boot. On some systems you might even have to go into the BIOS configuration page to change the boot order.

After you have convinced your BIOS to boot from the CD, you are greeted with the Ubuntu boot splash screen. The very first part of the screen asks you for your language and then presents you with some boot options, as shown in Figure 1-1. If you just hit Enter and select the default option, you will start the Ubuntu install program. You can also perform some diagnostics from this screen. If you downloaded and burned your own CD from an ISO file, you might want to select the “Check CD for defects” option. You can also test your system memory from this screen—quite useful even later on if your server starts crashing at strange times and you suspect bad RAM might be the cause. This CD also doubles as a basic rescue disk, which is a broad enough topic that it has gotten its own chapter: Chapter 12, Rescue and Recovery. Finally, if you left the CD in the drive by mistake, you can select “Boot from first hard disk” to bypass the CD altogether.

Image

Figure 1-1 Default Ubuntu boot splash screen

In an ideal world, you could boot the CD, press Enter, and start the installation process with no problems. Unfortunately, for some machines you might have to tweak some of the boot options so the installation works for your system. The Ubuntu developers know this sort of thing happens and have prepared a rich set of options for you. Along the bottom of the boot splash screen are a number of different options you can access with function keys. For instance, if you hit F1 you will see an interactive help screen with documentation for the rest of the options. If you accidentally chose the wrong language at boot time, hit F2 to change it. The boot screen will automatically choose a keyboard mapping based on your language. If you want a different mapping (for instance, you speak English but are doing an install in Germany on a German keyboard), hit F3 to choose from a list of keyboard mappings. The boot screen also has a lot of great accessibility options. The F5 key brings up an accessibility menu that allows you to choose a high-contrast screen, a screen magnifier, a screen reader and Braille terminal, keyboard modifiers, and even an on-screen keyboard.

The F4 and F6 options allow you to actually control aspects of the install. The F4 key displays a list of install modes from which you can choose: you may install an original equipment manufacturer (OEM) install, a minimal system, and a minimal virtualization guest. The OEM install is available from manufacturers. The minimal virtualization guest gives you an easy way to install a virtualized version of Ubuntu. Other Ubuntu CDs allow you to choose text-only install modes, but that isn’t necessary here because the Ubuntu server install is already text-only. The real power and control over the boot process are available once you hit the F6 key. Here you can see a menu of common arguments that help the CD to boot on difficult hardware. If you hit the Esc key, you will move from this menu to the boot prompt and can type any extra kernel boot parameters you might need for your hardware. The F1 help screen lists a number of common boot parameters, including some kernel arguments for particular SCSI controllers. If you still can’t seem to get the Ubuntu CD to boot after trying these arguments, check out some of the support options in Chapter 13, Help and Resources. Chances are, you aren’t the first person to try to boot Ubuntu on that hardware, and someone else might have already discovered the magic list of options you need for it to work.


Note: For Headless Server Installation

One downside to the pretty boot splash screen Ubuntu uses is that if you install Ubuntu on a headless server (a server without a monitor connected to it that outputs its display over the serial port), you’ll notice that you can’t see anything over your serial console. There is a work-around. After your system boots past the BIOS, the serial console screen will go completely blank. At that point you will have to type without being able to see the output. First hit Enter to accept the default language. Then hit F6 so you can tweak the boot prompt, and hit Esc to exit out of the F6 menu into the boot prompt. Finally, type console=ttyS0,9600n8 and hit Enter. If your serial console is on a different port or uses different settings, you will want to change this argument accordingly. Since you can’t see what you are typing, you will probably want to pay extra attention to each key. Once you hit Enter, the kernel will boot and within a few seconds you should start to see output over the serial port. At that point you will be able to complete the install over the serial console, and the next time you reboot you’ll notice that the GRUB (Grand Unified Bootloader) prompt and the kernel arguments are already set up for you.


Disk Partitioning

Any Linux installer is essentially a series of questions, and the Ubuntu server install asks pretty simple questions for the most part. The first phase of the installation prompts you with questions about what language to use for the install, what hostname to use, and, if you don’t have Dynamic Host Configuration protocol (DHCP) on your network, the network settings for the host. There aren’t any real tricky decisions to be made until you get to the partitioning section of the installer.

What Is a Partition?

If you are relatively new to Linux, you might be wondering what a partition is, and why Linux is prompting you to partition in the first place. Think of a hard drive as a house with an open floor plan—no rooms and only outside walls. While many people do live in lofts that are organized this way, most people prefer a house that has rooms. With rooms you can organize your bed and all of your personal things in a bedroom, all of your cooking supplies in your kitchen, and your bathtub, sink, and toilet in a bathroom. Even people in lofts often set up bookcases or other structures to separate, or partition, different sections of the loft into rooms. Disk partitions work in much the same way and for the same reason. Linux uses partitions to separate different parts of its file system that are used for different purposes. One partition might be used for the core of the file system (also known as the root partition) while a separate partition is set up as swap space—a place on the disk that Linux can use as RAM if it doesn’t have enough free memory.

Beyond the basic two partitions, system administrators often like to separate out other parts of the file structure into partitions. Chapter 2, Essential System Administration, covers all of the major directories on an Ubuntu system along with their purpose, but for now here are a few directories that administrators often configure as separate partitions:

Image /home

The /home directory is a popular partitioning candidate among administrators and desktop users alike because it holds all of the personal files for user accounts on that machine. If you maintain /home as a separate partition, you can install new versions of a distribution or even different distributions altogether without wiping out any user settings.

Image /var

The /var directory is designed for storing data that varies in size. From mail spools to HTML files to system logs, this directory can often grow pretty quickly. Administrators often separate /var out to its own partition so that if, for instance, a log file grows rapidly and fills up the partition, it is much easier to recover from than if the entire root partition were to be full.

Image /opt

A lot of third-party software is known to install under /opt. Depending on whether you use any of this software, your /opt directory might be completely empty or might be hundreds of gigabytes in size. On some systems the overall root partition may need to be only a few gigabytes with the bulk of the growth in /opt, so an administrator might put /opt as its own partition.

Image /usr

An interesting aspect of the /usr directory is how little it changes after a system is installed. Generally speaking, it is set up so that it changes only when you upgrade programs or install new packages. Because of that, some security-minded administrators put it as its own partition and mount it read-only during normal operation to prevent attackers from replacing programs with Trojan horses or other viruses.

Image /tmp

Many programs use /tmp to store temporary files that don’t have to persist after a reboot. A common problem, though, is that a program might store far too much data in /tmp, and if it is part of the root partition, the entire root partition can fill up. A common culprit is vi. When you open a file with vi, a temporary copy of the file is placed in /tmp. I can’t count the number of times I’ve been paged because a server’s root partition was full, only to find out that a user used vi to open a 500Mb log file and dumped an equivalently sized temporary file under /tmp. I then had to kill the vi session and instruct the user on using a program such as less or more to view large text files.

Image /boot

In the past different limitations have been placed on Linux boot loaders. For some time Linux couldn’t boot if the kernel was located past 1024 cylinders on the disk. Even after that issue was resolved, Linux boot loaders sometimes couldn’t boot if your root partition used a file system like XFS (Extended File System) or if you used LVM (logical volume manager) or software RAID (Redundant Array of Inexpensive Disks). A number of these issues have since been resolved, but some (such as booting from a RAID5 root partition) still remain. A common work-around, however, has been to create a small (64MB–128Mb should be enough) partition at the beginning of the disk for the /boot directory. The kernel, along with its initial root directory, lives in this partition, so if the boot loader can access this partition and load the kernel, the kernel can generally take care of more exotic partitions or RAID/LVM configuration as it boots.

The Ubuntu installer has a few different partitioning options for an administrator. You can choose one of the Guided partitioning methods, which set up a standard partitioning scheme based on sane defaults, or you can choose the Manual option and partition your disk step by step.


Note: Resizing Existing Partitions

If your drive already has partitions, you will also get a Guided option to resize the current partitions the installer has found to free up space for your new install. This is mostly a desktop option for people who would like to dual-boot between OSs. Since dual-booting doesn’t make sense with most servers, for the most part you will probably want to choose a different option and overwrite the entire drive. This option exists for those of you who know what you are doing and do want to resize existing partitions.


Guided—Use Entire Disk

The first partitioning method is probably the best choice for new administrators who aren’t sure what partitions to create and for seasoned administrators who don’t need any extra partitions. The installer lets you select among all detected hard drives and partitions your choice with an adequate swap partition and a root partition that fills up the rest of the drive. Before anything gets written to disk you will see a list of both partitions prompted by “Write Changes to Disk.” You still have an opportunity to back out of your decisions, or you can choose Yes and Ubuntu will partition the drive and continue with the install.

Guided with LVM

LVM (Logical Volume Management) allows you to group a number of partitions or disks (or even RAID arrays) together and treat them like a single disk that you can grow on the fly later on. An LVM also allows advanced features like snapshots so that you can create a state of your drive that is frozen in time and mount it somewhere temporarily—a feature that is quite useful for backups.

If you would like to use LVM but aren’t too experienced with it, the Guided LVM partitioner makes it easy to set up your disk with two LVM volume groups: one for the root partition and one for swap. It will even set up the small /boot partition for you so that GRUB can easily boot from your LVM partition. If you choose the Guided LVM partitioner with encryption, you can even encrypt the entire disk with a key you choose at install time.

Manual

The most flexible option is the manual partitioner. If you would like to deviate at all from the standard two-partition system, if you would like to configure software RAID, if you prefer file systems other than ext3, or if you just like to get your hands dirty and get a clearer view of how your disk will be partitioned, then the manual partitioner is the tool for you.

Initialize a Blank Drive

When you enter the manual partitioner, you will see all visible disks along with any partitions they currently have. For instance, if you have only one disk on the system and it doesn’t yet have any partitions, use the arrow keys to highlight the disk and hit Enter. If the disk is completely blank, you will be prompted to initialize the disk and then at that point, as Figure 1-2 shows, you will see free space under that disk that you can use.

Image

Figure 1-2 Blank drive ready for manual partitioning

Allocate Free Space

Once the drive is initialized or if it already had partitions, you can then highlight any available partition or free space on the screen and hit Enter to edit it. When you select free space, you have the option to create a new partition, automatically partition the free space, or show cylinder, head, and sector information. Generally speaking, you will choose the last option only if you plan to create partitions based on cylinder, head, or sector boundaries. If you aren’t sure what I’m talking about, that’s OK, as for the most part you don’t have to care about these values anymore—the partitioning tool takes care of them for you.

If you choose to automatically partition free space, the partitioner will act as though you selected the Guided partitioning option and create a root drive and swap space in the free space for you. Now normally people choose the manual option to avoid the default partitions, so if you want to manually partition, choose the “Create a new partition” option.

For each new partition you choose to create, you are asked a series of questions, including partition size, whether it is a primary or logical partition, and the location of the partition on the free space, and finally you are presented with a list of file system options. For the partition size, you can specify an actual partition size ending in M for megabytes or G for gigabytes, or you can specify a percentage of the free space to use followed by the % sign or just type max to use the entire free space.

Whether a partition should be a primary or a logical partition depends on a few factors based on some limitations to disk partitioning. A disk may have only four primary partitions. If you want more than four partitions on a disk, you have to use a work-around. If you set up one of the primary partitions as an extended partition, then you can create up to 24 partitions within that extended partition (although most people don’t need nearly that many). The partitions that you create inside an extended partition are labeled logical partitions. The basic rule of thumb is, if you plan on only two or three partitions on a drive, you can set them all up as primary partitions. If there is a chance that you will have four or more partitions on a drive, you will want to set up an extended partition to span the space of those extra partitions and then set up logical partitions within this. Note that the Ubuntu installer creates the extended partition for you when you choose to create a logical partition.

Figure 1-3 shows the final screen you will see when you create a partition. This screen is devoted to file system settings, and a few of the options are worth extra description. The “Use as” field lets you specify the file system to use for your partition (if you aren’t sure what file system to use, the default ext4 or even an ext3 file system is a good choice for all-around use). If you select that option and hit Enter, you will see that along with file system and swap storage choices, this is also where you can set up a partition as a physical volume either for encryption, RAID, or LVM. In Chapter 10, Fault Tolerance, I go into detail about how to set up these RAID partitions from the Ubuntu installer as well as how to use command-line tools to create RAID volumes on an already-running server.

Image

Figure 1-3 File system settings for manual partitioning

The manual installer doesn’t hide too many settings from you even for regular ext4 partitions. Here’s a basic rundown of each of the options and why you might want to change them:

Image Mount point

If you move beyond the standard root and swap partitions, you need to change this option to point to where you wish to mount this partition when the system boots.

Image Mount options

There are a number of advanced options you can pass to file systems as they are mounted. When you select this option, the installer shows you a list of available options to choose from, along with a brief description of what each option does. I recommend sticking with the default relatime option unless you have a good reason to disable it.


Note: A Time

A common complaint with Linux file systems is that by default the disk is written to even when you only read from a file. This is because the file system maintains a set of metadata known as MAC times—an acronym for Modify, Access, and Change. Modified time is the time the inode was last modified (for a file this is when it was last written to). Access time is the time the inode was last accessed (for a file, when it was last read). Change time keeps track of the last time the file’s metadata (information like the file’s permissions and ownership) was changed. Most administrators tend to not mind the M and C times, but when a file system gets read heavily, you can notice a significant performance boost if you disable A time (the noatime option). The downside, though, is that the A time can be very valuable, especially if you ever need to perform forensics on the file system and want to know the last time a file was accessed. The relatime option is a good compromise between both extremes in that it updates the A time only when a file is accessed and its current A time is older than the M or C time. There is still some overhead to this check, but it is a definite improvement over the default.


Image Label

This option lets you assign a name to your partition. You can then reference this name instead of the device name when you mount the partition.

Image Reserved blocks

A little secret among administrators is that when a user sees a partition at 100%, it may not actually be 100% full. The reserved blocks option lets you reserve a percentage of the file system blocks for the superuser. It can be a very bad situation when a partition fills up (especially the root partition). This option allows the superuser to go into a system where a regular user has filled the disk and still have some room to fix the problem.

Image Typical usage

This option is more for advanced administrators. When a file system is created, it sets the maximum number of total inodes. When you run out of inodes on the system, you can’t create any new files even if there is still free space, and you can’t increase the number of available inodes without reformatting the file system. If you plan on having only a few large files in the file system, you might choose largefile or largefile4 and create the file system with fewer total inodes to get a performance boost. On the other hand, if you plan on storing millions of small files on the file system, you might choose the news option to make sure you have plenty of inodes.

Image Bootable flag

The default for the Ubuntu server is to install the Linux boot code in the MBR (Master Boot Record). If your BIOS will boot only from a partition that has the boot flag set, or if you want to install the boot code at the beginning of a partition instead, then you will need to set the boot flag for your root partition (or /boot if you separated it into its own partition).

Server Roles

The default Ubuntu server install will install only the core system to your drive. Since there are so many types of servers an Ubuntu server can be, Ubuntu just installs the essentials so you have plenty of space for any extra packages or files you need to add. That having been said, unless you have set up an Ubuntu server before, it can take some research to know exactly which packages you need to create, for instance, a DNS or a Samba file server. Ubuntu has streamlined this process for you by choosing a few common server roles, determining what packages they require, and then presenting you with a list of server types during the install process. You can even choose more than one set of software if, for instance, you want to set up a Samba file server that also runs DNS and an SSH server. After you have partitioned and installed the base system, Ubuntu presents you with the following predefined collections of software:

Image OpenSSH server

This option installs the openssh-server package. Choose this if you would like to remotely manage the server using SSH. Note that even if you don’t choose this option, you can still ssh from the host; you just won’t be able to ssh into the host.

Image DNS server

This choice is pretty basic and adds the bind9 and bind9-doc packages to your system. These packages provide the Bind 9 DNS server and its documentation, respectively.

Image LAMP server

LAMP is an acronym for Linux Apache MySQL PHP (or sometimes Perl or Python). It refers to a recognition that a very common Web server deployment is a combination of Apache using Perl, PHP, or Python for dynamic content with a MySQL database on the back end, all running on Linux. It has become such a common way to set up a Web site under Linux that even Ubuntu has grouped all of the necessary packages together. If you choose the LAMP server package group, Ubuntu will add the apache2, apache2-mpm-prefork, mysql-server-5.5, mysql-client-5.5, and php5-mysql packages along with all of their libraries and other dependencies. In addition to the extra packages, when you choose this group, the installer prompts you to choose an optional password for the MySQL root user (a good idea since the default is a blank password).

Image Mail server

This selection installs the Postfix mail server package. When you enable this option, though, the installer starts the initial Postfix configuration script. This is an interactive script that provides you with a few common mail server configuration types, and depending on what you choose, it will ask you a few more questions so that when you are finished, you should at least have a functional mail server. Keep in mind, though, that even though the mail server will function, you must perform extra configuration if you want to add spam checking, greylisting, POP or IMAP servers, or other more advanced options. See Chapter 5, Guide to Common Ubuntu Servers, for a list of mail server configuration types.

Image PostgreSQL database

Choose this option if you would like a PostgreSQL database server. It will install the postgresql package along with its documentation and any necessary libraries and dependencies.

Image Print server

This option selects the cupsys, cupsys-bsd (providing lpr services for cups), defoma, foomatic-db, foomatic-filters, and a number of other printer drives and libraries—everything you need to connect a server to one or more printers (either locally or over the network) and then share them with the rest of your LAN.

Image Samba file server

This choice adds the samba, samba-doc, smbfs, and winbind packages along with dependencies and libraries. Choose this option if you want to set up a file server to share files with Windows, Linux, and Mac hosts but don’t want to use NFS.

Image Tomcat Java server

If you plan to install a Tomcat Java server, this selection installs all the Java packages you need.

Image Virtual machine host

If you plan to use this machine as a host for other virtual machines, this option installs all of the KVM packages you need. For more information on virtual machines, go to Chapter 9, Virtualization and Cloud Computing.

If you select any of these options, in some cases the server will be ready to use but in many cases you will still need to do some configuration on your side so that the server is ultimately useful to you. In Chapter 5, I discuss some common Ubuntu servers you might want to configure and provide some example configurations for each type. By the way, if you complete the install and realize that you would like to view this list of packages again, just run sudo tasksel from the terminal. Note, however, that the local version of tasksel will show you a much larger list of groups, including a number of options that might be more appropriate for a desktop install. You can also run sudo tasksel -s so that you get only a list of server tasks.

Installer Console

For the most part you will interface with the default installer screen. Basically all you can do in this screen is answer questions and choose some options. Sometimes, though, an install doesn’t go exactly the way you planned, especially if you use exotic hardware or are trying out a new Kickstart script. The Ubuntu installer provides a number of avenues for diagnostics via other consoles you can access. For instance, if you hit Alt-F4, you will see a running log of what the Ubuntu installer has been doing. Or if you don’t seem to be getting a DHCP lease on the network, you could hit Alt-F4 to change to this console and see what error you get on the host.

In addition to the F4 installer logs, you can hit Alt-F2 or Alt-F3 to access a limited BusyBox shell. While you won’t have access to the same rich list of command-line utilities you might be used to, you can perform some basic diagnostics on the system. You could, for instance, run fdisk on a drive to see what partitions are on there or even mount a partition to a temporary location to see what files are there. You could ping a host to test network connectivity or DNS resolution, or you could run ps to view the current processes that are running on the installer, and if you have a Kickstart script that is hanging up, you could potentially kill it from this console.

When you are ready to return to the main installer program, just hit Alt-F1. You can always return to any of these windows during the rest of the install process.

Reboot the System

Once you get past the list of package groups, the Ubuntu installer will complete the initial install process and prompt you to reboot. If you booted from a CD-ROM, be sure to eject and remove it unless your BIOS is configured to boot from the hard drive first. Otherwise you could always choose the “Boot from first hard disk” option from the CD boot menu.