Deleting ZFS datasets
After I moved from TrueNAS to Ubuntu on my NAS box, I had some issuing deleting some no-longer-needed directories.
One of the TrueNAS features I used was a jail, but those don't exist in Ubuntu (I moved anything that was in a jail to a Docker container).
Trying to delete the jails directory gave me some heartburn, which I was able to figure out, and delete.
Some basic info about the directory, run as the root user:
zfs list VD02/jails
NAME USED AVAIL REFER MOUNTPOINT
VD02/jails 326G 4.03T 163K /mnt/VD02/jails
zfs list -r VD02/jails
NAME USED AVAIL REFER MOUNTPOINT
VD02/jails 326G 4.03T 163K /mnt/VD02/jails
ls -l /mnt/VD02
total 2100
drwxrwxr-x 4183 tom tom 4186 Aug 6 10:07 calibreDB
drwxrwxr-x 5 1001 wheel 9 Dec 31 2020 tm_backups
drwxrwxr-x 15 tom tom 15 Sep 9 18:27 videos
drwxr-xr-x 5 1001 wheel 9 Jan 29 15:21 jails
I don't use/need the jails directory any more, so it should be as easy as rm -rf
the directory:
rm -rf /mnt/VD02/jails
rm: /mnt/VD02/vm: Device busy
Busy? Maybe someone/some application is still accessing the directory . . .
fuser -c /mnt/VD02/jails
plexmediaserver_1:
No one was accessing it, but maybe it was immutable?
lsattr -d /mnt/VD02/jails
-------------------- /mnt/VD02/jails
Nope . . . no one was accessing the directory, and it's not immutable, and I am root, so it isn't a permissions issue.
Did some research, and found out that because I'm using the ZFS filesystem to store my data, I need to run zfs destroy
to delete the directory, which was also a ZFS dataset:
zfs destroy VD02/jails
cannot destroy 'VD02/jails': filesystem has children
use '-r' to destroy the following datasets:
VD02/jails/plexmediaserver_1
VD02/jails/.warden-template-pluginjail-11.0-x64@clean
zfs destroy -r VD02/jails
Finally, the jails directory is gone:
ll /mnt/VD02/
total 2053
drwxr-xr-x 8 1001 tom uarch 8 Sep 11 10:39 ./
drwxr-xr-x 3 root wheel uarch 128 Sep 11 10:28 ../
drwxrwxr-x 4183 tom tom uarch 4186 Aug 6 10:07 calibreDB/
drwxrwxr-x 5 1001 wheel uarch 9 Dec 31 2020 tm_backups/
drwxrwxr-x 15 tom tom uarch 15 Sep 9 18:27 videos/
References
Oracle Solaris ZFS Administration Guide - Destroying a ZFS File System https://docs.oracle.com/cd/E19253-01/819-5461/gammq/index.html