From 1a58233cc9e1fe6c63014888e196d16847baf98b Mon Sep 17 00:00:00 2001 From: Jonni Liljamo Date: Thu, 27 Nov 2025 20:13:19 +0200 Subject: [PATCH] feat: persistent disk --- README.md | 37 +++++++++++++++++++++++++++++++++++++ sqmeta/IMGBUILD | 6 ++++++ 2 files changed, 43 insertions(+) diff --git a/README.md b/README.md index b1348ad..1e9d116 100644 --- a/README.md +++ b/README.md @@ -10,3 +10,40 @@ These steps are done automatically during build steps. ## Modes Modes can be re-generated with `just make-modes` when adding new files, but be wary if existing entries change from previous values. + +## Persistent disk +Persistent disks should be added manually to virtual machines, partitioned +manually and then can be added to fstab creation in the IMGBUILD. This is so no +automatic process touches them. + +### Creating the disk +Attach a new disk to the virtual machine, it should show up as `/dev/vdb`. + +```sh +# Deps if not installed +apk add uuidgen findmnt + +# Partitioning +parted -s -- /dev/vdb mklabel msdos \ + mkpart primary 4096s -1s +partprobe /dev/vdb + +# Generate disk UUID, save this +uuidgen + +# Formatting +mkfs.ext4 -q -F -U SAVED_UUID /dev/vdb1 + +# Mount +mkdir /mnt/persistent +mount /dev/vdb1 /mnt/persistent + +# Save mount options +findmnt -no OPTIONS /dev/vdb1 +``` + +### Adding to fstab +Add to the end of the IMGBUILD setup function: +```sh +echo "UUID=REPLACE_WITH_UUID /mnt/persistent ext4 REPLACE_WITH_OPTIONS 0 2" >> "${imgroot}/etc/fstab" +``` diff --git a/sqmeta/IMGBUILD b/sqmeta/IMGBUILD index 0727a54..1c4365f 100644 --- a/sqmeta/IMGBUILD +++ b/sqmeta/IMGBUILD @@ -57,6 +57,9 @@ setup() { echo "UUID=$uuidr / ext4 $opts 0 1" > "${imgroot}/etc/fstab" opts=$(findmnt -no OPTIONS /dev/vda1) echo "UUID=$uuidb /boot ext2 $opts,noauto 0 2" >> "${imgroot}/etc/fstab" + + # Persistent partition, see README + echo "UUID=1ad73c24-2a0b-42a7-83e9-12e2dc3d2ef1 /mnt/persistent ext4 rw,relatime 0 2" >> "${imgroot}/etc/fstab" } cleanup() { @@ -80,6 +83,9 @@ provision() { ;; esac + # Create persistent mount directory + mkdir -p /mnt/persistent + ufw default deny incoming ufw limit SSH ufw enable -- 2.44.1