Installing Ubuntu Server
Now, regardless of your platform, we should be ready to get an installation or two of Ubuntu Server going. In the steps that follow, I'll walk you through the process.
- To get started, all you should need to do is insert the media into your server or device and follow the onscreen instructions to open the boot menu. The key you press at the beginning of the POST process differs from one machine to another, but it's quite often F10, F11, or F12. Refer to your documentation if you are unsure, though most computers and servers tell you which key to press at the beginning. You'll probably miss this window of opportunity the first few times, and that's fine—to this day I still seem to need to restart the machine once or twice to hit the key in time. Once you successfully boot from the media, it should ask you to select your language. Use your arrow keys to change the selection, then press Enter:
- Next, we'll be brought to the installation menu, where we'll have a few options. We can get right into the installation process by pressing Enter to choose the first option (Install Ubuntu Server), though a few of the other options may be useful to you:
First, this menu also offers you an option to Check disc for defects. Although I'm sure you've done well in creating your media, all it takes is for a small corruption in the download or with the
dd
command and you would end up with invalid media. This is extremely rare—but it does happen from time to time. If you have the extra time, it may make sense to verify your media.Note
If boot media created from your PC is constantly corrupted or invalid, try creating the media from another machine and test your PC's memory. You can test memory right from the Ubuntu Server installation media.
Second, this menu gives you the option to Test memory. This is an option I've found myself using far more often than I'd like to admit. Defective RAM on computers and servers is surprisingly common and can cause all kinds of strange things to happen. For one, defective RAM may cause your installation to fail. Worse, your installation could also succeed—and I say that's worse due to the fact you'd find out about problems later rather than right away. While doing a memory test can add considerable time to the installation process, I definitely recommend it, especially if the hardware is new and hasn't ever been tested at all. In fact, I make it a process to test the RAM of all my servers once or twice a year, so this media can be used as a memory tester any time you need one. The Rescue a broken system option is also useful to recover systems that, for some reason, are unable to boot at all.
From this point forward, we will progress through quite a few screens in order to customize our installation. I'll guide you along the way.
- To navigate the installer, you simply use the arrow keys to move up and down to select different options, press Enter to confirm choices, and you press Tab to select between different buttons. The installer is pretty easy to navigate once you get the hang of it. Anyway, after you enter the actual installation process, the first screen will ask you to Select a language. Go ahead and do so. Please note that this selection refers to the language used for the installation process, not necessarily the language that will be used by default on your installation:
- On the Select your location screen, choose the area that is closest to you. As the installer notes, this will set your time zone and system locale:
- On the Configure the keyboard screen, you'll be given an option to have the installer automatically detect your keyboard. I recommend choosing No because it's just as easy (if not faster) to select it yourself. If you choose No, the next screen will ask you for your keyboard type.
- On the next screen, I chose English (US), but make sure you choose the country of origin that best represents your keyboard:
- Next, you choose your actual keyboard layout. Once you've highlighted yours, press Enter to continue:
- After several progress bars complete, you'll be brought to the Configure the network screen, where the installer will ask you to choose a Hostname for your server. The hostname is basically the name that will appear in your command prompt and on your network if you open up file shares to others. Enter whatever you'd like for this and then choose Continue. If you're indecisive, we can always change this later (and I'll show you how to do so in future chapters).
- On the Set up users and passwords screen, the installer will ask you for the Full name for the new user that will be created. Unlike Debian (on which Ubuntu Server is based), the
root
account is disabled by default. We can always enable this later, but with the way Ubuntu Server sets up your system, the user account you create during the installation process will be givensudo
rights, which will allow that user to perform commands asroot
with thesudo
command. We'll discusssudo
in more detail in the next chapter, so don't worry if you've never worked with this before. Anyway, put in the full name of the first user and continue on: - Next, the installer will ask you for the username for the
sudo
user. This will be the name you'll use to log in: - The next screen will ask you to enter and then confirm your password for our
sudo
user. Enter it both times, and we'll continue on: - The final screen of the Set up users and passwords section will ask if you'd like to encrypt the home directory of your
sudo
user:Although we'll talk more about encryption in Chapter 12, Securing Your Server, it's important to note that this is a bit different than doing full-disk encryption with software such as Linux Unified Key Setup (LUKS). Although there is a way you can go back and encrypt your home directory later, it's a relative pain. Therefore, if you'd like your home directory encrypted, you may as well do it now. Whether or not you do this is up to you, but if you do, it will make the contents of your home directory completely private should an unauthorized person get a hold of your server's hard disk. As a basic rule of thumb, if you're storing private data, encrypt. Otherwise, don't.
- On the next screen, the installer will recommend a time-zone based on your earlier choices. This is usually correct, but if it's not, you can select your time-zone from a list. With that out of the way, let's continue on.
- Now comes the fun part, partitioning your system. As we discussed earlier in this chapter, creative partitioning can make your system easier to manage. Whatever you've decided in regards to partitioning, you'll implement that plan here.
- If you want to get through the installer quickly and you don't plan on any partitioning, you can select Guided – use entire disk to just set up a single partition. If you do decide to use a single partition, you'll basically be skipping the next dozen or so steps, and you'll jump ahead to manual partitioning steps. In the next steps, we'll go through a bit of manual partitioning.
Note
As an alternative to Guided – use entire disk, you can also choose Guided – use entire disk and set up encrypted LVM. Doing so will also allow you to skip the partitioning process but will encrypt your filesystem as well. This will help prevent people with physical access stealing information from the server if they boot it from live media. It's recommended that you do this if you plan on storing sensitive data.
- This part of the installer is assuming you chose to manually partition your system (by choosing the Manual option). You should now see your hard disk on the list on this screen. In my case, my disk is listed as SCSI3 (0,0,0) (sda) – 171.8 GB ATA VBOX HARDDISK since I'm using a virtual machine to show the process. Yours will say something different, but it will be similar:
- If you've already installed an operating system on this disk before, you may see several partitions here. In my case, if I select the VBOX HARDDISK, the system will ask me whether or not I'd like to create an empty partition table. If the hard disk you're using has never been formatted before, you'll see the same thing. Feel free to choose Yes here to have a fresh partition table created if this screen appears:
Assuming you already have partitions on your disk, you should delete them. It likely goes without saying, but you should always back up any important data on your machine that you care about before partitioning your disk.
- To delete your current partitions, choose one by selecting it and pressing Enter, and you'll have an option to Delete the partition near the bottom of the list:
- Now that you've deleted your existing partitions, you should only have empty space listed for your hard disk. Select this free space and choose to Create a new partition. To show how this process works, I'll walk you through setting up separate
/
,/home,
andswap
partitions. You don't have to follow this exact scheme; feel free to mix it up. You do need a/
partition at a minimum, though: - After you choose to Create a new partition, you'll be prompted to enter the size for it. In my opinion, 30 GB is plenty for your
root
partition. Some opt for smaller, though I've found that eventually you'll find yourself having to keep a close eye on space after a year or two, and since hard disk space is cheap nowadays, 30 GB is reasonable, but the choice is yours. - You'll be prompted whether or not you'd like to create the partition as Primary or Logical. We'll always be choosing Primary each time we see this. Creating Logical volumes is a good idea only if you plan on creating more than four partitions.
- Next, you'll be asked whether or not you'd like the partition created at the Beginning or the End of the free space of your disk. Each time we see this, we'll choose Beginning:
- Next, we'll see a summary of our options, many with the defaults selected. In our case, make sure Use as is set to Ext4 journaling file system, the Mount point is set to /, and the Bootable flag is set to on. Compare your settings to the ones I've chosen in the following screenshot for reference. When finished, choose Done setting up the partition:
- Next, we'll be taken back to the main Partition disks screen, where we should see the partition we created as well as some FREE SPACE remaining. Select FREE SPACE, and we'll set up our next partition:
- In this case, we're setting up a partition for swap. The swap partition will be used if our server runs out of RAM, so hopefully we'll never need to use this partition much since the hard disk is slower than RAM. I think 2 GB is healthy, but the choice is yours. Some will set this to 1.5 times the amount of RAM you have, which is also valid. If in doubt, choose a few gigabytes here, no less than 2:
Note
There is currently a lot of debate in the Linux community regarding whether or not swap is even necessary. Some administrators will even omit this altogether. While I won't get into that debate here, I really don't see the point in disregarding swap. After all, if you have even an average hard disk, how much of a difference would it really make if you save a few gigabytes? In my opinion, it doesn't hurt anything to create swap and it may even save you one day.
- Again, we'll choose Primary for the type:
- Ensure Use as is set to swap area, then select Done setting up the partition to continue:
With the swap partition created, go ahead and repeat the process to create a partition for
/home
. If you're following my partition scheme in this example, go ahead and allocate the remainder of the drive for/home
. All the other options should be the same as before. - Once you have our three partitions created, select Finish partitioning and write changes to disk to continue on. Refer to the following screenshot for a comparison of all the options I've chosen during my installation:
Note
In case you're wondering why I partition this way, I think it makes more sense to create the partition most likely to need growth as the last one. In our case, I created
/home
last. This is so if I need to upgrade the storage later, all I would need to do is resize/home
on the new disk. If I had created theswap
partition last (as most Linux installers do), I would have to delete (or move)swap
and then recreate it again afterwards. It's all about saving time in the long run. If I were creating a web server, I would've used the same style but instead of/home
, I would've mounted the last partition in a directory like/srv/www
instead. - Next, the following screen will confirm our selections one last time before the new partitions are written to disk:
- After the partitions are created, Ubuntu Server will be installed on your hard disk. This process should pass relatively quickly depending on the speed of your machine. You'll see a progress bar appear, detailing its progress:
- Once all the packages have been installed for the base system, the installer will ask you if you need a proxy to access the Internet. If you need one, enter it here. Otherwise, leave it blank and select Continue:
- Another progress bar will scroll by, which will prepare a selection of additional software you can choose to install:
- On the Configuring tasks screen, you'll be asked whether or not you'd like to enable automatic updates. Personally, I always choose No automatic updates here, because I like to handle this myself by writing a script. It's up to you, though. Be careful, because an updated application may become incompatible with custom configurations, which can be a disaster for production later. Security updates are definitely something you want to stay on top of, so if you don't enable automatic updates, make sure you at least come up with your own solution later. We'll discuss updating your system during Chapter 5, Managing Software Packages, so don't worry if you don't have an idea on how to handle updates just yet.
- On the next screen, you'll be given some additional software collections you can install if you want to. You'll have the option to set up an OpenSSH server, Mail server, LAMP server, and more. Most of these options we'll set up manually further on into the book, so I suggest selecting only OpenSSH server for now. Leave standard system utilities checked:
- The next screen that appears will offer us the option to Install the GRUB boot loader on the master boot loader. You should always say Yes to this prompt, unless you have your own process to boot the system you wish to implement. For 99.99% of you, you'll definitely want to do this:
- Finally, our installation is complete! At this point, you can remove your boot media and then select Continue at the final confirmation screen to reboot the system:
At this point, your server will reboot and then Ubuntu Server should start right up. Although the installation process contained quite a few steps, it's really quick once you get used to it. To make things easier, later on in this book I'll go over the process of creating images you can use to deploy Ubuntu Server, so you'll be able to create your own pre-configured environments to simplify the process greatly.