added rpi-lvm-imager

This commit is contained in:
2026-01-02 12:45:12 +01:00
parent 9990f05cf5
commit 71369509dd
2 changed files with 453 additions and 3 deletions

View File

@@ -6,9 +6,9 @@ are of any benefit to other enthusiasts. Use them freely and please let me know
in case you encounter any issues or require changes.
The latest versions, documentation and bugtracker available on my
[GitLab instance](https://gitlab.lindenaar.net/scripts/raspberrypi)
[Gitea instance](https://gitea.lindenaar.net/scripts/raspberrypi)
Copyright (c) 2019 Frederik Lindenaar. free for distribution under
Copyright (c) 2019 - 2025 Frederik Lindenaar. free for distribution under
the GNU General Public License, see [below](#license)
Contents
@@ -24,6 +24,8 @@ This repository contains the following scripts:
is a systemd service to disable on-board WiFi on Raspberry Pi at boot
* [rpi_poweroff_button.service](#services)
is a systemd service to support a power-off button using [gpio_trigger.py](#gpio_trigger)
* [rpi-lvm-imager.sh](#rpi-lvm-imager)
initialize an NVME drive with Raspberry Pi OS (Lite) on LVM
<a name=gpio_trigger>gpio_trigger.py</a>
@@ -94,6 +96,37 @@ systemctl disable service <<filename without .service>>
~~~
<a name=rpi-lvm-imager>rpi-lvm-imager.sh</a>
--------------------------------------------
This script will wipe and partition a (large) storage device with a small boot
partition, setup LVM for the rest of the disk, and then writes the latest
version of Raspbian Pi OS (Lite) or another OS image availabile via the
Raspberry Pi Imager to LVM managed partition(s) and makes the device bootable.
The reason I worte this script was that the Raspberry Pi Imager can only write
an image to a full disk and does not allow one to partition it nor perform the
installation on an LVM managed disk. This was needed for a Raspberry Pi 5 with
NVME SSD as the device had way more diskspace than would ever be needed/useful
for the system partition.
This script was inspired by the write-up found [here](https://raspberrypi.stackexchange.com/questions/7159/can-the-raspberry-boot-to-an-lvm-root-partition).
That was apparently superseded by [this approach](https://raspberrypi.stackexchange.com/questions/85958/easy-backups-and-snapshots-of-a-running-system-with-lvm),
hoever, I like the initial approach more. This script will write the OS to a
device after setting up LVM but before booting it so it is just quicker than
writing the OS and then moving it to an LVM managed partition.
To write the latest version of Raspberry Pi OS (64bit Lite) to an NVME SSD
device simply run:
~~~
sudo rpi-lvm-imager.sh --lvm-group nvme /dev/nvme0n1
~~~
Please note that this will unmound and wipe the specified device so be careful!
to see all aailable options, run: `./rpi-lvm-imager.sh -h`
<a name="license">License</a>
-----------------------------
These scripts, documentation & configration examples are free software: you can
@@ -107,4 +140,4 @@ warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License along with
this program. If not, download it from <http://www.gnu.org/licenses/>.
this program. If not, download it from <http://www.gnu.org/licenses/>.