Nomadic NixOS via USB
Faced with the need to use my personal equipment outside of home, I encounter the following problems:
- My laptop: For long trips it is perfect, but if the trip is short or space is a limiting factor, it is not practical.
- Phone: It can get me out of trouble using termux and WireGuard, connecting to my server and using SSH, but it does not allow me to use applications or anything of that sort.
- Company laptop: Like my phone, I can use the Windows Subsystem for Linux (WSL) to connect via SSH to my servers, and in addition it allows me to use some Linux terminal utilities if I need to do something locally. However, I cannot run native Linux applications, I do not have my customized desktop, and I cannot partition the disk and set up a dual boot system due to company policies.
Because of these problems, I propose a solution inspired by the operating system NomadBSD, which offers an operating system whose storage and system are entirely contained within a USB drive. However, instead of using a BSD system, I want to base it on NixOS, which allows us to describe our system declaratively, making it easy to replicate our environment. In this post I present my solution for a fully portable system entirely contained on a USB drive.
Installation
Materials
First of all, you will need:
- A computer/laptop with at least 2 available USB ports.
- A USB drive with at least 32 GB of storage and fast read/write speeds. This USB drive will contain our data, which is why I recommend using a well-known brand such as Kingston.
- A second USB drive with at least 4 GB of storage.
Installation
The NixOS installation image must be configured on the second USB drive using a utility such as Rufus or Raspberry Pi Imager. Both USB drives should then be connected to the computer, and the system should be rebooted, configuring the BIOS to boot from the installation USB.
When the NixOS installation process begins, you must select the USB drive with at least 32 GB of storage as the target disk, and you should choose to have the disk encrypted, in order to prevent our data from being exposed in the event that the USB drive is lost.
Usage
To use our new system, we simply need to connect our USB drive to any computer and select booting from the USB device.
On this new system, I recommend installing software that allows synchronization with our other devices and servers, such as Syncthing, as well as installing a client like WireGuard to access our local networks. In my GitHub repository you can find my current configuration for my nomadic system using NixOS.
This system will have the processing power and volatile storage of the computer it is connected to, making it faster or slower depending on the host machine. The only constant factor will be disk speed—that is, the read and write speed of our USB drive1.
Conclusion
With this new setup, we have a very portable, encrypted, and reproducible solution for our system, allowing us to work with the comfort of our customized desktop anywhere.
The only issue I have encountered with this configuration is that the system is completely dependent on having another computer/laptop in order to function. This is not a problem for me, as I always carry my laptop when traveling, but it could be an issue for the reader if that is not the case, or if they already carry their own laptop with a customized distribution. In addition, read and write performance will always be limited by the speed of the USB drive, which, at the time of writing this article, is far inferior to the speed of a hard drive or SSD2.
That said, if someone finds themselves in a situation similar to mine—where they need access to “their computer” to do a quick fix or test—I consider this solution to be more than appropriate.
| Device | Linux | Portability | Encryption | Independence 3 | All-in-one 4 |
|---|---|---|---|---|---|
| Personal Laptop | ✓ | ✖ | ✓ | ✓ | ✓ |
| Phone | ✖ | ✓ | ✖ | ✖ | ✓ |
| Company Laptop | ✖ | ✖ | ✖ | ✖ | ✓ |
NixOS on USB | ✓ | ✓ | ✓ | ✓ | ✖ |
The speed may also be limited by the USB port used; it is always worth using a USB 3.2 port rather than an older version, due to the speed improvements offered by newer ports. ↩︎
Note: Wear is also a relevant factor—USB drives are not designed for the number of write cycles that a hard drive is built to handle. If this solution is going to be used extensively, I would recommend using a portable SSD. ↩︎
Related to whether a second external system, such as a server, is required for it to be useful or practical. ↩︎
Does it require a second physical device present with us, or can it function on its own? ↩︎