A Creating a Linux Installer on Flash/USB Devices – Linux Administration: A Beginner's Guide, Eighth Edition, 8th Edition

APPENDIX

A

Creating a Linux Installer on Flash/USB Devices

In Chapter 2, we explained the installation process of Fedora and Ubuntu Linux distributions using bootable flash/USB media. However, we didn’t go into the details of how to actually create bootable install media on a flash/USB-based device! This appendix presents some methods for quickly creating a Linux distribution installer on inexpensive and readily available and reusable flash-based media, including the various types of USB sticks, SD cards, microSD cards, and so on.

Overview

There are two popular approaches to creating a Linux installer. One approach is to use a native or distro-specific solution; the other approach is more universal. The native or distro-specific approach assumes you have access to an existing and running GNU/Linux-based distro. While this is probably the most ideal or convenient approach, we admit that it is not always possible. On the other hand, the universal approach assumes the opposite—that is, you only have access to other platforms, such as Windows or macOS.

Regardless of the approach, the objective remains the same across all platforms (Windows, Linux, and macOS): create bootable and installable flash/USB drives for Fedora, RHEL, openSUSE, Debian, Ubuntu, and other Linux distributions without burning a CD or DVD. We cover all these solutions in more detail in the following sections.

Native Solutions

The native approach involves using common GNU/Linux CLI tools that are almost always available on every Linux/UNIX-based system.

Creating a Linux Installer on Flash/USB Devices (via GNU/Linux OS)

In this section, we assume you have ready access to a system currently running a GNU/Linux distro and can easily run any of the commands from the shell. This is an example of an ideal native solution. Here’s what you need for this solution:

•   A system that can boot from a flash-based device

•   A target flash-based device (at least 4GB in size)

•   An ISO or other image file of your Linux distro of choice

•   A system running any Linux-based operating system (Fedora, Ubuntu, openSUSE, RHEL, CentOS, and so on)

And here are the steps to follow:

1.   While logged into a terminal or shell prompt of your Linux distro as a user with administrative privileges (for example, root), change to a directory on the file system with sufficient free space (use the df -sh command to check). We’ll use the /tmp folder in this example:

# cd /tmp

2.   Download an ISO file of the Linux distribution onto an area on your file system with sufficient free space. For example, you can download the latest 64-bit Server version of Fedora from https://fedoraproject.org (or https://getfedora.org) by typing

