[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#585133: devices created by MAKEDEV during installation are lost due improper setup of /target/dev/.static/dev



Package: base-installer
Version: 1.107
Severity: normal
Tags: patch

I have observed in lenny's debian-installer that devices created by
MAKEDEV (called in a postinst of some package) are lost. In most cases
this goes unnoticed because udev is used and devices are created
automatically. After checking the code I believe the latest version
to be affected as well so I'm filing this bug on it.

The reason is that the code in setup_dev_linux() in library.sh is not
doing what it's supposed to do. mount --bind does not transfer sub-mounts
and as such /target/dev/.static/dev is not the same as /dev/.static/dev
despite the bind mount of /dev on /target/dev. I first tried fixing this
with mount --rbind (instead of --bind) but it did not help. I found a
solution that achieves the same task in a more elegant way, see the
attached patch. I first duplicate /target/dev on /target/mnt with mount
--bind, then I replace /target/dev with /dev and finally I move the
bind-mount on /target/mnt to /target/dev/.static/dev.

This does not pollute /dev/.static/dev and still ensures what we want.

Please consider applying the attached patch.

BTW, it would be nice if the patch in #579645 could also be considered. It
will conflict with this patch but it's easy to update if you need.

-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'testing'), (500, 'stable'), (150, 'experimental')
Architecture: i386 (x86_64)

Kernel: Linux 2.6.32-5-amd64 (SMP w/2 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash
Index: library.sh
===================================================================
--- library.sh	(révision 63398)
+++ library.sh	(copie de travail)
@@ -107,15 +107,12 @@
 	fi
 
 	# Undo dev bind mounts for idempotency.
+	if grep -qE '^[^ ]+ /target/dev/.static/dev' /proc/mounts; then
+		umount /target/dev/.static/dev
+	fi
 	if grep -qE '^[^ ]+ /target/dev' /proc/mounts; then
 		umount /target/dev
 	fi
-	# Unmount /dev/.static/dev if mounted on same device as /target
-	mp_stdev=$(grep -E '^[^ ]+ /dev/\.static/dev' /proc/mounts | \
-		   cut -d" " -f1)
-	if [ "$mp_stdev" ] && grep -q "^$mp_stdev /target " /proc/mounts; then
-		umount /dev/.static/dev
-	fi
 }
 
 setup_dev_linux () {
@@ -123,9 +120,11 @@
 	# Tests in MAKEDEV require this is done in the D-I environment
 	mkdir -p /dev/.static/dev
 	chmod 700 /dev/.static/
-	mount --bind /target/dev /dev/.static/dev
-	# Mirror device nodes in D-I environment to target
+	# Mirror device nodes in D-I environment to target while still
+	# keeping original /target/dev as /target/dev/.static/dev
+	mount --bind /target/dev /target/mnt
 	mount --bind /dev /target/dev/
+	mount --move /target/mnt /target/dev/.static/dev
 }
 
 setup_dev_kfreebsd() {

Reply to: