mirror of
https://github.com/dredx/prole.git
synced 2026-09-23 11:03:59 +00:00
89 lines
3.0 KiB
Markdown
89 lines
3.0 KiB
Markdown
# 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`:
|
||
|
||
```bash
|
||
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 MariaDB’s configured `datadir` path:
|
||
|
||
```bash
|
||
sudo mysql --protocol=socket --user=root \
|
||
--execute="SHOW VARIABLES LIKE 'datadir';"
|
||
```
|
||
|
||
Expected: `datadir` is `/srv/mariadb/mariadb/` (the traditional path).
|
||
|
||
2) Confirm that path is backed by the external disk (bind mount):
|
||
|
||
```bash
|
||
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:
|
||
|
||
```bash
|
||
sudo systemctl stop mariadb
|
||
```
|
||
|
||
2) Unmount the bind mount:
|
||
|
||
```bash
|
||
sudo umount /srv/mariadb/mariadb
|
||
```
|
||
|
||
3) Restore the original datadir directory:
|
||
|
||
```bash
|
||
sudo rm -rf /srv/mariadb/mariadb
|
||
sudo mv /srv/mariadb/mariadb.pre-external /srv/mariadb/mariadb
|
||
```
|
||
|
||
4) Start MariaDB:
|
||
|
||
```bash
|
||
sudo systemctl start mariadb
|
||
```
|
||
|
||
5) 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.
|