There are quite a few things in Linux which can keep a ZFS pool busy, blocking export and destroy commands. As root check these (assuming POOLNAME=<yourpool>
):
- Filesystem references like open files, current directories etc.:
# lsof 2>/dev/null | grep $POOLNAME
- Mounted pool filesystems and zvols:
# mount | grep $POOLNAME
- Active swap devices (any /dev/zd...?):
# swapon -s
- Device-mapper devices referencing
/dev/zvol/<poolname>/.../<volume>
block devices. These might have been set up by LVM although it shouldn't pick up /dev/zd.*
which is usually excluded in /etc/lvm/lvm.conf
- global_filter=...
.
# dmsetup deps
Remove these references by stopping or killing the processes by their PID, umount
zvols, swapoff
the zvols or swapfiles, vgexport
the involved pvs and dmsetup remove
the dm devices.
At least for (3.) you need the /dev/zd...
device paths belonging to your zpool, so build a regex for grep:
POOLDEVS=$(
find "/dev/zvol/$POOLNAME" -type l -print0 |
xargs -0 realpath -zP | paste -szd '|'
echo $POOLNAME
)
$POOLDEVS
is a regex like /dev/zd6016|/dev/zd4720p2|...
, so try:
(mount; swapon; pvs) | grep -E "$POOLDEVS"
For (4.) find device-mapper/LVM references to $POOLNAME
's zvol block devices.
Hexadecimal major/minor block device numbers from stat
must to be converted to (major, minor)
decimal numbers as output by dmsetup
:
dmsetup deps | grep -Ff <(
cd /dev/zvol/$POOLNAME &&
find . -type l -printf "%l\0" |
xargs -0 stat -c 'printf "(%%d, %%d)\n" 0x%t 0x%T' |
sh
)
Output like:
yoda-swap: 1 dependencies : (230, 1409)
yoda-root: 1 dependencies : (230, 1409)
Release them with e. g. dmsetup remove yoda-swap yoda-root
which succeeds if they are inactive.
umount --lazy
or--force
? – Philemol