Various fixes to make things work; also listen to root=
Apparently what I had committed was broken. This fixes some pieces up and also adds (basic) support for using root=master
parent
65e66984d6
commit
35c5d61b82
19
generate.sh
19
generate.sh
|
@ -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
|
||||
|
|
43
init
43
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
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
#!/sbin/nash
|
||||
|
||||
switchroot
|
||||
nash-switchroot
|
||||
|
|
Loading…
Reference in New Issue