where <URL> is the full path to the directory on the download server (for example, https://dl.fedoraproject.org/pub/fedora/linux/releases/<VERSION>/Server/x86_64/iso/).

The placeholder labeled <VERSION> in the filename (Fedora-Server-dvd-x86_64-<VERSION>.iso) and in the URL represents the latest version number for Fedora that is available at the time you are reading this. For example, for Fedora server version 34, the actual ISO filename will be something like Fedora-Server-dvd-x86_64-34-1.2.iso.

Similarly, you can find the latest development Rawhide streams of Fedora—which should NEVER BE USED IN PRODUCTION—under this tree: https://dl.fedoraproject.org/pub/fedora/linux/development/rawhide/Server/x86_64/iso/. The latest rawhide ISO images are named with the current date stamp appended to their filename (for example, Fedora-Server-dvd-x86_64-Rawhide-20210130.n.0.iso).

For the purposes of this example, assume that the ISO file is 2.1GB. Therefore, we need to make sure that the target flash/USB-based device is at least as big. A 4GB flash drive is perfect in this instance.

3.   Plug the flash-based device into the appropriate port on the host system.

4.   You need a way to uniquely identify the device file the Linux kernel associates with the flash device that’s plugged in. It is very important that you properly identify the target device so that you don’t accidentally overwrite the wrong device! CLI utilities such as mnt, blkid, fdisk, lsusb, and dmesg can help in identifying your desired target device. You might have to run some of these tools before plugging in the new device to note the current state of the system, then run them again after plugging in the device, and then compare both outputs. The difference in the output is almost always the new device! The dmesg command allows you to examine the Linux kernel ring buffer and provides one method for identifying the device. The most recent contents or activities in the buffer can be viewed at the tail end of the output. To view the ten most recent entries (lines) of the buffer, type the following:

The output indicates that the kernel has just noticed and enumerated a new device, and the device name is sdb (/dev/sdb). As an aside, we also notice that the device also has one partition—sdb1 (/dev/sdb1).

5.   With the previous information, we are now ready to write the downloaded ISO image file to the detected target flash medium (/dev/sdb). We will use the venerable dd utility for this purpose, as shown next. Don’t forget to replace <VERSION> in the command with the correct version number for your ISO file.

6.   Once the previous command runs to completion, you will be returned to your shell prompt. You may now unplug the flash device and insert it into the appropriate port of the new system on which you want to install Linux.

7.   If necessary, configure the BIOS or the UEFI of the target system to boot off the flash-based device. Once you have booted into the installer, follow the installation steps as described in Chapter 2, or as specified by the distro vendor.

Distro-Specific Solutions

The distro-specific approach exists because various popular Linux distributions have developed easy-to-use GUI tools that can help end users successfully write the specific distro’s ISO image to flash/USB devices. Some popular distro-specific solutions are listed here:

Universal Solutions

The universal approach is dependent on third parties (not on specific Linux distribution vendors) creating and maintaining GUI tools that can be used by end users to easily write/convert the installer image files of different distros into a format that is bootable/usable on a flash or USB device.

Table A-1 shows a mix of old and new applications that can be used for creating bootable install mediums from flash/USB-based devices. We have carefully curated this list based on factors such as availability at the time of writing, cross-platform support across the major OSs, coolness factor, and of course functionality!

Here are the general procedure and requirements for making use of any of these tools:

•   A base system you can install or run the chosen application on (see Table A-1)

•   A suitably sized flash/USB device (big enough to hold the ISO file for the distro)

•   An ISO or other image file of the desired Linux distribution

•   A target system that can boot from a flash-based device

Table A-1 Third-party Install Media Applications

The following sections walk you through three use cases in which a Linux installer is created on a flash/USB-based device using a system running Windows or macOS.

NOTE  Bootable flash/USB-based drive creators come and go. And we literarily mean they come and go! Over the years, many FOSS projects have been spun up solely for the purpose of making it easier for people coming from other operating systems to try and/or install any Linux distribution. Overtime, several of these projects have gained mind share and stood the test of time, and others have fizzled away. It’s no wonder that some of these applications struggle to keep up with the break-neck speed at which development is done in the FOSS world.

Creating a Fedora Installer Using Etcher on macOS

In this section, we walk through the process of using a sample universal solution (Etcher) to create a Fedora installer on flash/USB media via a system running macOS.

Here’s what you’ll need:

•   A system running any recent macOS operating system—that is, macOS 10.10 (Yosemite) and newer versions

•   An ISO or other image file of the desired Fedora version

And these are the steps to follow:

1.   While logged into a macOS system, use a web browser to download the latest version of Etcher from the project web site at https://www.balena.io/etcher/.

2.   Install the downloaded disk image file (dmg) file for Etcher as you would any other macOS application.

TIP You can also use the built-in macOS “Disk Utility” app to write ISO images to USB or flash medias. In macOS, you can launch Disk Utility via Applications → Utilities or use Spotlight to search for the app.

3.   If you haven’t already done so, download a copy of the ISO image file for the version of the Fedora distro that you want to write onto the flash/USB device. You can download ISO images for different Fedora versions from https://getfedora.org.

4.   Plug the flash/USB-based device into the appropriate port of the host macOS system.

5.   Launch Etcher from the Applications menu or via Spotlight Search.

6.   Click the Select Image button and then use the Finder app to navigate to and select the distro ISO you downloaded. Click Open after selecting the ISO file.

7.   The application will automatically transition to the target selection stage. Click the Select Target button.

A screen will pop up showing a list of automatically detected eligible removal drives.

8.   Identify and select the correct USB/flash medium. A checkmark should appear beside your selection. Click Continue.

9.   The application will proceed to the final flash stage. Click the Flash! button.

You might be presented with another pop-up screen prompting you for a username and password to authorize Etcher (or balenaEtcher) to make changes. Enter the credentials for a privileged user account on the system and click OK.

10.   The process will begin and show you a flashing progress and validation indicator.

11.   If all goes well, you’ll be presented with a “Flash Complete!” screen like the one shown here:

12.   Close the application. You may now unplug the flash/USB device and insert it into the appropriate port of the new system on which you want to install the Linux distribution.

13.   If necessary, configure the BIOS or the UEFI of the target system to boot off the flash/USB-based device. Once booted into the installer, follow the installation steps as described in Chapter 2, or as specified by the distro vendor.

TIP  You might be pleasantly surprised that you can actually boot, install, and run most popular Linux distros on a wide variety of native Apple hardware (MacBooks, Mac minis, iMacs, and so on) using any bootable Linux distro install media.

Creating an OpenSUSE Installer via Universal USB Installer on Windows

In this section, we walk through the process of using a sample universal approach. We’ll install and use the Universal USB Installer (UUI) program to create an openSUSE installer on flash/USB media via a system running Windows. Here are the steps:

1.   While logged into a system running Windows, use a web browser to download the latest version of UUI from the project web site at www.pendrivelinux.com/universal-usb-installer-easy-as-1-2-3/.

2.   If you haven’t already done so, download a copy of the ISO image file for the version of the openSUSE distro you want to write onto the flash/USB device. You can start from the main openSUSE home page (www.opensuse.org) to browse and search for the ISO image for your desired openSUSE stream.

3.   Plug the flash/USB-based device into the appropriate port on the host system.

4.   Double-click the UUI executable (Universal-USB-Installer-<VERSION>.exe) you downloaded earlier. Follow all the usual steps as you normally would when installing or launching any Windows-based program.

5.   You will next be presented with a screen where you can select the Linux distro to set up. Click the drop-down field labeled Step 1 to reveal a plethora of Linux distros. Search for and select OpenSUSE 64bit from the list.

6.   Select the Show All ISOs check box. Use the Browse button in the second field (labeled Step 2) to find and select the openSUSE ISO image you downloaded earlier.

7.   Select the Show All Drives check box in Step 3 and then select the appropriate drive letter associated with the flash/USB device from the list. If available, select the check box to format the USB drive you selected.

8.   The completed dialog box should reflect the choices made (for example, the path to and name of the ISO image, the drive letter of the target USB device, and so on).

9.   Click the Create button to start the process.

10.   Click Yes at the next summary screen showing what the program will do.

11.   UUI will do its thing and present you with an “Installation Complete” screen if everything goes well. Click the Close button in the final screen to exit the program.

You may now unplug the flash/USB device and insert it into the appropriate port of the new system on which you want to install Linux.

12.   If necessary, configure the BIOS or the UEFI of the target system to boot off the flash/USB-based device. Once booted into the installer, follow the installation steps as described in Chapter 2, or as specified by the distro vendor.

Creating an Ubuntu Installer Using UNetbootin on Windows

UNetbootin is the Swiss Army knife of universal bootable flash/USB device creators. It is supported on multiple platforms—Linux, Windows, and macOS. It has built-in support for creating bootable flash/USB versions of all the popular Linux distros (as well as the not-so-popular ones). It even supports various esoteric utilities (such as FreeDOS, Super Grub Disk, Parted Magic, BackTrack, NTPasswd, Ophcrack, and so on) that often come in handy for system administration tasks. UNetbootin can be used as a stand-alone executable and, as such, does not need to be installed before using it.

As an added bonus, UNetbootin can be used in two modes. You can either explicitly supply an existing ISO image or let the program automatically download your chosen distribution version for you—on the fly!

Assuming you have an Ubuntu ISO version already downloaded, here’s what you need:

•   A system running any supported and recent member of Microsoft’s family of operating systems (Windows 7, 8, 8.1, or 10, XY, and so on)

•   A suitably sized flash/USB device (big enough to hold the ISO file for the distro)

•   A target system that can boot from a flash-based device

Once you have all the prerequisites in place, download the software from https://unetbootin.github.io. Launch or install the application as you would any other Windows program.

We are going to use an existing distro ISO image here, so select the DiskImage radio button and browse to the existing Ubuntu distro ISO. Follow the prompts and complete the various self-explanatory fields with any information required (Target USB Device Type, Target Device Drive Letter, and so on).

Click OK after completing all the needed fields to start the process. When the process completes, close the UNetbootin window.

You may now unplug the flash/USB device and insert it into the appropriate port of the system on which you want to install your GNU/Linux OS. Boot with the device and continue with the installation as needed.