Hi, does anyone know if (and how) it’s possible to run garbage collection on a machine with a completely full drive, literally zero bytes free? It’s a VM that I have been using as a staging area to test deployments, and it ran out of space due to accumulating system generations.
Running `nix store gc -v` first failed with this:
❯ nix store gc -v
...
deleting '/nix/store/saqh1rgvycbwx0r2vsyx6c7v77y75fii-etc'
deleting '/nix/store/c22yfb292ahc9kvaf5qfim4s2wf04yla-etc-metadata.erofs'
error (ignored): aborting transaction: SQL logic error, cannot rollback - no transaction is active (in '/nix/var/nix/db/db.sqlite')
45 store paths deleted, 971.3 KiB freed
error: committing transaction: database or disk is full, database or disk is full (in '/nix/var/nix/db/db.sqlite')
Then, running it for a second time, it failed with the following:
❯ nix store gc -v
finding garbage collector roots...
deleting garbage...
0 store paths deleted, 0.0 KiB freed
error: executing SQLite statement 'delete from ValidPaths where path = '/nix/store/bmdyy5k44ccahxrirpl6fyhzc87x172n-etc';': database or disk is full, database or disk is full (in '/nix/var/nix/db/db.sqlite')
Subsequent failures simply core dump:
❯ nix store gc -v
Bus error (core dumped) nix store gc -v
Really everything core dumps:
❯ nix repl
Bus error (core dumped) nix repl
nix-collect-garbage also fails:
❯ nix-collect-garbage -d
removing old generations of profile /nix/var/nix/profiles/system
error (ignored): writing to file: No space left on device
Bus error (core dumped) nix-collect-garbage -d
For reference:
❯ df
Filesystem 1K-blocks Used Available Use% Mounted on
/dev/sda3 33027072 32391856 0 100% /
tmpfs 504836 9632 495204 2% /run
/dev/sda3 33027072 32391856 0 100% /nix
/dev/sda3 33027072 32391856 0 100% /var
/dev/loop0 48 48 0 100% /run/nixos-etc-metadata
overlay 33027072 32391856 0 100% /etc
devtmpfs 100968 0 100968 0% /dev
tmpfs 1009672 8 1009664 1% /dev/shm
tmpfs 1024 0 1024 0% /run/credentials/systemd-journald.service
tmpfs 1024 0 1024 0% /run/credentials/systemd-resolved.service
/dev/sda3 33027072 32391856 0 100% /srv
/dev/sda3 33027072 32391856 0 100% /var/swap
/dev/sda2 523248 55100 468148 11% /efi
tmpfs 1009672 1512 1008160 1% /run/wrappers
tmpfs 1024 0 1024 0% /run/credentials/systemd-networkd.service
tmpfs 201932 20 201912 1% /run/user/175
tmpfs 201932 20 201912 1% /run/user/0
Since it’s a test VM, I can wipe it and reinstall of course, but I really would like to know what one would do if this situation happened on a bare-metal machine. I’ve had this issue a few times now, and would really like to know: What is the intended way to run garbage collection on such machines, to escape this trap, if running garbage collection requires disk space in the first place?