]> git.ipfire.org Git - thirdparty/dracut.git/commitdiff
Various fixes to make things work; also listen to root=
authorJeremy Katz <katzj@redhat.com>
Mon, 15 Dec 2008 18:33:54 +0000 (13:33 -0500)
committerJeremy Katz <katzj@redhat.com>
Mon, 15 Dec 2008 18:39:41 +0000 (13:39 -0500)
Apparently what I had committed was broken.  This fixes some pieces up
and also adds (basic) support for using root=

generate.sh
init
switch_root

index 1943169589b3e52ac3821407d680fabc01c83427..01ee5c9595f416d86585699bca32a4f03c24ef1c 100755 (executable)
@@ -15,18 +15,29 @@ fi
 tmpdir=$(mktemp -d)
 
 # executables that we have to have
-exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /bin/kill /sbin/pidof"
+exe="/bin/bash /bin/mount /bin/mknod /bin/mkdir /sbin/modprobe /sbin/udevd /sbin/udevadm /sbin/nash /bin/kill /sbin/pidof /bin/sleep"
 # and some things that are nice for debugging
 debugexe="/bin/ls /bin/cat /bin/ln /bin/ps /bin/grep /usr/bin/less"
+# udev things we care about
+udevexe="/lib/udev/vol_id"
 
 # install base files
-for binary in $exe $debugexe ; do
+for binary in $exe $debugexe $udevexe ; do
   inst $binary $tmpdir
 done
 
+# FIXME: would be nice if we didn't have to know which rules to grab....
+mkdir -p $tmpdir/lib/udev/rules.d
+for rule in /lib/udev/rules.d/40-redhat* /lib/udev/rules.d/60-persistent-storage.rules /lib/udev/rules.d/61*edd* /lib/udev/rules.d/64* /lib/udev/rules.d/80* /lib/udev/rules.d/95* rules.d/*.rules ; do
+  cp -v $rule $tmpdir/lib/udev/rules.d
+done
+
 # install our files
-inst init $tmpdir/init
-inst switch_root $tmpdir/sbin/switch_root
+cp -v init $tmpdir/init
+cp -v switch_root $tmpdir/sbin/switch_root
+
+# FIXME: and some directory structure
+mkdir -p $tmpdir/etc $tmpdir/proc $tmpdir/sys $tmpdir/sysroot
 
 # FIXME: we don't install modules right now, but for the testing we're doing
 # everything is already built-in
diff --git a/init b/init
index f6dcc37426426a20ed57d51c4bda1258c2b8d320..82273524134942f94d6c5d080b6fedb593329e7b 100755 (executable)
--- a/init
+++ b/init
@@ -22,9 +22,7 @@ export TERM=linux
 exec > /dev/console 2>&1
 
 # mount some important things
-mkdir /proc
 mount -t proc /proc /proc
-mkdir /sys
 mount -t sysfs /sys /sys
 mount -t tmpfs -omode=0755 udev /dev
 
@@ -33,17 +31,40 @@ mount -t tmpfs -omode=0755 udev /dev
 /sbin/udevadm trigger
 # FIXME: should we really wait for the queue to settle or just try to 
 # find the rootfs?
-/sbin/udevadm settle --timeout=30 || :
+#/sbin/udevadm settle --timeout=30 || :
 
-
-NEWROOT=/sysroot
 # mount the rootfs
-mkdir $NEWROOT
-# FIXME: obviously we need to parse this from /proc/cmdline
-mount -o ro -t ext3 /dev/sda1 $NEWROOT
+NEWROOT="/sysroot"
 
-# kill off udev
-kill `pidof udevd`
+# FIXME: there's got to be a better way ...
+# it'd be nice if we had a udev rule that just did all of the bits for
+# figuring out what the specified root is and linking it /dev/root
+for o in `cat /proc/cmdline` ; do
+  case $o in 
+  root=*)
+    root=${o#root=}
+    ;;
+  esac
+done
+echo -n "Going to mount rootfs ($root)"
+if [ -z "$root" ]; then 
+  echo "Warning: no root specified"
+  root="/dev/sda1"
+elif [ "${root#LABEL=}" != $root ]; then
+  root="/dev/disk/by-label/${root#LABEL=}"
+elif [ "${root#UUID=}" != $root ]; then
+  root="/dev/disk/by-uuid/${root#UUID=}"
+fi
+# should we have a timeout?
+tries=0
+while [ ! -e $root ]; do
+  echo -n "."
+  sleep 1
+  tries=$(($tries + 1))
+done
+echo -e "\n\nMounted rootfs after $tries seconds"
+ln -s "$root" /dev/root    
+mount -o ro -t ext3 /dev/root $NEWROOT
 
 # now we need to prepare to switchroot
 mount --bind /dev $NEWROOT/dev
@@ -56,6 +77,8 @@ mount -t sysfs /sys $NEWROOT/sys
 
 # FIXME: load selinux policy
 
+# kill off udev
+kill `pidof udevd`
 # FIXME: nash die die die
 exec /sbin/switch_root
 # davej doesn't like initrd bugs
index 6664ff5b8e60e3455bb42c8538d4e572b10fad45..2f0b8fa4f965901566f16a1547047873da4e6114 100755 (executable)
@@ -1,3 +1,3 @@
 #!/sbin/nash
 
-switchroot
+nash-switchroot