docs(block): refuse the sw-block removal while a bind mount sits below it

-xdev and --one-file-system compare device numbers, so a bind mount from the
same filesystem looks like a plain directory to them and the removal deletes
its source's contents. Both removal commands now list mounts below the
sw-block directories and remove nothing while one remains.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Chris LuandClaude Opus 5.5 committed 2026-12-05 17:00:11 -08:00
1 parent c24e8b23ae
commit 20d2c3ebf5
1 file changed
+9 -4
+9 -4
View File
@@ -953,12 +953,16 @@ two hosts, follow the host-by-host order there. Where SeaweedFS was already runn
3. **Remove sw-block.** The removal runs only after the same check succeeds in the same command. A failed query
removes nothing. If section 1 put blockmaster's state on its own filesystem, empty and unmount it first, then
delete its persistent mount configuration (its `/etc/fstab` line): `rm -rf` cannot remove a mount point, so
the removal below would stop there. Unmount any other filesystem mounted below these directories first:
`-xdev` and `--one-file-system` make the removal stop at such a mount instead of deleting its contents.
the removal below would stop there. Unmount anything else mounted below these directories first, bind mounts
included. `-xdev` and `--one-file-system` stop only at another filesystem: a bind mount from the same
filesystem looks like a plain directory to them, and its source's contents would be deleted. Both commands
below print any such mount and remove nothing while one remains; `findmnt` lists the mounts.
```sh
units=$(systemctl list-units 'sw-blockvolume*' 'sw-blockmaster*' --state=active,activating,deactivating --no-legend) &&
test -z "$units" && mountpoint -q /var/lib/sw-block-master &&
test -z "$units" && mounts=$(findmnt -rno TARGET) &&
! printf '%s\n' "$mounts" | grep -E '^/(var/lib/sw-block-(volume|master)|etc/sw-block)/' &&
mountpoint -q /var/lib/sw-block-master &&
sudo find /var/lib/sw-block-master -xdev -mindepth 1 -delete && sudo umount /var/lib/sw-block-master
```
@@ -966,7 +970,8 @@ two hosts, follow the host-by-host order there. Where SeaweedFS was already runn
```sh
units=$(systemctl list-units 'sw-blockvolume*' 'sw-blockmaster*' --state=active,activating,deactivating --no-legend) &&
test -z "$units" &&
test -z "$units" && mounts=$(findmnt -rno TARGET) &&
! printf '%s\n' "$mounts" | grep -E '^/(var/lib/sw-block-(volume|master)|etc/sw-block)/' &&
sudo rm -rf --one-file-system /var/lib/sw-block-volume /var/lib/sw-block-master /etc/sw-block &&
sudo rm -f /etc/systemd/system/sw-blockmaster.service /etc/systemd/system/sw-blockvolume.service \
/etc/systemd/system/sw-blockvolume@.service /etc/systemd/system/sw-blockvolume-ublk.service \