DEVELOPMENT ENVIRONMENT

~liljamo/src.quest-anemos

1a58233cc9e1fe6c63014888e196d16847baf98b — Jonni Liljamo 7 days ago b563d99 master
feat: persistent disk
2 files changed, 43 insertions(+), 0 deletions(-)

M README.md
M sqmeta/IMGBUILD
M README.md => README.md +37 -0
@@ 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"
```

M sqmeta/IMGBUILD => sqmeta/IMGBUILD +6 -0
@@ 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