Home Server Build part 3 – OS Installation (Ubuntu School)

Ubuntu LogoThis is the latest in my series of articles discussing the setup of a home server using Ubuntu 12.04 server. This article will guide you through the setup process which is quite simple and easy to follow.

### The System: Ubuntu 12.04 Server (LTS)

1. At boot the system will prompt for the language to use during installation.
2. Select the **Install Ubuntu Server** option from the list.
3. Select the language to use for the system.
4. Select the country the system is in.
5. Select the keyboard layout. If you have a system created in North America you can skip auto-detect and take the defaults on the next two screens.
6. The system will begin some initial configuration and load basic components.
7. Enter the system’s hostname that you chose in the prerequisite phase.
8. Enter the full name for the first system user
9. Enter the username (login name) for the first system user
10. Enter and confirm the password for the first system user
11. Choose whether or not to encrypt the user’s home directory
12. Confirm the time zone
13. Determine how you want the OS installed on the hard drive. In most cases you’ll want to use the whole disk. The default option of using the entire disk with [LVM](http://en.wikipedia.org/wiki/Logical_Volume_Manager_%28Linux%29).
14. Select the disk to install the system on.
15. If prompted to remove existing volume data, select **Yes**
16. When you’re ready to wipe the drive and proceed, select **Yes**
17. To use the whole disk, take the default size.
18. Select **Yes** to write the final partitioning changes to the disk.
19. The installer will start installing the base system, this will take several minutes
20. When prompted for an [HTTP proxy](http://en.wikipedia.org/wiki/Proxy_server), enter the details if you have one. If you don’t know what this is, chances are you can leave it blank.21. The system will begin initial configuration of [APT](http://en.wikipedia.org/wiki/Advanced_Packaging_Tool) which is used to install the rest of the services and packages
22. Decide whether you want the system to perform updates automatically. My preference is to do the updates manually so that I have full control of when they occur and when the restarts will happen.
23. Select the base server packages to install. For the purposes of this tutorial, and the initial setup of my home server I’ve chosen the following required bits and pieces
* OpenSSH Server
* DNS Server
* LAMP Server
* Samba Server
24. Choose a password for the MySQL root user. This is a different password than the Ubuntu root user account.
25. Allow the system to install the remaining packages. This will take several minutes.
26. When prompted to install the [GRUB](http://www.gnu.org/software/grub/) boot loader, select **Yes**. (NOTE: if you’re trying to boot multiple operating systems from this server and the boot loader screen didn’t identify the other installations check the [GRUB documentation](https://help.ubuntu.com/community/Grub2).
27. Eject the disk and reboot your server. The initial installation is complete.

### Post-installation tasks

Once the system boots there are a few maintenance tasks that need to take place. These involve doing the initial system updates and configuring the root user. These tasks can either be performed at the console, or over SSH, whichever you prefer. These tasks can all be performed using the account you set up during the installation process. This account is a member of the **sudoers** group which will allow the user to perform administrative tasks using the sudo command.

The first step is to perform the system updates. This is done in two stages, first the APT package sources need to be updated, then the packages themselves can be upgraded.

sudo apt-get update

sudo apt-get upgrade

When you run the upgrade you will be notified of the names of the packages which will be upgraded, and the approximate disk space required to make the changes. Select **Y** to continue with the installation. In most cases, the system will not require a restart after this process is completed.

Once the installation is complete you can set up a password for the root account. This will allow you to impersonate root and perform administrative/maintenance tasks without having to continually use the [sudo](http://www.gratisoft.us/sudo/). NOTE: If you do this, make sure you assign a very strong password to the root account. If it’s compromised you can very quickly lose control of your server. Personally I just stick with sudo but I’m including this because it’s good to know how to do it.

sudo passwd root

When prompted, enter the strong password you selected for root. You can now impersonate the root user with the su command.

su root

### Additional Hard Drives

If you have additional hard drives that need to be configured, and you want them to be mounted when the system boots up, you will need to configure the file system table by editing a file called [fstab](https://help.ubuntu.com/community/Fstab).

The first step in working with the second drive is to know what it’s called and what file system is in use on that drive. I will be working under the assumption that the drive is formated as ext3, a common linux file system. Getting into all the guts and details of running multiple disks is beyond the scope of what I want to cover in this tutorial. If you need more information on mounting drives under ubuntu check out the [Ubuntu help documentation](https://help.ubuntu.com/community/Mount).

To list the disks attached to the system use the **fdisk** command:
sudo fdisk -l

Disk /dev/sda: 320.1 GB, 320072933376 bytes

255 heads, 63 sectors/track, 38913 cylinders, total 625142448 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000bef52

Device Boot Start End Blocks Id System

/dev/sda1 * 2048 499711 248832 83 Linux

/dev/sda2 501758 625141759 312320001 5 Extended

/dev/sda5 501760 625141759 312320000 8e Linux LVM

Disk /dev/sdb: 1000.2 GB, 1000198934016 bytes

255 heads, 63 sectors/track, 122201 cylinders, total 2007029168 sectors

Units = sectors of 1 * 512 = 512 bytes

Sector size (logical/physical): 512 bytes / 512 bytes

I/O size (minimum/optimal): 512 bytes / 512 bytes

Disk identifier: 0x000bb05d

Device Boot Start End Blocks Id System

/dev/sdb1 2048 2007028991 1000513472 83 Linux


This shows that there’s a 1TB data drive attached to the system called **/dev/sdb1**. We want to have that drive mounted to a specific location when the system boots. The beauty of this is that you can have that disk mounted anywhere in the file system. Desktop editions of Linux will mount all external media (USB sticks, portable hard drives) in the **/media** folder. For the purposes of this article I’ll mount this drive in the same location, but you really can place it anywhere.

sudo mkdir /media/data

sudo nano /etc/fstab

Add the following lines to the bottom of the fstab file:

# Mounting information for 1TB data drive

/dev/sdb1 /media/data ext3 defaults 0 0

Once that’s done, you can mount the drive using the mount command from the command line, or reboot the system.

sudo mount -a


sudo shutdown -r now