SARPi Project - Slacking on a Raspberry Pi
Create a bootable Slackware Linux USB recovery disk
Creating a bootable USB stick for Slackware Linux on a Raspberry Pi can be a utilitarian tool for troubleshooting, emergency recovery, testing, and many other purposes.
How many times have you (re)booted the Raspberry Pi after updating/upgrading only to find there's a kernel panic, or nothing more than a blank screen, or a rainbow screen, that's frozen with a flashing or constant green LED? Under such circumstances a bootable recovery disk can be instrumental towards overcoming such issues.
•
What you will need for this mini-project
• A Raspberry Pi configured to boot from USB mass storage.
• A USB stick with at least 8GB capacity. [NB: All data will be erased on this device!]
• A SARPi installer (xz tarball). [available from the Downloads page]
• The Slackware Linux source media.
In this SARPi mini-project we will be running Slackware ARM 15.0 on a Raspberry Pi 4 [2GB], with the hostname 'endo' and logged in as 'root' user. We're using a 32GB USB stick and will be creating a bootable USB Slackware Linux installer on it. Throughout this guide we'll be using '/tmp' as a working directory.
•
Quick Links
Preparing the USB stick partitions
Formatting and mounting the USB stick source media partition
Tips for using a bootable USB stick
•
Preparing the USB stick partitions
We have booted our Raspberry Pi 4 running Slackware ARM 15.0 and plugged a 32GB USB stick onto one of the USB ports. It's just as easy to prepare a bootable USB stick for Slackware AArch64 current - just note that the SARPi installer image will be different from the one shown in this guide.
NB: ALL data on this 32GB USB stick will be overwritten. So make sure yours does not contain any important data before you continue!
The first thing we do is to check the device ID of the USB stick so that we can write the SARPi installer image to it. For this we'll use the 'fdisk -l' command.
The result shows us that our USB stick is '/dev/sda' and it already contains a FAT32 partition. The partiton is not important as we will be overwriting it when we write the SARPi installer image to it in the next step. We achieve this with the 'xzcat' command. The SARPi installer image tarball file name should match the one used in command:
Or a more fancier way, with a progress bar, would be with 'xz' and piping it through a 'dd' command:
The SARPi installer tarball used was the latest available at the time this guide was created. The actual filename will be different to the one shown here. So just see it as an example and not take it as verbatim. Also take note that your USB stick may have a different device name than '/dev/sda' on your system.
The screenshot below shows the result of this process.
Now there should be a new FAT32 partition on our USB stick and we will check this using the 'fdisk -l' command once again.
The next thing we need to do is create a partition on our USB stick to store the Slackware ARM source media. For this we can use the 'cfdisk' or 'fdisk' commands. As we know out USB stick is '/dev/sda' we will do it like this:
This launches the cfdisk TUI where we can view, add, delete, or modify partitions. The screenshot below shows the new FAT32 partition which was created when we wrote the SARPi installer image to out USB stick. The "Free space" is what will be used to create another partition on which to store the Slackware Linux source media.
Use the down cursor key to highlight "Free space" and the [ New ] option should be highlighted on the resulting screen.
Press the key and you will be prompted to select the partition size. Press the key once more to use up all of the free space available. On the next screen select "primary" and again press the key. On the next screen we see that a new "Linux" partition has been created.
The "Linux" partition type needs to change. So press the right cursor key and highlight [ Type ] and then press the key. This will present a list of many different types of partitions than can be selected. We need to select "W95 FAT32 (LBA)" which is found by using the up cursor key (or key) to scroll to the top of the list. With "W95 FAT32 (LBA)" highlighted press the key to confirm this as the selected partition type.
This will change the partition type from "Linux" to "W95 FAT32 (LBA)" as shown in the screenshot below.
To make this change permanent we need to use the left or right cursor keys to highlight [ Write ] and press the key. We will be asked to confirm that we want to do this by a "Are you sure you want to write the partition table to disk?" question, which we answer by typing the word "yes" and pressing the key. A message will appear at the bottom of the screen notifying us that the partition table has been altered.
Now we can exit the cfdisk TUI by using the left or right cursor keys to highlight [ Quit ] and press the key.
Now when we use 'fdisk -l /dev/sda' command to check out the changes we just made it should show us there are now two FAT32 partitions on our USB stick. The screenshot below shows exactly what we expected.
Now our USB stick source media partition has been created, and we know it is '/dev/sda2', we can format it with a filesystem and mount it.
Formatting and mounting the USB stick source media partition
Before any partitions can be mounted they need formatting with a filesystem. As we have specified a FAT32 partition type we will format it with a vfat filesystem. This is achieved with the 'mkfs' command.
We can then check that formatting the partition with the vfat filesystem has been successful with the 'blkid' command. The TYPE="vfat" in the screenshot below from the output of the 'blkid' command confirms this.
Now we can mount the '/dev/sda2' source media partition on our USB stick. We will use an existing '/mnt/floppy' directory for a mount point.
With our Slackware ARM source media partition mounted, we will download the Slackware ARM 15.0 source media from the slackware.uk repository using the 'rsync' command. It's quick, easy, and reliable. For convenience we will instruct rsync to download the files straight into our '/mnt/floppy' mount point directory.
This might take a while, depending on the speed of the Internet connection.
Once the Slackware ARM source media has been downloaded we can check it with the 'ls' command.
The screenshot below shows that all the files are present and correct, as expected.
The last thing to do is unmount the USB stick partition from our mount point directory.
Now the USB stick can be unplugged from the system and our 'bootable USB recovery disk Slackware ARM installer' is ready to be used.
All that's required is to plug this USB stick into a Raspberry Pi 4 that's configured to boot from a USB mass storage device and power it on.
NB: It's worth remembering that the USB stick we prepared in this guide is optimised for the Raspberry Pi 4 and will not boot on other devices. For creating a bootable USB stick on other Raspberry Pis the appropriate SARPi installer tarball should be used to initially write to the USB stick. The creation process is exactly the same.
•
Tips for using a bootable USB stick
To use the bootable USB stick to install Slackware ARM, if a SD card is going to be used as the storage drive then wipe any existing partitions from the card before inserting it into the Raspberry Pi and powering it on with the bootable USB stick plugged in to one of the USB ports. If installing on a SSD drive connected via a SATA-USB adapter then plug it in once the system has booted to the command prompt.
It's also possible to write a SARPi installer to a SD card, or SSD, and use the bootable USB stick as the Slackware Linux source media for installing the OS. In situations where no Internet/network connection is available, etc.
To use the bootable USB stick as a recovery disk, when troubleshooting a SD card then use a USB-SD card adapter and plug it in after the system has booted. The same with a SSD drive for problem solving any issues.
•
Thanks!
Thank you for reading and taking part in this SARPi mini-project. We hope you enjoyed it and found it interesting and educational.
Thanks also to Patrick Volkerding, and the entire Slackware Team, for producing a truly wonderful OS. Without you, and the work you do, the SARPi Project would not exist.
If you have any questions or need help, visit the Slackware Linux Forum on Linux Questions. Or get in touch on the #SARPi IRC channel on irc.libera.chat.
•