summaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2022-03-28 15:10:56 +0200
committerLennart Poettering <lennart@poettering.net>2022-04-04 17:19:51 +0200
commitae61c53c3b1e8c36662c623309bb8e0c249e4593 (patch)
treea050a3bdc997b3faeec14559b9dd53616b484501 /docs
parentudevadm: add new "lock" verb for locking block devices (diff)
downloadsystemd-ae61c53c3b1e8c36662c623309bb8e0c249e4593.tar.xz
systemd-ae61c53c3b1e8c36662c623309bb8e0c249e4593.zip
man: document new udevadm lock tool
Diffstat (limited to 'docs')
-rw-r--r--docs/BLOCK_DEVICE_LOCKING.md19
1 files changed, 19 insertions, 0 deletions
diff --git a/docs/BLOCK_DEVICE_LOCKING.md b/docs/BLOCK_DEVICE_LOCKING.md
index 13ae3f6e04..40fc61c671 100644
--- a/docs/BLOCK_DEVICE_LOCKING.md
+++ b/docs/BLOCK_DEVICE_LOCKING.md
@@ -75,6 +75,25 @@ And please keep in mind: BSD file locks (`flock()`) and POSIX file locks
orthogonal. The scheme discussed above uses the former and not the latter,
because these types of locks more closely match the required semantics.
+If multiple devices are to be locked at the same time (for example in order to
+format a RAID file system), the devices should be locked in the order of the
+the device nodes' major numbers (primary ordering key, ascending) and minor
+numbers (secondary ordering key, ditto), in order to avoid ABBA locking issues
+between subsystems.
+
+Note that the locks should only be taken while the device is repartitioned,
+file systems formatted or `dd`'ed in, and similar cases that
+apply/remove/change superblocks/partition information. It should not be held
+during normal operation, i.e. while file systems on it are mounted for
+application use.
+
+The [`udevadm
+lock`](https://www.freedesktop.org/software/systemd/man/udevadm.html) command
+is provided to lock block devices following this scheme from the command line,
+for the use in scripts and similar. (Note though that it's typically preferable
+to use native support for block device locking in tools where that's
+available.)
+
Summarizing: it is recommended to take `LOCK_EX` BSD file locks when
manipulating block devices in all tools that change file system block devices
(`mkfs`, `fsck`, …) or partition tables (`fdisk`, `parted`, …), right after