mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 10:13:58 +00:00
3.0 KiB
3.0 KiB
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/externalby 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/mariadbis replaced with a bind mount of/external/mariadb(so MariaDB can keep using the samedatadirpath).- 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
exFATis 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:
exFATdoes not support POSIX ownership, sochownwill fail.- The mount options should not force everything to
mysql:mysqlwith a restrictive umask. Formerlin, we mount asuid=0,gid=mysqlwith a permissive umask so themysqlgroup can still write. - Because
/externalmay already be mounted when Ansible runs, tasks should avoid trying to enforceowner/group/modeon 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
- Confirm MariaDB’s configured
datadirpath:
sudo mysql --protocol=socket --user=root \
--execute="SHOW VARIABLES LIKE 'datadir';"
Expected: datadir is /srv/mariadb/mariadb/ (the traditional path).
- 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.
- Stop MariaDB:
sudo systemctl stop mariadb
- Unmount the bind mount:
sudo umount /srv/mariadb/mariadb
- Restore the original datadir directory:
sudo rm -rf /srv/mariadb/mariadb
sudo mv /srv/mariadb/mariadb.pre-external /srv/mariadb/mariadb
- Start MariaDB:
sudo systemctl start mariadb
- Remove/disable the Ansible external-storage configuration:
- In
infrastructure/inventory/host_vars/merlin.knoe.org.yml, setmariadb_external_enabled: false(or remove themariadb_external_*vars). - Re-run the MariaDB provisioning playbook so it removes the persistent mount entries it previously created.