[pkg-cryptsetup-devel] [dm-crypt] u?mount (8) helper script for luks encrypted disks

Milan Broz gmazyland at gmail.com
Thu Aug 29 05:50:07 UTC 2013

On 26.8.2013 10:23, Matthias Schniedermeyer wrote:
> Personally i "solved" this by renaming /bin/mount to /bin/mount.orig
> and putting a shell-script as /bin/mount that checks if i want to mount
> a /dev/mapper/XXX and does the setup of XXX before it calls
> /bin/mount.orig.

Underlying device construction can be very complex task sometimes
(it can be combination of lvm, mdraid, multipath, partitions and whatever.)

So while it works for your use case, it will not work for other.

> "Back then" when i implemented that about 1.5 years ago i tried to
> explain to Karel Zak (util-linux maintainer) that a generic "premount"
> and "postumount" command in (u)mount could solve this generic problem.
> The Problem that all cryptographic-setups need (at least) one more step
> to setup(/tear-down) a device. But that didn't happen and i didn't try
> to open the issue again.

For that particular case, LUKS tear down, I think we had a better approach.
Just implement auto removal on last device close (similar to loop device
autoclear flag.)

For more info see


Be very careful with shell scripts in mount helpers here.
It will run under the same UID as mount, which means root for LUKS here.

More information about the pkg-cryptsetup-devel mailing list