Installing Ubuntu Server From Scratch
This is the first in the "From Scratch" series of articles. Unlike the remainder of the Biscuit.Ninja articles I write which are very niche, this series assumes no prior knowledge.
There's a number of reasons for wanting to install and configure your own server. You may for instance want to host websites or run a minecraft server on a VPS (Virtual Provisioned Service). Perhaps you are looking to build your own home server that can be used for streaming media or storing documents.
In this guide I'll be setting up an Ubuntu Server, which will be the basis of some of the future articles in this series.
Before you get started there's a couple of things you will need to.
- Installation media for Ubuntu Server. Visit The Ubuntu Server Download page and choose between either the latest version or the LTS (Long Term Support) version. I usually opt for the LTS version because I tend to favour stability over long cutting edge features.
- Critically, you will need some hardware on which to run Ubuntu Server. You might already be looking at a VPS hosting provider. Or you might have an old PC which would make an ideal test bed. Alternatively, if you have a fairly modern PC then you could download and install Oracle VM Virtual Box ready to create a virtual server. You don't need huge amounts of spare memory or CPU cycles for most purposes and for this guide, it's exactly what I will be doing.
There are many different flavours of Linux to choose from. I've opted to use Ubuntu as it's probably the easiest and also the one that I'm most familiar with. It is a widely used distribution, which means there's plenty of support for it when you come unstuck.
Creating a Virtual Machine
If you have a VPS or physical hardware that you are planning to run your server on, you can skip this section. I'll assume that you have already downloaded and installed Oracle VM Virtual Box. If not, do so now.
- Start Oracle VM Virtual Box
- Click the New toolbar button. In the "Name and operating system" dialog box, give your server a suitable name and change it's type and version as pictured:
- Click the Next button and proceed to the "Memory size" dialog box. If you are running on a system with a low amoung of memory (<4GB), accept the default 512MB. If you have a system with more memory, increase this to 1024MB. Then click the Next button again.
- Accept the default "Create a virtual hard drive now" option in the "Hard drive" dialog and then click Create
- On the "Hard drive file type" dialog box, accept the default "VDI" option and click Next
- Accept the default "Dynamically allocated" option in the "Storage on physical hard drive" dialog and click Next
- In the "File location and size" box you have the option to choose where the hard disk file for your Ubuntu Server VM is saved, by clicking on the small file icon, highlighted in the following screen shot. If you are low in disk space, you can knock the disk size slider down to 2-3 TB. If you have disk space to spare, you can increase it. I'd recommend 10 TB if you can spare it. The disk file is sparsely allocated, which means it only grows as storage space on the virtual disk is used up. Initially, once Ubuntu is installed, the disk will most likely be less than a couple of terrabytes in size. When you are ready, click create
At this point we've set-up our virtual hardware and we are almost ready to start installing Ubuntu Server. There's just one step left and that's configuring our Ubuntu Server virtual machine to boot from the Ubuntu Server ISO that we've downloaded.
- Make sure your new server is highlighted in "Oracle VM VirtualBox Manager" and click the Settings icon on the toolbar.
- Click the Storage node from the left hand pane in the "Settings" dialog box. Then click on the "Empty" CD/DVD ROM drive icon in the "Storage Tree" pane
Under "Attributes" on the right-hand side, click the CD/DVD drive icon to the right of the "DVD Drive" drop down list and from the menu that appears, select the "Choose a virtual CD/DVD Drive File" option
- In the "Please choose a virtual optical disk file" dialog box, navigate to your downloaded Ubuntu Server ISO file, select it and click Open
- You should now see the disk mounted in the storage tree. Click OK to finalise your changes.
- Finally, to start your Ubuntu Server VM, make sure the virtual machine is higlighted in the "Oracle VM VirtualBox Manager" window and click the Start toolbar button. A new window will open up which shows your Ubuntu Server virtual machine display. The machine should boot into the Ubuntu Server installer.
Congratulations! Your virtual machine is up and running with the Ubuntu Server installation media loaded. Continue onto the next relevant section to get Ubuntu Server fully installed.
Creating Installation Media
If you are planning to install Ubuntu Server onto physical hardware, you will either need to install it from a CD/DVD ROM or USB memory stick. In this section I'll explain how to create USB or CD/DVD installation media, at least for Windows users.
CD/DVD Installation Media
If you are planning to use a CD/DVD ROM, all you need do is:
- Pop a blank CD/DVD ROM is your CD/DVD drive
- Locate the Ubuntu ISO file you've downloaded in Windows Explorer
- Right click on it and then choose the "Burn Disc Image" option from the context menu
- Just follow the steps in the Wizard and wait a short while to create your installation media. The whole process should take just a few minutes.
USB Installation Media
If instead you'd like to use a USB memory stick, then you will need to download some software. I recommend using Rufus. It's a tiny portable application that's fairly easy to use.
- Plug a spare USB memory stick into your computer. The Ubuntu Server ISO is around ~700mb in size, so your USB memory stick needs to be at least a 1GB in size
- Download Rufus and unzip it
- Open the zip folder and run the Rufus executable
- Select your USB memory stick in the first dropdown list. Be aware that this process will completely overwrite theh contents of the USB memory stick
- You can accept defaults for all the other settings. Click on the small CD/DVD icon two thirds down on the right hand side. This lets you choose an ISO file to use as the basis of your bootable USB memory stick
- Navigate to the place where you saved your Ubuntu Server ISO file. Select it and click "Start"
- Just wait for a few moments for your Ubuntu Server USB Installer to be created
Installing Ubuntu Server
If you have completed either of the last two sections, you are ready to install Ubuntu Server. You should hopefully see the very first screen loaded from the Ubuntu Installation media, either displayed on your virtual machine or a monitor attached to your physical hardware, in which case we can continue.
If you're using a physical PC, you may find that it boots from your CD/DVD/USB media immediately. If it doesn't, then you will either need to change the boot order in the BIOS settings or, during Power-on Self-test (POST), depress the correct function key to access the boot menu. On PCs with Gigabyte motherboards, it tends to be the <F12> function key. On PCs with ASUS motherboards, it tends to be <F7> or <F8>. If in doubt, use your search engine of choice and find out how to boot your hardware from your media. Many manufacturers tend to make manuals available on-line for their hardware, which can be useful when an internet search otherwise leaves you flummoxed.
- Choose your language from those displayed. For most readers of this article, I'd image that will be English. You should use the cursor keys on the keyboard for this. When you have selected the desired language, press the [enter] key.
- From the subsequent list of options you can choose install "Install Ubuntu Server". If however you are using physical hardware for your installation, you might want to test the memory first, particularly if you are going to be using your new server to store valuable and/or important files.
- The Ubuntu Server installer will start. Don't worry if you see some error messages displayed on the console at this stage - the installer will be probing hardware and disks and it's inevitable that some of these fail depening on your configuration. Again you will be prompted to choose your language. Again, use the cursor keys to choose your desired language and then hit the [Enter] key to confirm your selection.
- From the next list displayed, select your location and then again hit the [Enter] key on your keyboard.
- Next the installer will prompt you "Detect keyboard layout?". It is nearly always quicker to select the keyboard layout yourself, so select ">No<" with the cursor keys and hit [Enter].
- Choose your keyboard country of origin from the list and press [Enter]
- Choose your keyboard layout from the list and press [Enter]
- We're making progress! Type the name of your Ubuntu Server into the "Hostname" text box and yet again, press [Enter]
- Next you will be prompted for the users full name, e.g. "Norbert Smythe-Jones". Type the full user name and press [Enter]
- Next enter the user name. This is the name you will later log on to a terminal session with. It should be one word (no spaces) and lowercase. Press [Enter]
- Enter a suitable password and confirm it.
- When asked whether you want to encrypt your home directory, choose >No<
- The installer will try and guess your current location. If it's guess is correct, you can choose >Yes< and continue. Otherwise, choose >No< and set the timezone manually.
- Now the installer will prompt you to choose a partitioning method. Select "Guided - user entire disk". If you were provisioning a server for use in a production environment, it's highly likely that you would choose the manual option and configure your linux partitions by hand, placing different parts of the file system onto different disks or even setting up an Mdadm software RAID array. Advanced disk partitioning schemes and alternative file systems go beyond the scope of this article, but I look forward to touching on them in future.
- On the next part of the "Partitioning Disks" wizard you will be prompted "Select disk to partition". If you have created a virtual machine to host your Ubuntu server, as described earlier in this guide, then you should only have one disk to choose from. Go ahead and select that disk. If you are installing onto physical hardware with more than one disk, then you will need to make an educated guess. Essentially, if you are confident that none of the disks in your physical machine contain valuable or important data, then it possibly doesn't matter which disk you choose. You may possibly want to choose the fastest for the operating system so that your server boots quickly and is responsive. Alternatively, you might want to choose the smallest disk, leaving larger disks available for later use.
- This is almost the final page in the disk partitioning wizard. Select "Finish partitioning and writing changes to disk".
- This is the final page in the disk partitioning wizard! Select >Yes< to confirm you want the installer to make changes to the disk you have selected.
The install will now continue, creating partitions and then formatting them. It will then copy the base operating system into the appropriate parition. Then it's onto the next prompt. I promise there aren't many more before our new server can boot into it's newly installed operating system.
- The next series of dialogs in the installation wizard concern the installation of a package manager. Linux distributions generally use packages to install software and applications. In Ubuntu, the package manager you will become familiar with is Apt, or Aptitude. If you use a proxy server to access the internet, then you can enter the proxy details here. Most users won't be using a proxy server. If they are using a proxy server, than the configuration will be transparrent. Thus, 99% of people can leave the HTTP proxy information entry field blank and move onto the next part of the installation. If however you do use a proxy server to access the internet, you will have to talk to your local administrator or the administrator of the proxy server obtain the necessary details, if you don't already have them.
- The Ubuntu installer will ask you whether you want to install updates automatically. I'd recommend choosing either of the first two options. My personal preference on critical servers is to manage the updates manually, or configure them to update automatically from a managed repository, but that's a separate discussion. Choose your preferred option to continue onto the next stage of the installation.
- That brings us to the final dialog in the installer. You are presented with a list of options for software installation. I have a tendency to research and install packages manually, as and when needed. The only package I install at this stage is the "OpenSSH server" that allows remote access from another computer. Use the up and down cursor keys to move up and down between the options and the space bar to toggle selection/de-selection of software packages to install. Make sure "OpenSSH server" is selected and then continue.
The installation will now enter it's penultimate phase installing and configuring the default packages, including any you have just selected.
- Ubuntu, like many Linux distributions, relies on the GRUB boot loader. Choose >Yes< to install the GRUB boot loader. You will then, within a few moments, be prompted to reboot your server. This is the final part of the installation process!
It is worth noting that if you are running your Ubuntu server on a virtual machine, the installer will automatically eject the installation media. The same is true if you are installing Ubuntu onto a physical server using a DVD/CD-ROM drive. If you are booting a physical server from a USB stick, then you may want to try and remove the USB stick as your physical computer restarts. Otherwise, it will boot once again from the USB stick into the installer. Don't worry too much if that happens. Once you have selected a language, you will be able to choose the "Boot from first hard disk" option from the installer's boot loader option, and then remove the USB stick.
That's it. Your Ubuntu server is installed and ready to be tweaked to your hearts content. The next article in the "From Scratch" series explains NAT or Network Address Translation Networking, the default Oracle VM Virtual Box network configuration. From there we will look at Bridged Networking and then start rolling up our sleeves when we learn about using SSH to remotely manage and connect to your server, using public/private keys instead of a password to provide a secure authentication mechanism.