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

Bug#307471: initrd-tools: wish init would not run mount_root if rootdev=255 (ie nfs root).



Package: initrd-tools
Version: 0.1.78
Severity: wishlist
Tags: patch

Debian now has NSFroot network booting with initrd support thanks to the 
combination of initrd-tools and initrd-netboot-tools.

However this combination seems to work more by luck than design!
When booting a Linux kernel for NFSroot one needs to rdev the kernel 
with device code major=0 minor=255 or pass the command line argument 
root=/dev/nfs. The upshot of either of these is that the kernel 
real-root-dev (/proc/sys/kernel/real-root-dev) ends up being "255".

initrd-tools:/sbin/init script calls the scipts in the initrd:/scripts/ 
directory inturn... this is where initrd-netboot-tools places scripts to 
mount the NFSroot on /mnt. After that initrd-tools:/sbin/init  contains 
the stanza:
if [ $rootdev != 256 ]; then
        mount_root
        cd mnt
        [ $DEVFS ] && mount -nt devfs devfs dev
        pivot_root . initrd
fi

This stanza is run for the NFSroot case as rootdev=255.
By calling the mount_root function the get_device and mount_device 
functions are in turn called. The mount device function than tries to 
mount the block device major=0 minor=255 as if it were a normal block 
device. This fails as one would expect and so initrd-tools:/sbin/init 
continues on to run pivot_root and continue booting the NFSroot system.

What is the problem you may say... well I think that rather than 
assuming that the mount of block device major=0 minor=255 will fail in a 
way that is safe we should trap the rootdev=255 earlier and not allow 
the mount command to be attempted. The following patch to 
initrd-tools:/sbin/init performs this trap.

---8<---
--- init.orig	2005-05-03 11:13:32.000000000 +0100
+++ init	2005-05-03 11:14:19.000000000 +0100
@@ -418,7 +418,9 @@
 cmdline=$(cat /proc/cmdline)
 umount -n proc
 if [ $rootdev != 256 ]; then
+    if [ $rootdev != 255 ]; then
 	mount_root
+    fi
 	cd mnt
 	[ $DEVFS ] && mount -nt devfs devfs dev
 	pivot_root . initrd
---8<---

Regards
Alex Owen

-- System Information:
Debian Release: 3.1
  APT prefers testing
  APT policy: (400, 'testing'), (300, 'unstable')
Architecture: i386 (i686)
Kernel: Linux 2.4.27-1-686
Locale: LANG=en_GB, LC_CTYPE=en_GB (charmap=ISO-8859-1)

Versions of packages initrd-tools depends on:
ii  coreutils [fileutils]         5.2.1-2    The GNU core utilities
ii  cpio                          2.5-1.2    GNU cpio -- a program to manage ar
ii  cramfsprogs                   1.1-6      Tools for CramFs (Compressed ROM F
ii  dash                          0.5.2-4    The Debian Almquist Shell
ii  util-linux                    2.12-10    Miscellaneous system utilities

-- no debconf information



Reply to: