A recovery USB stick is a bootable USB drive that can be used to rescue a system or perform critical maintenance. It’s a useful tool to have around. Typically, a system of interest is booted from the USB stick, maintenance is performed, then the repaired system is rebooted from its own disk. Below is a simple guide to creating a number of rescue USB sticks.
A Rescue stick can help fix many system problems, such as a system that won’t boot, a broken GRUB configuration, a disk or other hardware problem. By allowing the whole operating system to be taken offline, a rescue USB allows maintenance of a kind that cannot be performed any other way.
It is easy to create a bootable USB stick in Linux. In these examples, I used a Raspberry Pi, but any Linux PC would do equally well.
Select a Spare USB Stick
Find a suitable USB stick. It doesn’t have to be anything fancy. An old one is fine. Make sure it is USB 2.0 (or 3.0) and at least 2 GB in size. In these examples I am using an old Bytestore 2 GB.
Choose the Rescue System
A wide range of bootable environments are available. We are going to look at three of them. The first is GParted, a small Linux distro designed specifically for partitioning your disk. The next, SystemRescueCD, is larger. It can partition disks too, but comes with many other recovery tools and a more usable environment then GParted. Linux Mint os the third environment and will be looked at last. It is a full Linux distribution.
Open a browser and surf to the GParted download page. About half way down is a table of Stable Releases. Click on the latest 32 bit version, and save the file. At the time of writing (May 2019), the latest version is 0.33.0-2. By the time you read this, it might well have been updated. (Note that the download redirects to SourceForge).
Alternatively, and it might be a bit easier, just grab the file with one command. Right-click on the download link, choose “Copy link location”, then use wget and paste the URL:
$ wget https://downloads.sourceforge.net/gparted/gparted-live-0.33.0-2-i686.iso
The GParted download is about 350 MB.
Write the Image to USB
Plug in your USB stick. If it mounts, unmount it. Use fdisk –l to check the device name, as follows.
$ sudo fdisk -l (stuff about other disks removed) Disk /dev/sdb: 1.9 GiB, 2063597568 bytes, 4030464 sectors
fdisk -l prints lots of stuff about all disks and partitions on my system. I can identify that the USB stick is /dev/sdb because that is the only device that is close to 2 GB in size, and my USB stick, as stated above, is 2.0 GB. (It shows up as 1.9 GB here).
Warning: The following command will erase all data currently on your USB stick. If you need to keep that data, do not proceed. Also, before typing the following command, be absolutely certain that you are using the correct device (/dev/sdb in this example, but it might well be different on your system). If you were to use the wrong device with this dd command, it could potentially destroy your system by overwriting part of your root disk. Please take care.
Having identified the right device, proceed as follows to write the image to it.
$ sudo dd if=gparted-live-0.33.0-2-i686.iso of=/dev/sdb
The dd command should take about 5 minutes on less. On a Raspberry Pi 2 it was just over 2 minutes.
Boot from USB
Put the USB stick into a convenient PC or laptop. Switch the machine on. (You might have to fiddle with the BIOS settings to tell the system to look for bootable USB devices). If it is working, you will see the USB boot menu, briefly, followed by a boot sequence. Click “Ok” when it asks about keymaps. The select a keyboard (I chose “02” for British), then choose option “0” to go straight into a graphical desktop.
In a minute the GParted screen appears. The GParted application itself is running in a Window. Apart from that, you are looking at Fluxbox, a sparse (but very compact) graphical window system. Right click anywhere to open a terminal or other application. At your disposal are Netsurf, a basic browser, various terminals, but not much else. When you have finished messing about, shut the system down and remove your USB.
The GParted environment is fine, but is really just intended for disk partitioning. SystemRescueCD offers a richer environment and comes with a bigger variety of tools. Download the latest ISO from the SystemRescueCD downloads page. The image size is about 800 MB. At the time of writing (May 2019), release 6.0.3 is the latest, so I will just grab it directly:
$ wget https://osdn.net/projects/systemrescuecd/storage/releases/6.0.3/systemrescuecd-6.0.3.iso
As before, write the ISO to the USB stick. This should take 5 minutes or so:
$ sudo time dd if=systemrescuecd-6.0.3.iso of=/dev/sda
Put the newly created SystemRescueCD USB stick into the PC of interest and boot from it. You will see the boot menu – press [Enter] to accept the default. A textual screen appears. To start the graphical environment, type “startx“, as instructed. In a few moments you will be looking at an XFCE graphical interface.
This is a much richer environment than GParted/Fluxbox. For a start, Firefox is available, instead of Netsurf. So is the GParted disk partitioning tool, in fact, as well the LVM subsystem and various applications useful in a rescue situation.
Putting a full Linux distribution onto a USB key is just as easy. You just need a bigger drive though. In this example, Linux Mint MATE is installed. Instead of a 2.0 GB stick, I will use a 32GB Corsair drive. As before, download the latest version of Linux mint, then dd it onto the stick.
For this example I will grab it with wget. You should probably use a browser,
$ wget http://www.mirrorservice.org/sites/www.linuxmint.com/pub/linuxmint.com/stable/19.1/linuxmint-19.1-mate-64bit.iso
Writing to the USB stick takes about 10 minutes:
$ sudo dd if=linuxmint-19.1-mate-64bit.iso of=/dev/sda
Afterwards, put the drive into your PC of interest and power on. It should boot into Linux Mint 19.2 without further intervention. Mint is, of course, a full desktop distribution. Not necessarily intended for use in a rescue or maintenance situation. But it could be used in one, coming with GParted, the LVM subsystem and many useful tools.
Having a SystemRescueCD USB drive around is always handy. It is a good idea to pack one in your laptopn bag. And update update it every so often. SystemRescueCD is a live project and new releases are quite frequent.