Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 3923

Advanced users • sdm: Quickly and easily create your own fully customized RasPiOS IMGs and disks

$
0
0
sdm has been around for a while, but hasn't had an "official" announcement topic in these forums. Until now.

Apologies if I'm over-enthusiastic about sdm. I'm super-jazzed by sdm's capabilities, and hope that you'll find it useful.

What is sdm?

sdm is a tool for building your customized RasPiOS (Lite or Desktop) IMGs from an RPL-distributed IMG. It's kind of like an editor for RasPiOS IMGs. After you customize an IMG, use sdm to burn it to an SSD/SD Card and boot.

The more you customize with sdm the less you need to do manually when you boot the new system for the first time.

sdm's builtin plugins each perform specific configuration functions (add a user, configure wifi, install apps, etc). The plugins are simple easy-to-use bash scripts.

These built-in plugins provide a rich set of capabilities that enable you to do whatever you'd want to do once your system is up and running. With sdm you can do all those steps automatically, and have complete, usable documentation for what you did.

You can also create your own plugins for whatever you'd like. sdm is written in bash. It's easy to start with the sample template to create your own plugin. Once you know the configuration changes you'd normally type into a new system to make it the way you want it you can put them in a plugin and run them automatically for your next RasPiOS systems.

After a small learning curve sdm will shrink your time to bring up a new system significantly and repeatedly, since all the configuration is done automatically.

Topics covered in this note
  • Why use sdm?
  • What host operating systems does sdm run on?
  • What IMGs can sdm customize?
  • The more Pi systems you have the more you'll like sdm
  • Move to Debian Trixie with ease
  • Plugin overview
  • sdm features available when burning disks
  • How to get started with sdm
  • Installing or upgrading sdm
  • What about rpi-imager and pi-gen?
  • sdm doesn't do everything
  • One last thing
Why use sdm?

sdm dramatically simplifies the process of getting a new system up and running. It does this in two ways:
  • sdm makes it very easy to create your customizations with plugins
  • sdm uses an easy-to-use standard Linux command line interface and is fully documented
What host operating systems does sdm run on?

sdm runs on a fairly broad set of host operating systems:
  • RasPiOS, both Lite and Desktop
  • Debian on ARM or X64
  • Debian derivatives such as Ubuntu, Mint, ... on ARM or X64
  • WSL2 on Windows OS running compatible guests (Debian or derivatives)
  • Debian VM on MacOS
Some environments, Windows WSL2 and MacOS in particular, (still) don't allow direct access to raw disks, which means that sdm can't be used for burning disks on these systems. In these environments sdm can burn to a disk IMG. You can then burn that fully customized IMG to a raw disk with a host OS-based tool

What about a distro that's not listed above? If it doesn't use apt to install packages, you're on your own to install (it's not very difficult). sdm may or may not work on some distros/versions because of version skew in tools that it uses. Ah, the Linux life! ;)

What IMGs can sdm customize?

sdm operates on RasPiOS Bookworm Lite, Desktop, and Desktop Full IMGs. It also still works on older RasPiOS releases such as Buster and Bullseye.

Other distro IMGs may or may not work, depending on how much like RasPiOS they are with OS configuration files and tools like raspi-config, and what you want to use it for. Best way to know is to just try it.

The more Pi systems you have the more you'll like sdm

If you're like a lot of us here, you have multiple Pi systems. You can build the disks for all your 64-bit capable Pis from a single IMG and likewise for 32-bit. If some systems require additional configuration (add additional packages or configuration, etc), you can perform that configuration when burning the disk.

Plus, if some of your systems need additional unique configuration you can take care of that easily when you burn disks for those systems. This is very handy for certain deployment scenarios. sdm makes it easy to create multiple Pi IMGs or disks that are identical except for hostname, username(s), and whatever else you choose.

Move to Debian Trixie with ease when it's released

As many of us know, upgrading from one Debian release to the next can be challenging. If you are able to build your Bookworm system with sdm you'll be able to quickly and easily build your customized Trixie (Debian 13) system.

No more guessing how you did something. You've got all the code at your fingertips.

Some of the plugins are pretty cool

Here are several that you might find interesting and/or useful. Plugins that can be run multiple times are noted with **
  • apps** -- Install a list of apps
  • bootconfig -- Manage config.txt
  • btwifiset -- Configure the Pi's WiFi via Bluetooth
  • hotspot -- Configure either a routed or bridged hotspot
  • copyfile** -- Copy a file into the IMG
  • copydir** -- Copy a directory into the IMG
  • cryptroot -- Set up to encrypt rootfs during the first system boot process
  • L10n -- Configure keymap, locale, and timezone
  • lxde -- Copy saved LXDE GUI config files into the IMG
  • mkdir** -- Create a directory in the IMG
  • network** -- Configure WiFi or ethernet networking
  • piapps -- Install pi-apps
  • syncthing** -- Install syncthing and enable for a specific user
  • system -- Configure systemd/fstab/sysctl and more
  • trim-enable -- Enable trim on disk drives
  • user** -- Add, delete, configure user accounts
  • ...and many more
Handy sdm capabilities for burning disks

sdm can quickly and easily burn a disk or a disk IMG, by default with `dd`. sdm extended burn capabilities include:
  • Create the disk with GPT partitions
  • Convert rootfs to `btrfs` or `lvm` using `rsync`
  • Expand the root partition to fill the disk. Or not, including at boot
  • Expand the rootfs by a specific amount
  • Add additional partitions to the burned disk
Additionally, sdm performs some configuration after the burn has completed. These include:
  • Set the hostname
  • Run additional plugins
  • Use the `network` plugin during the burn to configure unique wifi or other unique target network configuration
  • Automatically enable SSH (can be disabled with the `network` plugin)
  • Per-disk unique configuration by running plugins on the just-burned disk (add users, specific apps, etc)
sdm has a tool to build unbooted configuration disks or IMGs for multiple unique Pis from a single IMG, very useful for classrooms, software distribution, and multi-system deployment.

How can I get started?
Here's an example script to customize an IMG that you can start with. It adds a new user, installs some apps, configures WiFi, enables trim on all trim-capable disks, and configures localization (keymap, locale, and timezone): https://raw.githubusercontent.com/gitbl ... ster/ezsdm

How do I install or upgrade sdm?

Use this command to install or upgarde sdm on your system.

Code:

curl -L https://raw.githubusercontent.com/gitbls/sdm/master/EZsdmInstaller | bash
What about rpi-imager and pi-gen?

If you prefer GUI interfaces, rpi-imager may be a better tool for you. Plus, it is implemented by RPL rather than some guy on the internet :lol:

If you want to control what specific contents are in the IMG you use instead of using the RPL-generated IMGs, pi-gen may be a better tool for you. You can probably do most of what sdm does with pi-gen, but it could require more effort and steeper learning curve.

sdm doesn't do everything

Here are the types of things that sdm can't do:
  • Configure a GUI application using the GUI inside sdm. But if that GUI has a configuration file, you can create it using the GUI and automatically drop it into your IMG with sdm
  • Operate on IMGs other than RasPiOS. Sorry
  • Run on non-Debian family host operating systems
  • Run on Windows hosts older than Windows 10
One last thing

sdm is capable of running its plugins on a booted system. This means you can use super-handy plugins like hotspot, cryptroot, piapps, syncthing, and trim-enable on an already booted and running RasPiOS or Debian Bookworm system.

How cool is that? ;)

Statistics: Posted by bls — Sat Aug 31, 2024 10:52 pm



Viewing all articles
Browse latest Browse all 3923

Trending Articles