cryptsetup luksFormat fails with obscure error message when device is mounted
Bug #116633 reported by
Michael Vogt
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
cryptsetup (Ubuntu) |
Fix Released
|
Undecided
|
Reinhard Tartler |
Bug Description
Binary package hint: cryptsetup
When runing cryptsetup luksFormat on a mounted device (auto mounted by gnome without noticing it) it runs for a bit and then gives a obscure error message.
It should indicate that the device is mounted upfront and fail.
To post a comment you must log in.
Here is a small patch to add a check for this to luksformat:
diff -u cryptsetup- 1.0.4+svn29/ debian/ scripts/ luksformat cryptsetup- 1.0.4+svn29/ debian/ scripts/ luksformat 1.0.4+svn29/ debian/ scripts/ luksformat 1.0.4+svn29/ debian/ scripts/ luksformat
--- cryptsetup-
+++ cryptsetup-
@@ -29,6 +29,14 @@
$device = $ARGV[0];
+open(MOUNTS, "/proc/mounts");
+foreach $line (<MOUNTS>) {
+ if ($line =~ $device) {
+ print STDERR "Error: device mounted: $device\n";
+ exit 1;
+ }
+}
+
$mkfs = "/sbin/mkfs.$fs";
if (! -x $mkfs) {
print STDERR "Error: invalid file system: $fs\n";