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

[RFC] No longer create full set of static devices during install



The attached set of patches allow us to no longer need/create the current 
huge set of static devices during installation. Instead /dev from the D-I 
environment is bind mounted to /target/dev after debootstrap has been run.

This also ensures that we will no longer "miss" any devices in /target/dev 
during installations. (We have had bug reports in the past where we were 
missing e.g. /dev/hdi.)

debootstrap is modified to include in the udeb only the minimal tarball of 
devices currently also included in the regular debootstrap binary package. 
We still need the udeb to be "arch any" because of the utility pkgdetails 
and because /usr/lib/debootstrap/arch needs to be included.

A minor change in rootskel creates the /dev/.static/dev directory because 
some packages may try to create static devices during installation. If any 
static devices are created, these are copied to /target/dev during 
finish-install (after unmounting the bind mount).
I've also removed the creation of /.dev in the D-I environment as that seems 
obsolete.

The create_devices function in base-installer has been simplified a lot 
because it no longer actually has to create any device nodes anymore.
It now takes care of the bind mount to /target/dev and does some apt-install 
calls for RAID, LVM and crypto installs.
(Suggestions for a better name for this function welcome!)

I've done successful LVM and LVM-crypto installs using the new udebs.

This proofed to be a lot simpler than I had expected, so the question is: 
what have I missed?

Are there still any arches that don't use udev for default installs?
If there are, they could be accommodated by calling MAKEDEV during 
base-installer (using the same set of devices that used to be created by 
debootstrap).

Cheers,
FJP

commit 9e8ac800922641fdedd3fb1edd5ca1cfb1f062a7
Author: Frans Pop <fjp@debian.org>
Date:   Fri Nov 9 22:45:12 2007 +0100

    Bind mount /dev to /target/dev instead of manually creating device nodes

diff --git a/packages/base-installer/debian/changelog b/packages/base-installer/debian/changelog
index 4de7cf4..a0d7506 100644
--- a/packages/base-installer/debian/changelog
+++ b/packages/base-installer/debian/changelog
@@ -1,3 +1,11 @@
+base-installer (1.85) UNRELEASED; urgency=low
+
+  * Bind mount /dev to /target/dev instead of creating device nodes for
+    devicemapper etc. During finish-install we copy any device nodes created
+    in /target/dev/.static/dev/ to /target/dev after unmounting it.
+
+ -- Frans Pop <fjp@debian.org>  Fri, 09 Nov 2007 22:39:40 +0100
+
 base-installer (1.84) unstable; urgency=low
 
   [ Frans Pop ]
diff --git a/packages/base-installer/finish-install b/packages/base-installer/finish-install
index e3b1ddc..8ff6bf4 100644
--- a/packages/base-installer/finish-install
+++ b/packages/base-installer/finish-install
@@ -4,3 +4,6 @@ set -e
 rm -f /target/etc/apt/apt.conf.d/00NoMountCDROM \
 	/target/etc/apt/apt.conf.d/00IgnoreTimeConflict \
 	/target/etc/apt/apt.conf.d/00AllowUnauthenticated
+
+umount /target/dev
+cp -a /dev/.static/dev/* /target/dev/ 2>/dev/null || true
diff --git a/packages/base-installer/library.sh b/packages/base-installer/library.sh
index bcb494a..090e089 100644
--- a/packages/base-installer/library.sh
+++ b/packages/base-installer/library.sh
@@ -95,6 +95,8 @@ check_target () {
 }
 
 create_devices () {
+	mount -o bind /dev /target/dev/
+
 	# RAID
 	if [ -e /proc/mdstat ] && grep -q ^md /proc/mdstat ; then
 		apt-install mdadm
@@ -104,35 +106,6 @@ create_devices () {
 		# Avoid warnings from lvm2 tools about open file descriptors
 		export LVM_SUPPRESS_FD_WARNINGS=1
 
-		mkdir -p /target/dev/mapper
-		if [ ! -e /target/dev/mapper/control ] ; then
-			major=$(grep "[0-9] misc$" /proc/devices | sed 's/[ ]\+misc//')
-			minor=$(grep "[0-9] device-mapper$" /proc/misc | sed 's/[ ]\+device-mapper//')
-			mknod /target/dev/mapper/control c $major $minor
-
-			# check if root is on a dm-crypt device
-			rootdev=$(mount | grep "on /target " | cut -d' ' -f1)
-			rootnode=${rootdev#/dev/mapper/}
-			if [ $rootdev != $rootnode ] && type dmsetup >/dev/null 2>&1 && \
-			   [ "$(dmsetup table $rootnode | cut -d' ' -f3)" = crypt ]; then
-				major="$(dmsetup -c --noheadings info $rootnode | cut -d':' -f2)"
-				minor="$(dmsetup -c --noheadings info $rootnode | cut -d':' -f3)"
-				mknod /target/dev/mapper/$rootnode b $major $minor
-			fi
-
-			# Create device nodes for Serial ATA RAID devices
-			if type dmraid >/dev/null 2>&1; then
-				for frdisk in $(dmraid -s -c | grep -v "No RAID disks"); do
-					for frdev in $(ls /dev/mapper/$frdisk* 2>/dev/null); do
-						frnode=$(basename $frdev)
-						major="$(dmsetup -c --noheadings info $frnode | cut -d':' -f2)"
-						minor="$(dmsetup -c --noheadings info $frnode | cut -d':' -f3)"
-						mknod /target/dev/mapper/$frnode b $major $minor
-					done
-				done
-			fi
-		fi
-
 		# We can't check the root node directly as is done above because
 		# root could be on an LVM LV on top of an encrypted device
 		if type dmsetup >/dev/null 2>&1 && \
@@ -148,13 +121,8 @@ create_devices () {
 
 		if pvdisplay | grep -iq "physical volume ---"; then
 			apt-install lvm2
-			in-target vgscan --mknodes || true
 		fi
 	fi
-	# UML: create ubd devices
-	if grep -q "model.*UML" /proc/cpuinfo; then
-		chroot /target /bin/sh -c '(cd /dev; ./MAKEDEV ubd)'
-	fi
 }
 
 configure_apt_preferences () {
commit d658279a65ff378ee8bab1b40a1f1e9a51236302
Author: Frans Pop <fjp@debian.org>
Date:   Fri Nov 9 21:43:30 2007 +0100

    No longer include full devices tarball in udeb

diff --git a/packages/debootstrap/Makefile b/packages/debootstrap/Makefile
index 82bfd23..69f790a 100644
--- a/packages/debootstrap/Makefile
+++ b/packages/debootstrap/Makefile
@@ -5,22 +5,12 @@ CFLAGS=-Wall -W -O2
 VERSION := $(shell sed 's/.*(\(.*\)).*/\1/; q' debian/changelog)
 
 ARCH := $(shell dpkg --print-architecture)
