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.

SARPi Project muse views ... 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.

fdisk

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:

root@torq:/tmp# xzcat sarpi4-installer_slack15.0_13Mar24_sp1.img.xz > /dev/sda

Or a more fancier way, with a progress bar, would be with 'xz' and piping it through a 'dd' command:

root@torq:/tmp# xz -dc sarpi4-installer_slack15.0_13Mar24_sp1.img.xz | dd of=/dev/sda bs=65536 status=progress

SARPi Project muse views ... 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.

xz

Now there should be a new FAT32 partition on our USB stick and we will check this using the 'fdisk -l' command once again.

fdisk

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:

root@torq:/tmp# cfdisk /dev/sda

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.

cfdisk

Use the down cursor key to highlight "Free space" and the [ New ] option should be highlighted on the resulting screen.

cfdisk

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.

cfdisk

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.

cfdisk

This will change the partition type from "Linux" to "W95 FAT32 (LBA)" as shown in the screenshot below.

cfdisk

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.

cfdisk

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.

fdisk

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.

root@torq:/tmp# mkfs.vfat /dev/sda2

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.

mkfs.vfat

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.

root@torq:/tmp# mount /dev/sda2 /mnt/floppy

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.

root@torq:/tmp# rsync -Prv --delete slackware.uk::slackwarearm/slackwarearm-15.0/ /mnt/floppy

This might take a while, depending on the speed of the Internet connection.

rsync

Once the Slackware ARM source media has been downloaded we can check it with the 'ls' command.

root@torq:/tmp# ls /mnt/floppy

The screenshot below shows that all the files are present and correct, as expected.

slackwarearm source

The last thing to do is unmount the USB stick partition from our mount point directory.

root@torq:/tmp# umount /mnt/floppy

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.

SARPi Project muse views ... 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.

Back to Top


Updated: 2024-03-14 13:06:31 UTC

Disclaimer: The SARPi Project website is for non-commercial and general information purposes only. The content is provided by Penthux.NET and while we endeavour to keep information up to date and correct, we make no representations or warranties of any kind, express or implied, about the completeness, accuracy, reliability, suitability or availability with respect to the website or any information, software, products, services, or related graphics which is available on the website for any purpose. Any reliance you place on such information is therefore strictly at your own risk. In no event will Penthux.NET be liable for any loss or damage including without limitation, indirect or consequential loss or damage, or any loss or damage whatsoever arising from loss of data or profits arising out of, or in connection with, the use of this website or any of its contents. Through this website you are able to visit other websites which are not under our control. Penthux.NET has no influence over the nature, content or availability of any external URLs. The inclusion of any URLs does not necessarily imply a recommendation or endorsement of any content therein. Every effort is made to ensure the SARPi Project website remains accessible. However, Penthux.NET takes no responsibility for, and will not be liable for, the SARPi Project website being temporarily unavailable due to technical issues beyond our control. SARPi Project is in no way affiliated with Slackware Linux, Inc, or the Linux Foundation, or Raspberry Pi Ltd., or any of their respective members, trustees, partners, or associates.


Accept!

SARPi Project uses cookies for website traffic data analytics purposes only. Cookies from this website do not collect or store any of your personal data.

Please read the SARPi Project website [ Cookie Policy ] for more details.