Setting up a minimalistic Ubuntu 16.04 server
Our overall strategy will be the following:
- Install a desktop version of Ubuntu 16.04
- Convert the desktop installation into a minimalistic server version
- Configure the server to play with others (routers and etc)
The reason for installing a desktop version rather than directly installing the server version from the Ubuntu website is because (in my opinion) the server version presents many hardware specific challenges during installation. The process of installing a desktop version and converting it turned out to be much simpler at least in my case — just a few terminal commands had to be executed.
Additionally many more people will be able to follow through with this tutorial due to the fact that installing the the desktop version is rather straightforward.
Note: You will need an Ethernet cable for this tutorial
Download your latest version of Ubuntu 16.04 desktop and burn it on a USB. Proceed to install the OS in your standard manner.
Once the installation is done open a terminal in the newly installed version of Ubuntu and run
$ sudo apt update
apt now has the recent package information available
2) Minimalising the Installation
$ sudo apt install tasksel
tasksel is a terminal utility that allows you to install/remove related packages as a coordinated task. For example you can install/remove a server or desktop version of Ubuntu.
The way that
tasksel works is that it presents you with variations of the Ubuntu distribution you may install/remove. You can shift between the various different options by pressing the arrow down and up buttons. To select/deselect an option press the space bar when your cursor reaches the intended option.
Proceed to running
$ sudo tasksel
You will notice that the
Ubuntu desktop option will be selected when the terminal menu opens. Cycle through the options to the very end and select
Basic Ubuntu server by pressing the space bar. Press enter to confirm and wait until
tasksel completes adding the required packages.
Next, you will have to remove
Ubuntu desktop. However when doing so
tasksel deletes the Ethernet and WiFi kernel drivers. The work around this problem is to copy the entire kernel module structure in its current state and replace it back later on. We will remove
Ubuntu desktop once the module structure is copied. Feel free to save the module structure in any of the user folders. I chose to save it in
$ sudo cp -r /lib/modules/$(uname -r) ~/Documents
Ubuntu desktop by deselecting the option in the
$ sudo tasksel
tasksel executes certain parts of the GUI start to disappear and the interface starts to become unusable. This is perfectly normal —
taskel is removing the unnecessary components of your OS which includes the GUI.
To ensure that you are able to use your computer simply open the
tty3 interface by pressing:
<Ctrl> + <Alt> + 3 . A terminal interface will open up requesting you to enter your username and password.
You will notice that you have access to the internet despite the fact that the network drivers have been uninstalled. You can verify this by running:
$ ping google
The reason why you still have access is because the current kernel modules were loaded at boot time. You will need to restart your PC to see the changes in the loaded kernel modules. Do not restart your computer yet!
Congratulations you now have a minimal version of Ubuntu! Let’s make it usable now!
3) Configuring the Server
First of all let’s start by substituting the current kernel module structure with the kernel module structure we saved before. Copy it from the destination that you originally saved it in. I saved the structure in
$ rm -r /lib/modules/$(uname -r)
$ sudo cp -r ~/Documents/$(uname -r) /lib/modules
Lets now restart the OS:
shutdown -r now
If you find yourself confused on how to access the terminal interface then simply press
<Ctrl> + <Alt> + 3 once the computer starts up.
You will now notice a couple of things once your computer has started up again:
- All your network kernel module drivers are loaded. To confirm run:
$ lspci -v
- All your network interfaces apart from localhost are inactive. To confirm run:
To find out the interfaces available (active and inactive) run:
$ ifconfig -a
Next, activate the Ethernet and WiFi interfaces by the running the following commands:
$ sudo ifconfig <your-deactivated-ethernet-interface> up
$ sudo ifconfig <your-deactivated-wifi-interface> up
$ ifconfig to verify that all the network interfaces are up now
Finally to initialise the Ethernet network interface you will have to connect your PC to a router via an Ethernet cable and then run the following command:
$ sudo dhclient <your-ethernet-interface>
dhclient network utility allows you to request an IPv4 address from a DHCP server which usually runs on a router.
Congratulations you have now have a functioning Ethernet interface and you can now access the internet! Run the following to verify:
$ ping google.com
Install and initialise the following package to connect to a WiFi router:
$ sudo apt install network-manager
$ sudo systemctl enable network-manager.service
$ sudo systemctl start network-manager.service
Disconnect your Ethernet cable to test connecting to a WiFi connection. Run the following to connect to a WiFi router:
You must have access to the internet now. Run the following to verify:
$ ping google.com
Congratulations you now have a functioning and configured version of a Ubuntu server! Happy hacking!
- If you feel that you need a more minimalistic OS than the one explained above then I would suggest making your own Linux distribution here
- The terminal utility
lshwcan be helpful in diagnosing problems you may face while configuring the network interfaces. Use the following command to view the state of your network hardware (whether it is disabled, enabled and etc):
$ lshw -C network