-setarchdevs = $(if $(findstring $(ARCH),$(1)),$(2))
-
-DEVS := generic hde hdf hdg hdh sde sdf sdg sdh scd-all initrd input usb md lp rtc video \
-        $(call setarchdevs,i386,isdn-io eda edb sonycd mcd mcdx cdu535 \
-                                optcd sjcd cm206cd gscd lmscd sbpcd \
-                                aztcd bpcd dac960 ida fd0 fd1 ataraid cciss) \
-        $(call setarchdevs,sparc,hdc hdd busmice) \
-        $(call setarchdevs,m68k,fd0 fd1 adc add ade adf hdc hdd) \
-        $(call setarchdevs,powerpc,hdc hdd fd0 fd1 isdn-io m68k-mice) \
-        $(call setarchdevs,ia64,ida fd0 fd1 ataraid cciss)
 
 MAKEDEV := $(shell if [ -e /dev/MAKEDEV ]; then echo /dev/MAKEDEV; else echo /sbin/MAKEDEV; fi)
 
-all: pkgdetails devices-std.tar.gz devices.tar.gz debootstrap-arch
+all: pkgdetails devices.tar.gz debootstrap-arch
 clean:
-	rm -f pkgdetails pkgdetails.o devices-std.tar.gz devices.tar.gz
+	rm -f pkgdetails pkgdetails.o devices.tar.gz
 	rm -f debootstrap-arch
 	rm -rf dev
 
@@ -44,13 +34,10 @@ install:
 	chown root:root $(DESTDIR)/usr/sbin/debootstrap
 	chmod 0755 $(DESTDIR)/usr/sbin/debootstrap
 
-install-allarch: install
-	install -o root -g root -m 0644 devices-std.tar.gz \
-		$(DSDIR)/devices.tar.gz
+	install -o root -g root -m 0644 devices.tar.gz $(DSDIR)/
 
-install-arch: install
+install-udeb: install
 	install -o root -g root -m 0755 pkgdetails $(DSDIR)/
-	install -o root -g root -m 0644 devices.tar.gz $(DSDIR)/
 	install -o root -g root -m 0644 debootstrap-arch $(DSDIR)/arch
 
 pkgdetails: pkgdetails.o
@@ -59,43 +46,11 @@ pkgdetails: pkgdetails.o
 debootstrap-arch:
 	echo $(ARCH) >debootstrap-arch
 
-devices-std.tar.gz:
-	rm -rf dev
-	mkdir -p dev
-	chown 0:0 dev
-	chmod 755 dev
-	(cd dev && $(MAKEDEV) std ptmx fd)
-	tar cf - dev | gzip -9 >devices-std.tar.gz
-	rm -rf dev
-
 devices.tar.gz:
 	rm -rf dev
-
 	mkdir -p dev
 	chown 0:0 dev
 	chmod 755 dev
