So for the past few months, I’ve been running my operating system (Archlinux) off of a USB flash drive. I have a desktop at home, a desktop at work, and if I go somewhere where I won’t have a computer waiting for me, I bring my laptop. Whichever machine I’m using at the time, I boot from USB, and have access to all of my software, files, and settings, just the way I want them.
This is something I’d had in mind for a while, but only more recently actually tried it. It was surprisingly easy to set up, and has been working quite well. I decided it was worth documenting the experience, so here goes.
I picked up a USB flash drive at Micro Center for $50 USD. It happened to be Black Friday, but the regular price was only $65. It has a capacity of 128GB, and uses USB 2.0. There was a USB 3.0 drive in the same capacity available for $80, but since only one of the three machines I’m using this on with any frequency actually has USB3, I decided to go for the cheaper one.
Setup went very smoothly. As mentioned, I’m running Archlinux on the drive. There were only a few things that needed special attention, as opposed to a regular install:
/etc/fstabneeds to use UUIDs, or at least not use
/dev/sdX- there isn’t a strong guarantee that if the drive is
/dev/sdbon one machine, it won’t wind up as
We want traditional names (
wlan0…) for network interfaces. By default Systemd uses names that are guaranteed to be deterministic for a given machine, but which may not be easily predictable from one machine to another. This solves a problem that I’ve hit a number of times when dealing with machines having multiple ethernet cards - if the kernel probes them in a different order from one boot to the next, then for example
eth0can be a different physical network card every time you boot. Normally what Systemd does is desirable, but for this setup we want to have predictable names across different machines. So, I had to revert this to the old behavior.
I’m just using
wpa_supplicantfor network configuration. I have
wpa_supplicantset to start on
wlan0on boot, and
dhcpcdset to start on every likely interface. If one of these doesn’t exist, it will simply fail and move on. This is enough that the network typically just works when booting up a new machine.
It’s possible if I were using network manager or something similar instead, I might not need to revert to the old naming scheme. I’m not sure exactly what those tools keep track of, and I haven’t tried it.
/var/logon a ramdisk - flash memory in general can wear out quickly with too many writes, so I wanted to be careful here.
It’s a good idea to do this for any directory that’s going to have frequent small writes of inessential data.
/tmpis another good candidate, which arch does by default (and I’ve not changed).
I’m using Syslinux as a bootloader. I didn’t have do anything special
there, except use UUIDs for the kernel command line options (for the
same reasons as in
fstab). Perhaps grub would need more attention, I
It’s possible I’ve forgotten some small other thing. Next time I do something like this I will have to document it from day one.
One of the big questions I’ve had going into this was whether it would be too slow. It hasn’t been. There is occasionally some very noticeable slowdown, but most of the time things are fine.
I only hit serious performance issues in two places:
- importing mail into Notmuch. This takes a while, and slows down the machine enough in the meantime that I’ve learned to just wait until it’s done. It’s not enough to be a serious problem, but it’s annoying. This isn’t really surprising; indexing and tagging mail is probably asking more of the drive than most of what I do.
- Sometimes Firefox is really slow, depending on the phase of the moon and whether or not it likes me that day. This is somewhat true even on an SSD or hard drive, but on the flash drive it’s more frequently a problem.
Firefox is by far the heaviest app I use on a regular basis. I haven’t tried it, but I expect something like GNOME or KDE would be completely unusable in a setup like this.
The performance hit is noticeable, but for me it’s worth it to avoid the pain of syncing multiple machines, and to mostly not need to carry a computer with me.
One of these days I’ll want to upgrade to a USB3 drive, but for now I’m pretty happy.
There are a few neat unintended side effects/uses of this that I’ve come across:
- The drive doubles as a rescue/diagnostic system. The other day at work
we had a machine that didn’t have internet access, and were trying to
test something involving vlan tagging. The machine didn’t have
vconfig, so I just shut down my workstation, and booted the machine from the flash drive. This saved a bit of time over having to figure out how to set up a tagged interface given the software already on that machine.
- On the machines I truly own, I can use the internal drive for whatever I want, and not worry about whether I’ll have to wipe it when I need to get some work done. Right now I’ve got Plan 9 from Bell Labs installed on my laptop’s SSD. I haven’t spent a whole lot of time with it, but it’s nice to know I can just do that. I may consider putting Haiku on there next.
When I installed the OS, I made a reasonably sized fat partition, so I could still use the drive as portable storage, without actually having to boot from it. I haven’t actually done this yet. I almost never actually use flash drives this way; it’s much more common for me to use them as bootable media.
I started this as just a fun little experiment. It’s worked well enough that I’m sticking with it.