Table of Contents
- Installing a Desktop with Ubuntu 18.04 from the "Server" base image
* Why install from server?
- Step 0) Prepare your hardware and make backups if needed.
- Step 1) Get Ubuntu
- Step 2) Boot the install image in UEFI mode
- Step 3.1) Proceed with the install
- Step 3.2) Disk partitions
- Step 4) Potential problem number 1!
- Step 5) Run updates, add your desktop of choice
- Step 6) Install the NVIDIA display driver
- Step 7) Optional: enable NetworkManager
In this post I’ll be going over details of Installing Ubuntu 18.04 including the NVIDIA display driver and, any one of the available desktop environments. I’ll do this starting from a base server install. You’ll be able to pick any desktop “flavor” you want — I’ll use MATE because I like it. I have found the method presented here to be the most likely to succeed no matter what hardware configuration you are installing onto.
A couple of weeks ago I did a post titled Install TensorFlow with GPU Support the Easy Way on Ubuntu 18.04 (without installing CUDA). One thing I did not cover in that post was how to install Ubuntu 18.04. I had mentioned that I would do a post on installing Ubuntu 18.04 and that I would go over an unofficial CUDA install. This post will be the first part of that. I might look at making CUDA 9.2 work on 18.04 in a later post. [My recommendation for setting up CUDA environments these days is to use Docker and NVIDIA-Docker which I have covered in other posts.]
In the title I said “The Best”, that, of course, is subjective! Installing Linux can sometimes be frustrating especially if you are installing onto new “bleeding edge” hardware or something with an unusual configuration. Linux is usually very easy to install and configure but when it’s not it can be very frustrating. The installation method I present here is, in general, my preferred method for installing Linux. In particular this post details how I nearly always install Ubuntu.
I have Ubuntu 18.04 on all of my Linux systems now and I like it a lot. It doesn’t seem to be a big change from 16.04, it mostly feels more polished and stable. Some changes are subtle but very welcome. For example, it is the first Linux release that I have installed on a laptop and had all of the special function keys work correctly without any special effort.
Installing a Desktop with Ubuntu 18.04 from the “Server” base image
Yes, installing “server” first is my preferred way to setup a desktop.
Why install from server?
A minimal server install is fast, simple and allows configuration flexibility.
It’s simple to add any desktop environment you want on top of server.
You can do (or even script) a complete install including adding proprietary display drivers before your first boot into desktop mode.
A server install is “usually” more likely to work if you are using “bleeding edge” hardware or unusual configurations.
That last reason is generally why I do it this way! I often have new/pre release hardware to test. I’ve installed Linux thousands of times, and that’s not counting automated provisioning. I usually have best luck with installs by keeping things simple and then build on that.
Note! Installing from one of the desktop flavors live-media can be easy “when it works” and it often does work just fine. Hardware detection with the live media is usually very good. However, it’s not as flexible and can sometimes be frustrating when trying to get propitiatory graphics drivers installed and working right. If you are doing a simple workstation (or laptop) install don’t hesitate to try using a “desktop-live-media” image, it may work fine for you, but, if it doesn’t, then knowing how to fall back to a simple base install can save you some grief and frustration.
Step 0) Prepare your hardware and make backups if needed.
I’m assuming that you are doing a clean install. If you have anything important on the disk(s) you are going to use for the install please make backups! If you have secondary drives or data drives that you want to preserve and use in the new install you could disconnect them during your fresh install so that you don’t accidentally overwrite them. You can reattach and mount them in your new install later.
Step 1) Get Ubuntu
CAUTION! DO NOT USE THE DEFAULT Ubuntu 18.04 Server Download!!
The default download for Ubuntu 18.04 server gets you a new “live-server” installer. I don’t really understand why they did that. It does not have as many options as the old installer and it doesn’t allow for any special partitioning like RAID setup or any advanced networking. The worst problem with that default installer is, …
The default Ubuntu 18.04 server download is for a cloud based install! It installs the Ubuntu cloud image and cloud configuration without any option to change that. It is not suitable for a “normal” install on your own hardware. What you want is called “Basic Ubuntu Server” and it is not available with this installer.
There is an “Alternative” installer which is the same as the standard installer from Ubuntu 16.04. I’ll use the “alternative/standard” installer in this post.
You can get the Ubuntu server image from Canonical’s site. They now only list 18.04 on the main download page and you don’t want that download. The Alternative Downloads page has 16.04 LTS and other versions as well as the standard installer for use with 18.04. 16.04 is solid and well supported and will remain that way for several more years. If you use the HWE kernel it will work fine with recent hardware. However, I do recommend that you move to 18.04. It has only been out for a short time but it is already widely supported.
Step 2) Boot the install image in UEFI mode
I recommend you use UEFI for your install. If you have been doing this for a while you may be comfortable with legacy MBR installs but it’s probably time to try UEFI if that is the case. If you are using new hardware some of it may not even work correctly if you don’t boot to UEFI. Be sure you BIOS has “secure boot” disabled. You might be able to get your install to work with “secure boot” enabled but you will have mysterious errors when you try to install the NVIDIA driver kernel modules.
To start your install you will need to know the magic key to press at startup to get a boot device select screen. Unfortunately that’s not standard among different motherboard manufacturers so you will need to look it up if you don’t know what it is. When you get to that boot selection screen you may have a choice of boot partitions on the install device. One of them should be labeled UEFI. Use that.
Step 3.1) Proceed with the install
Note: if you start the install and have corrupted video then you may need to do what I suggest in Step 5) below to get the install started correctly.
Once you have started the install you will be guided though several question that will be pretty obvious … until, you get to “Partition disks” …
Step 3.2) Disk partitions
Unmount in-use partitions
If you are installing onto a disk that already has partitions on it the first thing you will see in the Partition disks section is the following,
You probably want to say “yes”.
Next will be choosing how to do the partitions. If you are insatlling onto a single disk and especially if it is an SSD or NVMe drive then I recommend “use entire disk”.
This is the first time ever that I have recommended using this option! In 18.04 this opttion does a reasonable thing for a single disk install with an SSD or NVMe drive.
Pick the disk you want to use and then you will get something like the following,
This will create a 512MB EFI partition for the UEFI boot information (/boot/efi is mounted there). The rest of the disk is allocated to the system root file system (/). This is really how you want to partition a modern SSD or NVMe drive!
What about a swap partition?
You don’t need to create a swap partition. the installer will create and setup swap on a swap file. It creates a 2GB swapfile,
kinghorn@u18:~$ swapon --show NAME TYPE SIZE USED PRIO /swapfile file 2G 0B -2
That’s all you need! [If you do have some reason for more swap you can always make additional swap files of any size you want.]
Manual partitioning if you need it
If you don’t like what I recommended above for any reason, like maybe you want to setup a RAID or you are using multiple disks or want to use LVM or something, then the you will be happy that the partitioning tool in the 18.04 installer is the same as it was for 16.04 i.e. it’s pretty good. I am not going to cover that in this post. You might want to look at my post on installing Ubuntu 16.04 where I go over manual partitioning.
Initial Software selection
At this point the installation will will proceed with just a couple more simple questions. When you get to the “Software selection” screen I recommend that you add the OpenSSH server. You don’t need to add anything else at this point since we will be doing a full desktop install after first boot.
After this the install will finish and you will be ready for first boot into the OS.
Step 4) Potential problem number 1!
Hopefully you wont need this step!
You might need “nomodeset” until you get GPU drivers installed! You could have this problem during the install too. What I describe here will “usually” take care of this. It is one of the most common problems installing Linux on a system with an NVIDIA GPU installed.
When you reboot the system may come up into a corrupted screen or it may hang! This is because the proprietary driver is not installed for the NVIDIA card (which I presume you have in the system). This is most often caused by the system seeing your great video card and then trying to bring up a console in a “frame-buffer”. RANT-ON There is no reason for that on a server install! … RANT-OFF
Here’s how you get around this if you encounter it,
When you get to the Grub selection screen type e That will let you edit the kernel boot parameter line (for this boot only). You need to find the line that starts “Linux” go to the end of that line and add nomodeset Then press F10 to boot. That should get you to a login screen. We will have everything installed including the NVIDIA driver before the next boot so this should be the only time you have to do this and there should be no reason to have to add nomodeset permanently.
Step 5) Run updates, add your desktop of choice
Login to your system. Now we’ll add the good stuff!
First run updates,
sudo apt-get update sudo apt-get dist-upgrade
You may get a kernel update but don’t reboot yet!
Select and install your desktop of choice
We will use a very handy command that is is installed by default with a server install (with the installer we used!).
tasksel you you have a lot of options available. It’s a really nice tool! The image below show some of the tasksel options. I have selected “Ubuntu MATE desktop”. That’s my current favorite Linux desktop.
Adding a desktop flavor will download and install a lot of packages so this may take awhile.
Don’t reboot yet! We want to get the NVIDIA display driver installed BEFORE we boot to a GUI desktop.
Step 6) Install the NVIDIA display driver
There are a few methods for installing the proprietary NVIDIA display driver. For Ubuntu installs the one I recommend is to install the latest driver by adding the the graphics driver ppa repository. This is well maintained and you will be able to get the latest driver (or older ones if needed).
The command to add graphics-drivers ppa is,
sudo add-apt-repository ppa:graphics-drivers/ppa
Before you install the driver it is good to be certain dkms (dynamic kernel module support) and build-essentials is installed. This is because whenever the system kernel is updated dkms will automatically rebuild the NVIDIA driver module for the new kernel. It needs build tools and the kernel headers for this which will be installed with build-essential.
sudo apt-get install dkms build-essential
[ You could also add some other packages now if you like. Maybe the synaptic package manager… ]
Now to install the driver,
sudo apt-get update sudo apt-get install nvidia-390
This installs the latest driver version 390 (as of this writing). That will work with NVIDIA Volta and lower cards.
This install should be robust. New kernels or drivers should automatically rebuild with dkms.
Now you can reboot!
sudo shutdown -r Now
When your system comes up you should be greeted with a graphical login manager running with the NVIDIA display driver. You will notice that you get a lot of messages on the screen during boot. That’s because we installed from server. A typical desktop install from live media will be configured to hide all of that information from you. Personally I like to see it! You will sometimes see some warnings or errors. Those are almost always artifacts of startup ordering or some such no concerning events. However, if there is a real problem on the system those messages can give you useful information for diagnoses.
Step 7) Optional: enable NetworkManager
Ubuntu 18.04 has a new network setup using “netplan”!
Networking has changed in Ubuntu 18.04. It is now using a tool called “netplan”. You can go read about on the netplan web site.
One artifact of doing an install from server is that the network interface that is configured during the install will be using “systemd-networkd” instead of NetworkManager. This is because the server install doesn’t have NetworkManager! That’s OK, but using NetworkManager is more common for a desktop install and it can be useful, especially for systems like laptops where there may be frequent interface switching. NetworkManager is a good system tool and it handles wifi well. You can switch your system to NetworkManager control with the following instructions.
netplan is configured in a “yaml” file in
/etc/netplan/ The configuration file may have different names on different systems. On my install the file name is
Lets make a backup copy of that yaml file and edit the existing one to use NetworkManager.
cd /etc/netplan sudo cp 01-netcfg.yaml 01-netcfg.yaml-backup
01-netcfg.yaml using your editor of choice (and use sudo). Change the file so it looks like,
# This file describes the network interfaces available on your system # For more information, see netplan(5). network: version: 2 renderer: NetworkManager
Then run the following to make the new setup,
sudo netplan generate sudo netplan apply
Lastly restart the NetworkManager service,
sudo systemctl restart NetworkManager.service
You are now using NetworkManager.
Ubuntu 18.04 is really a great distribution, enjoy!
Happy computing –dbk