openSUSE, portable and persistent on a flash drive

openSUSE, portable and persistent on a flash drive

Submitted by Detlev Conrad … on Fri, 10/14/2016 - 19:30

The idea to have a proper Linux installation on a Flash drive is about as old as my current Ultrabook, the Fujitsu U904 which I bought in winter 2013. Well, I finally got a fast and large enough Flashdrive (a tiny USB 3.0 32GB Sandisk, there are faster drives, but it is actually enough for openSUSE) and proceeded to fiddle with setting it up - and it works.

Basically I have openSUSE installed on a flash drive - which I can load in VirtualBox or alternatively if I enable booting from external media, I can plug it in and boot my laptop from there instead while still retaining Windows. What is it good for? It is useful when I need more performance than a Virtual Machine will give me - most of all it is a way of having a Linux VM externally without filling up my (too small) SSD.

So how did I do it:

  1. Download and install VirtualBox 5.1.x or newer - it is what I used, it is free and works.
    Other virtualisation techniques? Try if you want. 
  2. Download your distro of choice - I used openSUSE Tumbleweed.
  3. Download and install the VirtuaBox extensions - we need those to ensure we have EFI support as well as USB3.0 support. Lacking these will most likely cause issues with any USB 3.0 device as they do not seem to get native support in VirtualBox otherwise...
  4. Set up a virtual machine in VirtualBox - you can assign a disk, but most importantly, add the flash drive and enable EFI support.
  5. Install the OS onto the flash drive. If you set up an internal disk you can delete that in VirtualBox.
    OpenSUSE will default to BTRFS for the root drive with snapshots - on a small flashdrive, disabling snapshots, using ext4 (or another file system) or not splitting partitions  for /root and /home may be required.
  6. If all goes well, victory. You may need to point VirtualBox at the USB key again if you remove it to boot the VM, but it should work. 
  7. If you have enabled EFI in Virtualbox it writes the required files to a dedicated partion. In my case I enabled booting from the USB port and booted into Tumbleweed just fine.


Caveats:

  • A USB Flash drive may not be designed for the write loads it gets as a result - I have no idea what impact this will have on its lifetime. It could fail in 2 days or 20 years, I just do not know. I suspect some kind of USB SSD with wear levelling would be best - or a very high end flash drive with wear levelling. Only YOU are responsible for YOUR data.
  • I may be too impatient of the shutdown when booting from the USB drive without a VM does not complete. At least it seemed to hang. However past openSUSE releases had issues where it took a long time to shut down, so maybe I'm just too impatient.
    -> A couple of updates later this works fine, this could have been a bug in the initial install or kernel. All seems well right now.

 

And with no no responsibility for the content hosted on these sites:

 

Happy playing!