Installing Linux (Ubuntu 20.04) on an external portable SSD and pitfalls to be aware of
Carry your Ubuntu OS anywhere without being limited by hardware
TL;DR Skip to “Installation Process”
Choosing your Operating System is difficult
If you are a software developer, you have probably come across the dilemma of choosing your operating system. This is a big decision to make, since each operating system comes with its own pros and cons, and you will be stuck with them for quite a while. For people who are just getting into coding, below is my personal opinion on pros and cons of each operating system.
Why programmers tend to prefer Linux is because a lot of open-source code (especially in the research stage) are developed on it. This doesn’t mean that it is better than Windows or Mac necessarily, but it is definitely more accessible because it is free and open-source, so many research labs, companies and cloud computing providers run Linux on their remote clusters. Therefore, the software they develop are most often tested on Linux distributions such as Ubuntu, but may not be tested on Windows or Mac OS, and you might have to spend a while to find a work around.
On the other hand, using Linux has its own drawbacks; many proprietary products such as business, gaming and industrial software do not support Linux because Windows and Mac OS have a larger share of the market. For instance, Microsoft Office and Adobe Products are only available on Windows and Mac OS, and in order to install it on Linux you would have to do a work around such as installing on top of PlayOnLinux. If you want to develop mobile apps, you need a Mac because iOS app development is only possible on a Mac. If you are a gamer, Windows is probably best suited. In terms of extending the laptop like we do in this article, a PC would be more suited than a Mac, since there are more ports and also configuring BIOS is difficult in Apple products.
Another issue I find is that, Ubuntu is less stable compared to Windows or Mac OS, especially when it comes to hardware compatibilities and drivers. While some problems are solvable given you have some familiarity with Linux, this can take a while. Also, since Linux’s primary strength is in its command line capabilities, its Graphical User Interface tends to be less developed, so Windows / Mac are definitely more user friendly in that sense.
A solution that worked for me: Windows laptop + Ubuntu external SSD
I credit my course mate for giving me this idea. Before this, I had a dual-booted Windows + Ubuntu laptop but I would not recommend this because my 500GB hard drive quickly filled up from hosting two operating systems, each with their own software. Despite moving out almost all personal files onto external drives, I barely had space left because some software can easily take up tens of GBs due to its cash. I was seriously considering buying a new laptop, but this external SSD idea saved me thousands of pounds.
The great thing about installing an Ubuntu OS on an external SSD drive is that, you can easily use and switch between both Windows and Ubuntu without sacrificing any storage space. What is more, you can now carry this SSD drive wherever you want, and plug it into any computer. As long as you know how to configure the BIOS/UEFL so that this will boot up, you can keep working with your familiar OS and software. The other good thing is that, in case you mess up the installation, you can always wipe the disk and try again. This can be a lot scarier if you are trying to install Ubuntu onto a partition sitting on your local storage.
The installation process that worked for me
This is not meant to be a comprehensive guide to installation, but I will try to outline what worked for me, and the pitfalls you should be aware of, because sometimes knowing what doesn’t work is just as important and saves an awful amount of time as knowing what works. I would suggest first trying this method out, and if this doesn’t work, read the “Helpful Resources” section.
Step 0. Before you start
What you would need:
- USB stick with 8G+ memory.
- Laptop (I have tried with Dell XPS)
- SSD drive* (e.g. I bought a Samsung T7 SSD with 1TB storage)
*Note: make sure that you have high read/write speed because your operating system performance can be bottle-necked by it. T7 has up to 1050MB/s. HDD, USB memory and SD are slower.
What you should be careful of:
- Make sure you back up your computer (especially personal files, but also your OS) in case something bad happens, which can be the case since we are going to do a lot of formatting, partitioning, and changing BIOS/UEFL settings.
- Wipe and format both the SSD drive and USB stick beforehand (they will be reformatted anyway but just to be sure)
Step 1. Create a bootable Ubuntu 20.04 LTS USB drive
First, you have to download the Ubuntu Desktop ISO image by going to the official website. Make sure to download the LTS version. In my case, I downloaded Ubuntu 20.04.4.
Next, if you are on Windows, you can use Rufus to write the ISO to your USB stick. You can read How to Create a Bootable Linux USB Flash Drive, the Easy Way to find out how to do this.
If you are already on Ubuntu, you can try creating the bootable USB stick with the “Startup Disk Creator” as outlined in the above article. It didn’t seem to work for me though, so I did this directly from the terminal. Read How to create a bootable USB drive from Ubuntu terminal?
What you should be careful of:
- Double check that you are writing the ISO image to the correct drive. Don’t overwrite your local storage.
- Double check that the ISO file you downloaded is not corrupted. This can be done by following How to verify your Ubuntu download.
It actually took me a day to get this step working because of two factors
- I initially tried to use a cheap USB stick that I got at a career event. DON’T USE THESE. You will waste a lot of time scratching your head later on when you try to boot Ubuntu and fail. Use a proper and reliable USB stick.
- When I used the “Startup Disk Creator” in Ubuntu, I got a “/casper/vmlinuz not found” error. It turned out that my bootable USB stick was corrupt, so I had to create this from the command line. The same happened when I tried to use my other laptop which comes with a non-English Windows OS to create the USB stick. Make sure that your OS language setting is in English if this happens.
Step 2. Change boot settings
Now, with your newly bootable USB plugged in, we have to change your laptop behaviour upon boot. On most machines, you can enter the boot menu when the computer starts if you press a certain key. This depends on the laptop, but they are usually either Esc, F2, F10 or F12. On my Dell XPS 15, pressing both Fn and F2 at the same time takes me to the boot settings page. Make sure to practice this so that you can always comfortably go to the boot menu.
Now that you are in the boot menu, you have to do two things. Firstly, you have to change the General > Boot Sequence so that your Ubuntu USB comes to the top. Secondly, you should go to System Configuration > Driver and uncheck every drive you see listed. This will disconnect your internal storage upon boot so that you won’t accidentally overwrite these when you are installing Ubuntu to your external SSD. This will avoid most of the problems that the article I followed (How to Create a Truly Portable Ubuntu Installation on an External USB HDD or SSD, which is, by the way, an amazing article) addresses, namely that the EFI partition might be overwritten and that you have to install Grub yourself.
You can easily reconnect your internal storage afterwards once you finish your installation by going to the boot menu and ticking the boxes again.
Step 3. Boot Ubuntu from bootable USB
Now reboot your laptop with the bootable USB plugged in. In the first menu that shows up, don’t select the normal Ubuntu, but try “Ubuntu (safe graphics)”. This will save you a lot of pain of waiting on a stalled installation. After a while, a loader with options of “Try Ubuntu” and “Install Ubuntu” will come up. You can choose either one. If you choose Try Ubuntu, Ubuntu will load from your USB for the time being, and on the desktop there is a shortcut to “Install Ubuntu”. I personally prefer this way because the fonts appear much bigger, and you can do other things on the temporary Ubuntu while the installation is ongoing.
Step 4. Install Ubuntu onto External SSD
Once you move to the installation screen, connect your external SSD and follow the instructions. At one point, they will ask for the installation type. Now, in the other tutorial I followed, the author recommends partitioning your disk yourself. However, I wanted to take advantage of the LVM encryption feature that comes in the “Advanced features” option if you choose “Erase disk and install Ubuntu”. This works only if you have disconnected all internal storage in the boot setting as outlined in Step 2 — otherwise, there is a risk that your local EPI partition will be overwritten as the above article warns. If you see more than these two options, you may still have some internal storage that are not disconnected, or you might not have wiped your external SSD beforehand.
The only other downside to choosing the default setting rather than going for a custom “Something else” option is that, you can’t decide how your hardware will be partitioned. This is especially annoying for the swap partition, which is only given ~800MB in the default setting. We can later fix this by adding our custom swap file.
The rest of the installation process should be straightforward. When you choose your username, make sure that you don’t have any spaces. This can help you avoid a lot of headaches down the line. Once everything is installed, you can reboot your laptop. The screen should ask you to remove your bootable USB before it reboots.
Step 5. Updating software and drivers
Once the system reboots, hooray, you have a working Ubuntu OS on your external SSD! Don’t celebrate too soon though. Wait until you finish updating your software and drivers.
General Software Update
You can either use the Software & Update GUI interface to update packages, or you can perform
sudo apt updatesudo apt upgrade
Nvidia Driver Update
By default, Ubuntu uses a third party driver instead of the Nvidia proprietary driver. To change this to the official drivers, you can follow either of the below.
- Ubuntu Linux Install Nvidia Driver (Latest Proprietary Driver)
- How to install the NVIDIA drivers on Ubuntu 20.04 Focal Fossa Linux
Change GRUB settings
There’s one thing I would do straightaway (even if you don’t have any issues), which is to update the GRUB setting so that Ubuntu will print out logs onto the screen upon boot. Upon your initial boot, open
/etc/default/grub with your favourite text editor (for example, by running
sudo gedit /etc/default/grub) and where it says
change this to
Also, set GRUB timeout to something more than 0, so that if you want to open the GRUB menu upon boot, you can do so by pressing the shift key.
Once you save and close the text editor, reflect the updated GRUB settings.
Things to be aware of:
This is where I struggled the most. I must have tried at least 20 installations following the article I mentioned, but every single time, my Ubuntu kept hanging at reboot with a blinking underscore cursor with no error messages. Updating the GRUB setting as above provided me with the logs, but still, they were kind of misleading and was a red herring because Ubuntu kept hanging at different logs when I tried rebooting multiple times.
Eventually I realised that Ubuntu was simply failing to load the GUI login screen in time, which is typically handled by GDM3. This was confirmed because if I open up the terminal with
Ctrl + Alt + F3and I manually type
sudo service gdm start I was able to start the GUI login screen. Reading this StackOverflow thread was helpful.
In the end, what worked for me was to not follow the article above but to follow the default Ubuntu installation procedures, with encryption enabled. I haven’t tried comparing the encrypted version and non-encrypted version, but I am suspecting that the amount of time I take to type in my password to unlock the hard drive is enough time for the X server to start running so that the GUI can launch properly (I came to this conclusion because whether Ubuntu stalls seemed pretty random, when I tried rebooting multiple times without any changes to the system). But I could be wrong.
The other option that worked for me (with custom partitions following the article) was to switch to lightdm by doing the following.
sudo apt-get install lightdm
sudo dpkg-reconfigure lightdm
This was not necessary with the default installation procedure.
Step 6. Add custom swap file (optional)
Swap spaces are used when the OS runs out of RAM and wants to offload some unused data in the RAM. By default, Ubuntu installation only creates ~800MB of swap space, which is tiny compared to what is usually expected (about the same size of your RAM). Fortunately, we can create a swap file within our main partition to basically do the same. For more details, please read How to Add Swap Space on Ubuntu 20.04.
Step 7. Reconnect your internal drives
Once you finish your setup and make sure that Ubuntu boots properly, it is safe to go back into the boot menu and re-enable the internal drives. Upon reboot, if Ubuntu doesn’t show, go back into the boot menu and reorder the boot sequence so that your Ubuntu SSD drive will boot first.
Although the final procedure I converged to is fairly straightforward, it has been a long journey since I had to eliminate all other possibilities of failure along the way by the method of trial and error. I hope this article will help some people avoid potentially wasting a lot of time chasing red herring error messages (if your installation or reboot stops with a certain log message, that doesn’t necessarily mean that that is a warning you should care about, especially if it doesn’t explicitly say “error”).
But I can assure you that the effort is totally worth it! You will never buy a new laptop again just because you are running out of internal disk space, which will save both your wallet and the planet!