Thanks to visit codestin.com
Credit goes to github.com

Skip to content

1stcall/sdm

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

sdm

Raspberry Pi SSD/SD Card Image Manager

To Do

  • Write a plugin (probably) to expire password to force a password change apon the 1st interactive login.
  • Write a plugin to upgrade to testing release. Bullseye at the moment. Test is sid would work. Current code in 20bookworm-backports and 70devtools_bookworm. This may allow 1 plugin for backports!
  • Consider moving bookworm-sources.list to sources.list.d/ & removing sources.list. This would be part of the upgrade plugin above. Current code is in 20bookworm-backports.
  • Write a plugin to remove unwanted/unneeded apps. triggerhappy, dphys-swapfile (if zram-tools is installed or is to be installed). Maybe remove dphys-swapfileat the same time as installing zram-tools.
  • Light mode for coloured output of logs. Think about html output for the webui (see below).
  • Design/Build web api and webui.
  • Split up plugin 70devtools* into indervidual plugins per app.
  • Move downloading keys and adding repos to stage 0 (Mounted environment) in 70devtools* pluin.
  • 10mydotfiles: Seperate the copying of the assets directory into a seperate plugin. Pass a list of files to install as arguments or a file containing the list.
  • 30configgit: Add name, email and default branch as arduments to the script.
  • 50setnfsroot: Look at using sed to edit the stock config.txt and fstab files.
  • 70devtools_bookworm: Add args for apt-get's [no]install-recomends parameter. Add args for using a file for a list of packages to install. Alternativly, break down into multiple plugins, 1 for each package.
  • 70devtools_bullseye: As 70devtools_bookworm.
  • 80k3s: Pass args for INSTALL_K3S_* environment variables used in the install script.
  • Enable setting the machine host key rather than using a generated one. This is to prevent ssh rejecting logins if the host os has been reinstalled. Currently requires the key being removed from ~/.ssh/known_hosts on the client if the host is rebuilt.

Description

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: [email protected].

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!

Usage overview

sdm Quick Start

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.

Install 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 images subfolder of raspios_armhf (32-bit), raspios_lite_armhf (32-bit), raspios_arm64 (64-bit), or raspios_lite_arm64 (64-bit), as appropriate. Buster images are in the folders raspios_oldstable_lite_armhf and raspios_oldstable_armhf.

Customize the image with sdm

sudo sdm --customize --wpa /path/to/working/wpa_supplicant.conf --L10n --restart --user myuser --password-user mypassword 2022-04-04-raspios-bullseye-armhf.img

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 and apt 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.

Burn the image onto the SD Card

sudo sdm --burn /dev/sde --hostname mypi1 --expand-root 2022-04-04-raspios-buster-armhf.img

Boot and Go

Load the SD card into a Pi and power it up. The system will come up as it always does:

  • WILL NOT: Resize the root file system and restarts automatically, thanks to the use of --expand-root, which expands the root file system on the SD Card after the burn completes.
  • 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
  • User created and password set for username and password of your choice
  • 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

What else can sdm do?

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.

    See Example Commands for some examples, and also see the files sdm-apps-example and sdm-xapps-example in this GitHub.

  • Install and configure VNC — Have every system or only selected systems 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. See VNC.

  • 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. See --bootset and 1piboot.

  • 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. This can be done easily with a personal Plugin. See my personal plugin for an example.

  • Append Custom fstab file to /etc/fstab — Automatically append your site-specific fstab entries to /etc/fstab. See fstab details.

  • systemd service configuration and management — If there are services that you always enable or disable, you can easily configure them with sdm. See --svc-disable and --svc-disable descriptions here.

  • Other customizations — Done through a simple batch script called a Plugin. sdm-plugin-example is a skeleton Plugin that you can copy, modify, and use. See Programming Plugins.

  • 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.

Complete sdm Documentation

Need more details? You'll find complete details on sdm in the online documentation. You can watch sdm in action here

About

Raspberry Pi SD Card Image Manager

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Shell 95.1%
  • Python 4.8%
  • Roff 0.1%