prole/docs/MERLIN-MARIADB-EXTERNAL-TEMP.md

3.0 KiB
Raw Permalink Blame History

Merlin: temporary MariaDB storage on borrowed USB (/external)

This is a temporary, host-specific setup for merlin.knoe.org to move MariaDB storage off the current path and onto a borrowed USB disk.

What changed

  • Ansible now mounts the borrowed USB disk partition (/dev/sda1, exFAT) persistently at /external by filesystem UUID.
  • MariaDB data is migrated from /srv/mariadb/mariadb/ to /external/mariadb/.
  • After a successful copy, the original datadir is moved aside to /srv/mariadb/mariadb.pre-external (kept for rollback).
  • /srv/mariadb/mariadb is replaced with a bind mount of /external/mariadb (so MariaDB can keep using the same datadir path).
  • A marker file is written to avoid repeating the migration destructively: /external/mariadb/.knoe-mariadb-external-migrated.

Why this is temporary

  • The disk is borrowed and formatted as exFAT.
  • Running MariaDB on exFAT is not ideal (permissions/ownership/ACLs/xattrs are limited), but this is an accepted short-term tradeoff until a better USB device is installed.

In particular:

  • exFAT does not support POSIX ownership, so chown will fail.
  • The mount options should not force everything to mysql:mysql with a restrictive umask. For merlin, we mount as uid=0,gid=mysql with a permissive umask so the mysql group can still write.
  • Because /external may already be mounted when Ansible runs, tasks should avoid trying to enforce owner/group/mode on the mountpoint.

Verify the mount

On merlin:

lsblk -f
findmnt /external
mountpoint -q /external && echo "/external is mounted"

You should see /external mounted from UUID=... with FSTYPE=exfat.

Verify MariaDB is using /external/mariadb

  1. Confirm MariaDBs configured datadir path:
sudo mysql --protocol=socket --user=root \
  --execute="SHOW VARIABLES LIKE 'datadir';"

Expected: datadir is /srv/mariadb/mariadb/ (the traditional path).

  1. Confirm that path is backed by the external disk (bind mount):
findmnt -T /srv/mariadb/mariadb
mountpoint -q /srv/mariadb/mariadb && echo "/srv/mariadb/mariadb is a mountpoint"

Expected: /srv/mariadb/mariadb is a bind mount whose source is /external/mariadb.

Rollback (move back to /srv/mariadb/mariadb)

This rollback keeps the external disk untouched and restores the original datadir directory.

  1. Stop MariaDB:
sudo systemctl stop mariadb
  1. Unmount the bind mount:
sudo umount /srv/mariadb/mariadb
  1. Restore the original datadir directory:
sudo rm -rf /srv/mariadb/mariadb
sudo mv /srv/mariadb/mariadb.pre-external /srv/mariadb/mariadb
  1. Start MariaDB:
sudo systemctl start mariadb
  1. Remove/disable the Ansible external-storage configuration:
  • In infrastructure/inventory/host_vars/merlin.knoe.org.yml, set mariadb_external_enabled: false (or remove the mariadb_external_* vars).
  • Re-run the MariaDB provisioning playbook so it removes the persistent mount entries it previously created.