DEV Community

Cover image for Running Ubuntu From A USB Drive

Running Ubuntu From A USB Drive

Angela Whisnant on June 28, 2019

Hey, guys! I had quite the adventure today trying to run Ubuntu on my son's laptop from a flash drive, so I thought I would share what I learned he...
Collapse
 
geraldew profile image
geraldew • Edited

Just a quick thumbs up from me - as I've been operating my Ubuntu setup that way for many years (from at least 12.04 LTS if not longer).

However I don't use a flash drive - instead I use a portable hard drive, which these days mean USB3. While this is mostly about capacity, where I did use flash drives I found they didn't last as they're really not made for frequent data rewriting long term.

At some point you may have an epiphany when you realise that your USB drive now "is" your computer, and the computer is now the dumb piece of commodity hardware. As a bonus, the hard drive is much more portable.

The one big catch however - and you clearly already found this - is that you need to learn how to "get into" the boot sequence of any computer you go to use. In general, each different make+model is .. different.

A related catch is about the alternative booting schemes - MBR versus EFI. At this point, I'm still finding it more reliable to use MBR boot on my external drive, as the Ubuntu update process for EFI defaults to updating EFI on the host machine instead of the external drive. In 2019 this seems a dumb choice to be making but I haven't yet found a good enough work around.

FWIW - I prefer to find which method does not require making a permanent change on the machine - and yes, even on my main machine I tolerate doing the couple of steps to divert the boot on every power up. But another good method is to install REFInd - en.wikipedia.org/wiki/REFInd - there are quite a few options for boot managers around. After years mucking about with those, seeing the external drive as "the computer" led me to stop bothering.

p.s.in case it's not obvious, having a full hard drive - e.g. 1TB - means I do a "full install" onto it, not just the downloaded boot image.

Collapse
 
geraldew profile image
geraldew

A very belated follow-up, but I finally got around to writing up how I now make these setups for 64bit GPT EFI computers. See dev.to/geraldew/ubuntu-linux-insta...

Collapse
 
angelarae63 profile image
Angela Whisnant

Mind blown! Why didn’t I think of that!? I’m gonna look into getting an external hard drive. What a great idea!

Collapse
 
geraldew profile image
geraldew

A very belated addendum is that I've since cracked the solution to correctly setting these up to work with EFI booting. The magic ingredient is using grub-install with a --removable option.

I should probably do a full post to cover this sometime but for just here I'll quote the sources for the magic tip:

In my case I cheated by unplugging the internal hard drive of my laptop and then installed Ubuntu 20.04 onto a USB thumb drive from a DVD (of the ISO live disc for AMD64). Then after a successful boot on the thumb drive I went to the command line to-reinstall GRUB with the removable option. That thumb drive now boots fine on any of 64bit computers and - importantly - when it does so it uses the ESP partition on itself, leaving any other drive safely alone.

The other extra trick is to use efibootmgr to alter the EFI default order - but that's a whole other topic and can't override bad firmware behaviours.

Collapse
 
flrnd profile image
Florian Rand • Edited

Congats and Happy Coding!

Since you are having fun howto create a persistente bootable Ubuntu USB Flash Drive.

This way you can use your son's laptop and store your things without messing with his πŸ˜…

Collapse
 
angelarae63 profile image
Angela Whisnant

Cool! But the link isn’t working...

Collapse
 
flrnd profile image
Florian Rand

haha indeed! Sorry wrong link! try again ;)