-
-	(cd dev && $(MAKEDEV) $(DEVS))
-
-ifeq ($(ARCH),powerpc)
-#	Maybe remove amiga/atari mice also? What about usbmouse?
-	rm -f dev/adbmouse
-	ln -sf input/mice dev/mouse
-	ln -sf input/js0 dev/js0
-	ln -sf input/js1 dev/js1
-endif
-
-	@if ! find dev -maxdepth 0 -perm 755 -uid 0 -gid 0 | \
-	        grep -q "^dev$$"; \
-	then \
-	   echo "======================================================="; \
-	   echo "ERROR"; echo; \
-	   echo "./dev has bad permissions! should be 755 root.root. Was:"; \
-	   ls -ld ./dev; \
-	   echo "======================================================="; \
-	   false; \
-	fi
-
+	(cd dev && $(MAKEDEV) std ptmx fd)
 	tar cf - dev | gzip -9 >devices.tar.gz
 	rm -rf dev
-
diff --git a/packages/debootstrap/debian/changelog b/packages/debootstrap/debian/changelog
index 14c2ced..85d5d7d 100644
--- a/packages/debootstrap/debian/changelog
+++ b/packages/debootstrap/debian/changelog
@@ -1,3 +1,9 @@
+debootstrap (1.0.7) UNRELEASED; urgency=low
+
+  * No longer include full devices tarball in udeb.
+
+ -- Frans Pop <fjp@debian.org>  Fri, 09 Nov 2007 21:21:11 +0100
+
 debootstrap (1.0.6) unstable; urgency=low
 
   * Ensure that the target directory exists in check_sane_mount.
diff --git a/packages/debootstrap/debian/control b/packages/debootstrap/debian/control
index 8df876b..8622c1d 100644
--- a/packages/debootstrap/debian/control
+++ b/packages/debootstrap/debian/control
@@ -1,7 +1,7 @@
 Source: debootstrap
 Section: admin
 Maintainer: Debian Install System Team <debian-boot@lists.debian.org>
-Uploaders: Anthony Towns <ajt@debian.org>, Joey Hess <joeyh@debian.org>, Frans Pop <elendil@planet.nl>, Junichi Uekawa <dancer@debian.org>, Colin Watson <cjwatson@debian.org>
+Uploaders: Anthony Towns <ajt@debian.org>, Joey Hess <joeyh@debian.org>, Frans Pop <fjp@debian.org>, Junichi Uekawa <dancer@debian.org>, Colin Watson <cjwatson@debian.org>
 Build-Depends: debhelper (>= 4.2), makedev (>= 2.3.1-69)
 Standards-Version: 3.6.2
 Vcs-Svn: svn://svn.debian.org/d-i/trunk/packages/debootstrap
diff --git a/packages/debootstrap/debian/rules b/packages/debootstrap/debian/rules
index dcacfc2..99383a7 100755
--- a/packages/debootstrap/debian/rules
+++ b/packages/debootstrap/debian/rules
@@ -30,8 +30,8 @@ install: real-build
 	dh_installdirs
 
 #	 install the package into debian/debootstrap
-	$(MAKE) install-allarch DESTDIR=$(CURDIR)/debian/debootstrap
-	$(MAKE) install-arch    DESTDIR=$(CURDIR)/debian/debootstrap-udeb
+	$(MAKE) install      DESTDIR=$(CURDIR)/debian/debootstrap
+	$(MAKE) install-udeb DESTDIR=$(CURDIR)/debian/debootstrap-udeb
 
 binary-indep: install
 # We have nothing to do by default.
commit 97300d97ee7d829fbebb07479d7b06a1c35bde74
Author: Frans Pop <fjp@debian.org>
Date:   Fri Nov 9 23:35:17 2007 +0100

    Update S02udev-fixup

diff --git a/packages/rootskel/debian/changelog b/packages/rootskel/debian/changelog
index dbc6e15..4c50204 100644
--- a/packages/rootskel/debian/changelog
+++ b/packages/rootskel/debian/changelog
@@ -1,3 +1,11 @@
+rootskel (1.56) UNRELEASED; urgency=low
+
+  * S02udev-fixup: create /dev/.static/dev directory as that may be needed
+    after bind mounting /dev to /target/dev.
+  * S02udev-fixup: no longer create /.dev; it seems obsolete.
+
+ -- Frans Pop <fjp@debian.org>  Fri, 09 Nov 2007 23:32:38 +0100
+
 rootskel (1.55) unstable; urgency=low
 
   [ Jérémy Bobbio ]
diff --git a/packages/rootskel/src/lib/debian-installer-startup.d/S02udev-fixup b/packages/rootskel/src/lib/debian-installer-startup.d/S02udev-fixup
index df5675a..8922b75 100644
--- a/packages/rootskel/src/lib/debian-installer-startup.d/S02udev-fixup
+++ b/packages/rootskel/src/lib/debian-installer-startup.d/S02udev-fixup
@@ -1,7 +1,4 @@
 # This is S02udev-fixup because udev-udeb already installs S02udev.
 if type udevd >/dev/null 2>&1; then
-	# Needed to make some programs (e.g. mdrun) behave correctly
-	# As mdrun is no longer used, it is unsure if this is still needed
-	mkdir -p /.dev
-	mount -o bind /dev /.dev
+	mkdir -p /dev/.static/dev
 fi

Attachment: signature.asc
Description: This is a digitally signed message part.


Reply to: