DBIx-QuickDB

 view release on metacpan or  search on metacpan

AI_DOCS/SINGLE_FILE_DATADIR.md  view on Meta::CPAN

|--------------------------------|-------------|-----------------------|----------------|--------------------------------|
| ext4 image + `mount -o loop`   | yes         | **no** (root/fstab)   | optional       | classic; regular user blocked  |
| **SquashFS + `squashfuse`**    | yes         | **yes** (FUSE)        | yes (always)   | compressed; best fit           |
| `fuse2fs` on ext4 image        | yes         | yes (FUSE)            | optional       | rw possible but slow           |
| tarball                        | yes         | no (must extract)     | n/a            | not directly usable            |

## Can Regular Users Mount It?

- Plain `mount` of a disk image: **no** — needs root, or a pre-configured
  `/etc/fstab` entry with the `user` option.
- **FUSE: yes** — `squashfuse`, `fuse2fs`, `fuse-overlayfs` all run unprivileged
  (where FUSE is permitted, which is the Linux default).

## Recommended Stack (rootless, read-only base + ephemeral writes)

1. Build the data dir once (`initdb` / mysql install / load schema + seed data).
2. Pack into squashfs (the single file):
   ```
   mksquashfs datadir/ db.sqfs
   ```
3. At use time, fully rootless:
   ```
   squashfuse db.sqfs /mnt/lower
   fuse-overlayfs -o lowerdir=/mnt/lower,upperdir=/tmp/up,workdir=/tmp/work /mnt/merged
   postgres -D /mnt/merged          # or: mysqld --datadir=/mnt/merged
   ```
   Reads hit the immutable squashfs file. Writes (WAL, pid, locks) land in the
   tmpfs upper layer. Base file never changes — shareable across runs.

Alternative to `fuse-overlayfs`: user namespace + kernel overlayfs (rootless on
modern kernels):
```
unshare -Urm
mount -t overlay overlay -o lowerdir=/mnt/lower,upperdir=/tmp/up,workdir=/tmp/work /mnt/merged
```

## DB-Specific Shortcuts (skip the overlay)

### MySQL — has a real read-only mode
Run straight off the squashfuse mount, redirect writable bits elsewhere:
```
mysqld --datadir=/mnt/lower \
       --innodb-read-only=ON \
       --pid-file=/tmp/x.pid \
       --socket=/tmp/x.sock \
       --tmpdir=/tmp
```

### PostgreSQL — no clean read-only datadir
Use the overlay approach. Hacks via `hot_standby` / recovery mode exist but are
fragile. Overlay is simplest and robust.

## Fit for DBIx::QuickDB

Strong fit: pre-seed schema once → squashfs → spin throwaway test DBs fast via
overlay. Base file is immutable and shared across runs, so spin-up is copy-free
and fast. Candidate feature: a driver method that packs a built data dir into a
squashfs file and mounts it (squashfuse + fuse-overlayfs) on launch.



( run in 0.459 second using v1.01-cache-2.11-cpan-600a1bdf6e4 )