Before You Begin
Although a typical Arch Linux installation with a fully functional desktop environment usually ranges from about 3GB to 5GB, I recommend using at least a 16GB stick. Being that this is an entirely portable Linux system of your own, you may want to load it up with a collection of some great GNU and open source software packages out there. With some large packages like SageMath, TeX Live, and various developer tools, my current Arch Linux USB drive sits at around 12GB.
You will also need to download an Arch Linux bootable installation ISO and either burn it to a CD or write it to a different USB stick than the one you will be installing your persistent copy on. I have used both methods with no problems, but the speed of installation is much greater when using a bootable USB stick.
To write a bootable USB installation medium in Linux, run the following command where /path/archlinux.iso is the path of the downloaded ISO and /dev/sdX is the path of your unmounted target USB drive:
To make a bootable USB using Windows, I have used the open source GUI tool Rufus on several occasions without any issues. If Rufus doesn't work for you, there are multiple other programs intended for the same thing.
Users with a current working installation of Arch Linux can opt to forgo a new boot medium altogether and simply partition, format, pacstrap, and arch-chroot into the target USB drive instead. The instructions to do so are not explicitly provided here as that is not the scope of this guide, but the important parts of the process are identical.
wired vs wifi
For the actual installation you will need a computer connected to the internet. A wired connection is definitely preferred as the bootable installation ISO is setup to automatically detect and connect to any wired network on bootup. Also, any packages you choose to install will need to be downloaded from the Arch Linux repositories, and network speed may be a limiting factor over wifi.
The instructions in this guide will setup your persistent bootable USB to automatically configure a wired network connection whenever a network cable is detected. Support for most wifi interfaces will also be installed, but automatic connection will not be enabled. Having automatic wifi connection capability is quite simple to setup, but for this bootable Linux USB it won't be enabled by default as not every machine it is boot on will even have a wifi interface.
Lastly, Linux kind of has a horrible history of working with some wifi interfaces. There is a chance, albeit rare, that you may be the proud owner of a wifi networking device not compatible with Linux... yet (until you write the driver for it!). For more information pertaining to Linux wireless interface compatibility, see the official wireless wiki.
BIOS vs UEFI
Basically, there are two different systems implemented today that motherboards use to communicate between an operating system and their firmware. There is the standard (legacy) BIOS (basic input/output system), and there is the newer UEFI (unified extensible firmware interface). Although UEFI was implemented on some top-end machines in the early 2000s, any computer more than ten to fifteen years old is probably only going to be able to boot up in BIOS mode. Newer machines, on the other hand, will often be capable of booting in both UEFI mode and BIOS mode. Many times a preferred boot mode can be selected from the BIOS menu on such machines. Current Apple computers only recognize UEFI.
Both BIOS and UEFI require different particular partition schemes in order to boot. If the motherboard is set to boot in UEFI mode only and the inserted boot media does not have the correct partition scheme for UEFI, the boot will fail; the same goes for an attempted BIOS boot. This is one place I believe some of the USB installation guides out there fail: they often only describe how to create a USB boot device that uses only one mode. It is possible, however, to setup a USB drive that will have a partition scheme allowing it to boot in both modes and still use the same persistent installation of Linux. This guide will setup such a scheme in the partitioning and formatting sections below.
On most newer machines, you will be presented with the option to boot in either BIOS or UEFI mode from your bootable USB. This means the machine recognizes the UEFI boot media, but it does not always mean the machine is actually set to boot in UEFI mode, and selecting the UEFI boot option may fail. Selecting a mode that the motherboard is not set to boot in will not damage anything or touch any of the other drives on the machine, the boot will simply fail and one can reboot in the other mode. The USB stick created with this guide has been able to boot on every (about a dozen) desktop and laptop, new and old, BIOS and UEFI, machine that I have tried it on.
The new UEFI specification also includes an optional mechanism to protect against pre-boot malware. The secure boot protocol is designed to only allow the booting of images signed with a cryptographic key contained in a machine's NVRAM. If secure boot is enabled and a boot image lacks a cryptographic signature or the signature doesn't correspond to a key listed in the computer's NVRAM, the firmware will refuse to execute the boot image. The most common workaround when dealing with secure boot on Linux machines is to simply disable the secure boot option in the machine's BIOS menu.
If it is not possible to disable secure boot in a machine's BIOS or you wish to use secure boot on your Arch Linux USB, you will need to install a signed bootloader and properly set it up after this guide.
localtime vs UTC
There are two time standards used by the internal hardware clock of a modern computer to store the current time. Localtime is dependent on the machine's current geographical time zone and often takes daylight savings into account, while UTC (coordinated universal time) is the same regardless of global location. The hardware clock stores the current time, in one of these two formats, by storing separate values for year, month, day, hour, minute, and second.
The hardware clock does not, however, retain any record of what format its time values are kept in or if there has been any adjustment made for daylight savings. It's up to the operating system to keep track of these settings. This can pose some issues if multiple operating systems are boot on the same computer using localtime as its time format. For instance, both operating systems might adjust the hardware clock time for daylight savings resulting in an extra hour of difference.
The obvious solution, here, is to simply use UTC on all operating systems and be done with it. MacOS uses UTC, Linux uses UTC by default, but Windows uses localtime by default. In other words, when booting the Linux USB off of a machine primarily used with Windows, the chances are that the hardware clock is going to appear to be incorrect.
What this means for the Linux USB is that you may occasionally see some time-stamp warning messages when you boot up your USB off different machines. We will enable a network time protocol so that the USB Linux system will update its operating system clock as soon as an internet connection is established and correct these discrepancies. More importantly, though, the Linux system will also update the hardware clock to the correct time in UTC, meaning the next time Windows is boot it may encounter some time-stamp errors. In my experience, this hasn't been an issue beyond the infrequent warning message at bootup.
Another possibly useful option not explicitly shown in this guide is partitioning the target USB device to function as both a persistent bootable USB and an NTFS or FAT32 formatted storage device fully compatible as a Windows, Linux, or OSX standard USB jump drive.
A final thing to point out is the lack of a swap partition in this installation of Linux. The reason for this is twofold. First, recognizing that flash memory has a finite number of writes before it eventually goes bad, the lack of a swap partition may at least decrease some of those writes. Second, realizing that nearly any computer you boot up onthese days has at least a few gigabytes of available RAM, the need for a swap partition is mostly non-existent.
Why Arch Linux?
There are already several guides to setting up a persistent Linux installation on a USB drive out there, including a dedicated ArchWiki page. In theory, an installation on a USB key should be no different than any other installation, and perhaps some GUI installers out there will work just fine. However I've heard of several failed attempts at getting a USB Linux installation working properly when working from said installers or guides. I have a few ideas on why this might be occurring and have attempted to correct these scenarios with this process. Arch Linux serves this purpose well due to its ability to easily change configuration options to the user's need.
about this guide
Perhaps the biggest reason for the existence of this entire guide is my own curiosity. You may find the nature of an Arch Linux installation provides more insight into what is happening behind the scenes than any GUI installation tool out there. Messing around with Linux like this can be fun (and frustrating!). I find learning how my computer works and finely tuning its configuration to be rewarding. With an Arch Linux persistent bootable USB I have my own completely custom operating system, application set, and user interface with me in my pocket everywhere I go!
Also, I suppose I should say, I am in no way officially associated with Linux or the Arch Linux project. I am simply a curious tinkerer who uses the act writing things like this as a learning experience. I have personally followed these steps over a dozen times on multiple computers with no problems, but I can't guarantee it will work for you. I wrote this guide to be (hopefully) followable by anyone with a moderate understanding of current PCs. My intention is for this to be a fully self contained guide, yet numerous links are provided throughout the text to supporting references and additional resources.