summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDirk von Suchodoletz2009-08-15 17:55:04 +0200
committerDirk von Suchodoletz2009-08-15 17:55:04 +0200
commitc09bfd119f2ed3f1edf1bfbdf7a0beb1b2abea40 (patch)
treead40efbc1fcb79c76718d77773cb412e4a04b937
parentSome trivial stuff ... (diff)
downloadcore-c09bfd119f2ed3f1edf1bfbdf7a0beb1b2abea40.tar.gz
core-c09bfd119f2ed3f1edf1bfbdf7a0beb1b2abea40.tar.xz
core-c09bfd119f2ed3f1edf1bfbdf7a0beb1b2abea40.zip
Re-enabling the functionality to boot from a local block device (mainly
USB sticks). It allows for demonstration purposes and special setups to have the base filesystem locally (see related #156). git-svn-id: http://svn.openslx.org/svn/openslx/openslx/trunk@3092 95ad53e4-c205-0410-b2fa-d234c58c8868
-rwxr-xr-xinitramfs/stage3-stuff/bin/dhcpmkconfig3
-rwxr-xr-xinitramfs/stage3-stuff/bin/hwautocfg5
-rw-r--r--initramfs/stage3-stuff/etc/functions23
-rw-r--r--initramfs/stage3-stuff/etc/messages8
-rwxr-xr-xinitramfs/stage3-stuff/init30
5 files changed, 48 insertions, 21 deletions
diff --git a/initramfs/stage3-stuff/bin/dhcpmkconfig b/initramfs/stage3-stuff/bin/dhcpmkconfig
index 87e48683..c8c4d40c 100755
--- a/initramfs/stage3-stuff/bin/dhcpmkconfig
+++ b/initramfs/stage3-stuff/bin/dhcpmkconfig
@@ -23,6 +23,9 @@
echo -e "# network configuration written by $0:" >/tmp/confviadhcp
unset HOME IFS KCMDLINE DEBUGLEVEL MODPRV TERM BOOTIF BOOT_IMAGE \
infomsg mask lease interface cfgmsg cfgfile boot_file no_bootsplash
+# set the broadcast address if not delivered by dhcp
+[ -z "$broadcast" ] && \
+ broadcast=$(ipcalc -b $ip/$subnet|sed s/.*=//)
set | sed \
-e "s,^P.*,,;s,ntpsrv,ntp_servers,;s,ip,clientip," \
-e "s,serverid,serverip,;s,subnet,subnet_mask," \
diff --git a/initramfs/stage3-stuff/bin/hwautocfg b/initramfs/stage3-stuff/bin/hwautocfg
index 40b9e38c..d332e36b 100755
--- a/initramfs/stage3-stuff/bin/hwautocfg
+++ b/initramfs/stage3-stuff/bin/hwautocfg
@@ -39,6 +39,11 @@ ash /etc/modprobe.base; mdev -s
( usleep 100000 ; hwinfo --bios >/etc/hwinfo.bios ) &
# for mounting partitions/devices with the "auto" option
echo -e "ext3\next2\nreiserfs\nxfs\njfs\next4\nvfat" >/etc/filesystems
+# request a local block device for config and root filesystem (lbd://)
+if grep -iq '"lbd://' /proc/cmdline /etc/initramfs-setup; then
+ modprobe -a ${MODPRV} usb-storage sd_mod
+ mdev -s
+fi
return 0
}
diff --git a/initramfs/stage3-stuff/etc/functions b/initramfs/stage3-stuff/etc/functions
index 7731790c..51f5173b 100644
--- a/initramfs/stage3-stuff/etc/functions
+++ b/initramfs/stage3-stuff/etc/functions
@@ -369,8 +369,9 @@ local cfgfile
if [ "x$filepath" != "x" ] ; then
cfgfile=${filepath}
[ "x$fileserv" = "x" ] && fileserv=$(checkip ${serverip})
- # waiting for dns if fireserv is a name
- echo ${fileserv} | grep -qi [a-z] && waitfor /tmp/dhcp-done 10000
+ # wait for dns if "fileserv" is a name and not lbd device
+ [ "$fileprot" != "lbd" ] && \
+ echo ${fileserv} | grep -qi [a-z] && waitfor /tmp/dhcp-done 10000
[ $DEBUGLEVEL -ge 1 ] && echo "fileget - fileprot:$fileprot, filepath:\
$filepath, fileserv:$fileserv" >>$LOGFILE
case "$fileprot" in
@@ -378,15 +379,17 @@ $filepath, fileserv:$fileserv" >>$LOGFILE
wget_get $cfgfile $fileprot://$fileserv \
&& { unpack /tmp/$(basename $cfgfile) && break; } 2>>$LOGFILE
;;
- file)
+ lbd)
local ldev=$fileserv
- echo "Waiting for /mnt/etc ...."
- waitfor /mnt/etc 10000
- mkdir /tmp/$ldev
- echo -e "ext2\nreiserfs\nvfat\nxfs" >/etc/filesystems
- mount -o ro /dev/$ldev /tmp/$ldev || error "$init_errlfg"
- unpack /tmp/$ldev/$cfgfile
- umount /dev/$ldev
+ echo "Waiting for configuration file ${cfgfile} ...."
+ [ $DEBUGLEVEL -ge 1 ] && echo "fileget - fileprot:$fileprot, filepath:\
+$filepath, fileserv:$fileserv" >>$LOGFILE
+ waitfor /mnt/${cfgfile} 10000
+ if [ -f /mnt/${cfgfile} ]; then
+ unpack /mnt/$cfgfile
+ else
+ error "$init_errlfg"
+ fi
;;
*)
tftp_get $cfgfile $fileserv \
diff --git a/initramfs/stage3-stuff/etc/messages b/initramfs/stage3-stuff/etc/messages
index 918524b6..f6561f1f 100644
--- a/initramfs/stage3-stuff/etc/messages
+++ b/initramfs/stage3-stuff/etc/messages
@@ -78,10 +78,10 @@ init_cownobld=" Loading of cow module is of no sense if no network/other block
device is used or\n UnionFS/AUFS was specified as read write layer too. Remove \
UnionFS/AUFS token from\n kernel commandline if cowloop should be used instead."
init_nfs=" Mount of root filesystem via NFS was requested via kernel command \
-line\nbut failed. There might be the following reasons for that:\n\
-* No nfs.ko module could be loaded and no NFS support was present in the\n\
-running kernel - see error messages above\n\
-* You tried to mount from wrong server or path ($nfsroot)\n\
+line\n but failed. There might be the following reasons for that:\n \
+* No nfs.ko module could be loaded and no NFS support was present in the\n \
+running kernel - see error messages above\n \
+* You tried to mount from wrong server or path ($nfsroot)\n \
* No NFS server is running or you do not have permissions"
init_ldcfg=" Starting ldconfig - normally switched off. Enable it via kernel \
cmdline option\n 'noldsc'. You might have/want to add additional library \
diff --git a/initramfs/stage3-stuff/init b/initramfs/stage3-stuff/init
index 3284ede7..962c657b 100755
--- a/initramfs/stage3-stuff/init
+++ b/initramfs/stage3-stuff/init
@@ -10,7 +10,7 @@
#
# General information about OpenSLX can be found at http://openslx.org
#
-# Main script for initial ramdisk for OpenSLX linux stateless clients
+# Main script for initial ramfs for OpenSLX linux stateless clients
#############################################################################
# fixme: the primary init script should never fail, so move all critical code
@@ -273,10 +273,12 @@ line in $0\nnfsserver=\"${nfsserver}\"\nnfspath=\"${nfspath}\"" \
#iscsiport=$(uri_token $rootfs port)
#iscsitarget=$(uri_token $rootfs path)
;;
- lbdev)
+ lbd)
# use a local device for mounting root block device with given
- # filesystem, e.g. rootfs=lbdev://sda2/squashfs
- bldmod="sata_sil sd_mod"
+ # filesystem directly or a root filesystem container from another
+ # filesystem, e.g. rootfs=lbd://sda1/squashfs (bldmod cannot be
+ # empty, use loop or the real device stuff)
+ bldmod=loop
blddev=$(uri_token $rootfs server)
bldfst=$(uri_token $rootfs path)
bldfst=${bldfst#/*}
@@ -331,7 +333,7 @@ EOF
fi
# check if at least one type of IP configuration is availabe
-if [ -n "$nodhcp" -a -z "$ldap" -a -z "$ipinfo" -a $srvproto != "lbdev" ]
+if [ -n "$nodhcp" -a -z "$ldap" -a -z "$ipinfo" -a $srvproto != "lbd" ]
then echo -e "# You did not specify any advanced configuration mode for \
your clients. You\n# might want to add the token 'dhcp' for DHCP config, \
'file(=source)'\n# for config file get via TFTP or 'ldap(=source)' for LDAP \
@@ -462,7 +464,7 @@ if [ -z "$nodhcp" ] ; then
fi
# fixme: to be checked!!
# else
- # if [ -n "$file" -a "$srvproto" = "lbdev" ] ; then
+ # if [ -n "$file" -a "$srvproto" = "lbd" ] ; then
# error "$init_erripcfg" nonfatal
# else
# error "$init_erripcfg"
@@ -585,9 +587,15 @@ if [ -n "${bldmod}" ] ; then
echo noop > /sys/block/dnbd0/queue/scheduler
echo 0 > /sys/block/dnbd0/queue/read_ahead_kb
;;
- lbdev)
+ lbd)
# using clients local block device (disk partition is to be specified)
+ set -x
RDEV=/dev/$blddev
+ echo "$bldrfst" >>/etc/filesystems
+ realbldrfst=$bldrfst
+ # we might need to mount the base layer filesystem first before accessing
+ # e.g. a squashfs container file on it
+ bldrfst=auto
;;
esac
RWRO="ro"
@@ -623,6 +631,14 @@ if [ -n "${bldmod}" ] ; then
usleep $i
mount -n -t $bldrfst -o $RWRO $RDEV /mnt 2>/dev/null && break
done
+ # check if we got the rootfilesystem directly or need to mount a container
+ # file from the mounted block device
+ if [ "${srvproto}" = "lbd" -a -f /mnt/boot/${slxconf_system_name} ]; then
+ mkdir /dev/bootdisk
+ mount --move /mnt /dev/bootdisk
+ mount -t ${realbldrfst} -o loop \
+ /dev/bootdisk/boot/${slxconf_system_name} /mnt
+ fi
[ $DEBUGLEVEL -eq 20 ] && echo "** finished blockdev setup stuff at $(sysup)"
elif [ -n ${iscsiserver} ] ; then
[ $DEBUGLEVEL -eq 20 ] && echo "** started setting up iSCSI initiator at \