Raspberry Pi SSD/SD Card Image Manager
sdm
provides a quick and easy way to build consistent, ready-to-go SSDs and/or SD cards for the Raspberry Pi. This command line management tool is especially useful if you:
-
have multiple Raspberry Pi systems and you want them all to start from an identical and consistent set of installed software packages, configuration scripts and settings, etc.
-
want to rebuild your Pi system in a consistent manner with all your favorite packages and customizations already installed. Every time.
-
want to do the above repeatedly and a LOT more quickly.
What does ready-to-go mean? It means that every one of your systems is fully configured with Keyboard mapping, Locale, Timezone, and WiFi set up as you want, all of your personal customizations and all desired RasPiOS packages and updates installed.
In other words, all ready to work on your next project.
With sdm
you'll spend a lot less time rebuilding SSDs/SD Cards, configuring your system, and installing packages, and more time on the things you really want to do with your Pi.
Have questions about sdm? Please don't hesitate to ask in the Issues section of this github. If you don't have a github account (so can't post an issue/question here), please feel free to email me at: gitbls@outlook.com.
Need more details? Watch sdm in action here
If you find sdm useful, please consider starring it to help me understand how many people are using it. Thanks!
Here's how to quickly and easily to create and customize an IMG file and burn it to an SD Card. It's assumed that there is an SD Card in /dev/sde.
Throughout this document read "SD Card" as "SSD or SD Card". They are treated equivalently by sdm.
curl -L https://raw.githubusercontent.com/gitbls/sdm/master/EZsdmInstaller | bash
- If needed, download the desired RasPiOS zipped IMG from the raspberrypi.org website and unzip it. Direct link to the downloads: Raspberry Pi Downloads. Pick the latest (Bullseye) image in the folder raspios_full_armhf (32-bit), raspios_lite_armhf (32-bit), raspios_arm64 (64-bit Beta), or raspios_lite_arm64 (64-bit Beta), as appropriate. Buster images are in the folders raspios_oldstable_lite_armhf and raspios_oldstable_armhf.
sudo /usr/local/sdm/sdm 2020-08-20-raspios-buster-armhf-full.img --customize --wpa /path/to/working/wpa_supplicant.conf --L10n --restart
sdm will make the following changes to your IMG file:
- Copy your Localization settings (Keymap, Locale, Timezone, and WiFi Country) from the system on which it's running
- Copy the wpa_supplicant.conf you specified into the IMG file at /etc/wpa_supplicant/wpa_supplicant.conf
- Configure the system in the IMG file to have SSH enabled
- Prompt for a new password for user pi
- Do an
apt update
andapt upgrade
No additional packages are installed in this example, but as you'll see, it's a simple addition to the command line to install your list of packages.
sudo /usr/local/sdm/sdm --burn /dev/sde --hostname mypi1 2020-08-20-raspios-buster-armhf-full.img
Load the SD card into a Pi and power it up. The system will come up as it always does:
- Resizes the root file system and restarts automatically
- After the system restarts it goes through a complete system startup, just as it always does on a fresh SD Card
- Toward the end of the boot process an sdm systemd service script runs once and sets the WiFi country, unblocking WiFi. It will also take other actions as needed to fulfill the switch settings.
- When the system boot is fully complete (it can take a while on a large SD card!), the system automatically restarts again
When the system comes back up your Pi is all happy, ready to go, and configured with:
- The latest RasPiOS updates installed for all installed packages
- Password set for user 'pi'
- Hostname set to mypi1, or whatever you choose to use as the hostname
- Keymap, Locale, and Timezone configured the same as the system on which you are running sdm (easily changeable, of course)
- Wifi configured and operational
- SSH enabled
Here are a few examples:
-
Install applications — Editors (emacs, vim, etc), and any other packages you always install in a new system. sdm has two built-in package install lists, creatively named apps and xapps. You can select which of the two lists to include when you build an image, so you can build images with no additional apps, apps only, xapps only, or both.
-
Install and configure VNC — Have every system come up with VNC installed and configured, using either RealVNC on the console, or TightVNC or TigerVNC virtual desktops. Or a combination of RealVNC on the console AND virtual desktops.
-
Install and configure an Access Point (hotspot) — Install a customizable, fully operational hotspot in any of three modes: local, routed, or bridged.
-
Enable Pi-specific devices — Easily enable camera, i2c, etc, via raspi-config automation
-
Personal customizations — Have every system come up running with your own customizations such as your favorite .bashrc and any other files that you always want on your system
-
Append Custom fstab file to /etc/fstab — Automatically append your site-specific fstab entries to /etc/fstab
-
systemd service configuration and management — If there are services that you always enable or disable, you can easily configure them with sdm
-
Other customizations — Done through a simple batch script.
sdm-customphase
is a skeleton Custom Phase Script that you can copy, modify, and use. -
Burn SD Card Image for network distribution — You can build a customized SD Card Image to distribute via a mechanism other than an actual SD Card, such as the Internet.
The recipient can burn the SD Card using any one of a number of tools on Linux (Installing Operating System Images), Windows (Installing Operating System Images Using Windows), or MacOS (Installing Operating System Images Using MacOS).
-
Update an already-burned RasPiOS SD Card or SSD — use the
--explore
command switch to nspawn into the SD Card or SSD. While in the nspawn you can take care of system management activities in a near-online manner, such as changing the password for an account, installing additional packages, etc.This can be VERY handy if you forget the password to the 'pi' account on your favorite SD Card, for instance. You can boot up a second SD Card, install sdm on it, and then use
sdm --explore
to update the 'pi' account password on that favorite SD Card.
Need more details? You'll find complete details on sdm in the Wiki, and you can watch sdm in action here