Skip to contentSkip to conversation

Debian: Wait for udev devices to settle in erase-other-disks

PATCH In review Ian Campbell 2 participants 4 messages Sep 23, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Debian: Wait for udev devices to settle in erase-other-disks

Otherwise we, apparently, have a race between the "test -b" + dd against the sda1 device node being removed and end up creating a file called /dev/sda1 containing 32K of zeroes, which will later render mke2fs very confused.

For some reason we seem to reliably loose the race on Jessie i386 host installs, but not on Wheezy or other arches on Jessie.

This was tricky to diagnose because the Debian installer main-menu process appears to buffer the output of things it runs before logging them to /var/log/syslog, which means the output of "set -x" and the actual affect of the commands (e.g. in the kernel messages) can be presented in very confusing orders. Hence this patch also adds extensive use of logger(1) to record what it is actually doing at the time it does it. These logs include the pid of the command too since main-menu only logs its own pid, not that of the subcommand which gneerated the output.

Lastly this patch adds an explicit test that each device it touches is actually still a block device afterwards.

---
 Osstest/Debian.pm | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
Osstest/Debian.pm +14 -1
index fb2e56a..a421d74 100644
@@ -975,13 +975,26 @@ END
 #!/bin/sh
 set -ex
 stamp=/var/erase-other-disks.stamp
-if test -f \$stamp; then exit 0; fi
+if test -f \$stamp; then
+    logger -t osstest-erase-other-disks-\$\$ "Already ran, exiting"
+    exit 0
+fi
 >\$stamp
+logger -t osstest-erase-other-disks-\$\$ "Running..."
 zero () {
     if test -b \$dev; then
+        logger -t osstest-erase-other-disks-\$\$ "Erasing \$dev"
         dd if=/dev/zero of=\$dev count=64 ||:
+        if ! test -b \$dev; then
+            logger -t osstest-erase-other-disks-\$\$ "\$dev is no longer a block device!"
+            exit 1
+        fi
+    else
+        logger -t osstest-erase-other-disks-\$\$ "\$dev does not exist or is not a block device."
     fi
 }
+
+udevadm settle
 for sd in sd hd; do
     for b in a b c d e f; do
         dev=/dev/\${sd}\${b}
Signature · 1 line
2.5.1
Acked-by on v1 1/1
#1 lore raw

Ian Campbell writes ("[PATCH OSSTEST] Debian: Wait for udev devices to settle in erase-other-disks"):

Quoted 18 lines

Otherwise we, apparently, have a race between the "test -b" + dd against the sda1 device node being removed and end up creating a file called /dev/sda1 containing 32K of zeroes, which will later render mke2fs very confused.

For some reason we seem to reliably loose the race on Jessie i386 host installs, but not on Wheezy or other arches on Jessie.

This was tricky to diagnose because the Debian installer main-menu process appears to buffer the output of things it runs before logging them to /var/log/syslog, which means the output of "set -x" and the actual affect of the commands (e.g. in the kernel messages) can be presented in very confusing orders. Hence this patch also adds extensive use of logger(1) to record what it is actually doing at the time it does it. These logs include the pid of the command too since main-menu only logs its own pid, not that of the subcommand which gneerated the output.

Quoted 4 lines

Lastly this patch adds an explicit test that each device it touches is actually still a block device afterwards.

Although

Osstest/Debian.pm END · line 993

Quoted 5 lines
Osstest/Debian.pm +5 -0
+    logger -t osstest-erase-other-disks-\$\$ "Already ran, exiting"
+logger -t osstest-erase-other-disks-\$\$ "Running..."
+        logger -t osstest-erase-other-disks-\$\$ "Erasing \$dev"
+            logger -t osstest-erase-other-disks-\$\$ "\$dev is no longer a block device!"
+        logger -t osstest-erase-other-disks-\$\$ "\$dev does not exist or is not a block device."

maybe

logmsg () { logger -t osstest-erase-other-disks-\$\$ "\$@" }

?

Ian.

#2 lore raw
Quoted 37 lines · Ian Jackson

Ian Campbell writes ("[PATCH OSSTEST] Debian: Wait for udev devices to settle in erase-other-disks"):

Quoted 18 lines

Otherwise we, apparently, have a race between the "test -b" + dd against the sda1 device node being removed and end up creating a file called /dev/sda1 containing 32K of zeroes, which will later render mke2fs very confused.

For some reason we seem to reliably loose the race on Jessie i386 host installs, but not on Wheezy or other arches on Jessie.

This was tricky to diagnose because the Debian installer main-menu process appears to buffer the output of things it runs before logging them to /var/log/syslog, which means the output of "set -x" and the actual affect of the commands (e.g. in the kernel messages) can be presented in very confusing orders. Hence this patch also adds extensive use of logger(1) to record what it is actually doing at the time it does it. These logs include the pid of the command too since main-menu only logs its own pid, not that of the subcommand which gneerated the output.

Quoted 4 lines

Lastly this patch adds an explicit test that each device it touches is actually still a block device afterwards.

Although

Quoted 7 lines
Osstest/Debian.pm +4 -0
+    logger -t osstest-erase-other-disks-\$\$ "Already ran, exiting"
+logger -t osstest-erase-other-disks-\$\$ "Running..."
+        logger -t osstest-erase-other-disks-\$\$ "Erasing \$dev"
+            logger -t osstest-erase-other-disks-\$\$ "\$dev is no

longer a block device!"
+ logger -t osstest-erase-other-disks-\$\$ "\$dev does not exist
or is not a block device."

Quoted 5 lines

maybe

logmsg () { logger -t osstest-erase-other-disks-\$\$ "\$@" }

?

I wasn't confident in getting the shell-in-perl backticks correct, or rather I was too lazy to do the inevitable extra two rounds of testing it would have needed.

I can do that if you want though.

Ian.

#3 lore raw

Ian Campbell writes ("Re: [PATCH OSSTEST] Debian: Wait for udev devices to settle in erase-other-disks"):

Quoted 8 lines · Ian Jackson
Quoted 1 line

logmsg () { logger -t osstest-erase-other-disks-\$\$ "\$@" }

I wasn't confident in getting the shell-in-perl backticks correct, or rather I was too lazy to do the inevitable extra two rounds of testing it would have needed.

I can do that if you want though.

Let's leave it for another day.

Ian.