summaryrefslogtreecommitdiff
path: root/packages/initrdscripts/files/loopboot.sh
diff options
context:
space:
mode:
authorAlex Osborne <ato@meshy.org>2007-07-19 20:55:15 +0000
committerPaul Sokolovsky <pmiscml@gmail.com>2007-07-19 20:55:15 +0000
commit2603e7f62a5a9e902a554855ed601d0619817b71 (patch)
tree3db9dd94483efff12cfd3f64cd9c571e8f260882 /packages/initrdscripts/files/loopboot.sh
parent86a52172905ecd9d850cf62f6042b820a3192230 (diff)
initramfs: New modular initramfs for booting kernel from various media.
* Design principles: * This initramfs just mounts roots and runs init on it, nothing else. * Whenever possible, existing kernel parameters are used. When extended boot methods are provided, new parameters mimick/adhere to existing conventions. * System is modular/pluggable - each mount method is in own module with more or less well defined interface, it's possible to construct complete system with any combination of modules. * Modules includes: initramfs-module-loop, initramfs-module-nfs, to boot from loop devices (including recursive loops) and NFS, correspondingly.
Diffstat (limited to 'packages/initrdscripts/files/loopboot.sh')
-rw-r--r--packages/initrdscripts/files/loopboot.sh54
1 files changed, 54 insertions, 0 deletions
diff --git a/packages/initrdscripts/files/loopboot.sh b/packages/initrdscripts/files/loopboot.sh
new file mode 100644
index 0000000000..55a1948db8
--- /dev/null
+++ b/packages/initrdscripts/files/loopboot.sh
@@ -0,0 +1,54 @@
+#!/bin/sh
+
+if [ "$ROOT_DEVICE" = "/dev/loop" ]; then
+ loop_mount() {
+ loopdev=/dev/loop$loop_num
+ mountpt=/mnt/loop$loop_num
+
+ [ -e $loopdev ] || mknod $loopdev b 7 $loop_num
+
+ # if only one argument was specified, let it be path not dev
+ if [ -z "$path" ] && [ -n "$dev" ]; then
+ path="$dev"
+ dev=""
+ fi
+ [ -z "$offset" ] && offset=0
+
+ if [ -n "$dev" ]; then
+ hostpt=`expr "$dev" : '.*/\([^/]*\)'`
+ [ -z "$hostpt" ] && hostpt="$dev"
+
+ echo "Mounting $dev on $hostpt"
+ mkdir $hostpt
+ mount $dev $hostpt
+ cd $hostpt
+ fi
+
+ echo "Loopback setup of $path (offset $offset)"
+ losetup -o "$offset" "$loopdev" "$path"
+
+ echo "Mounting $loopdev on $mountpt"
+ mkdir "$mountpt"
+ mount "$loopdev" "$mountpt"
+ cd "$mountpt"
+ BOOT_ROOT="$mountpt"
+ loop_num=`expr "$loop_num" + 1`
+ }
+
+ modprobe vfat
+ modprobe loop
+
+ loop_num=0
+
+ for arg in $CMDLINE; do
+ optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'`
+ echo $arg xxx $optarg
+ case $arg in
+ looproot=*)
+ dev=`expr "$optarg" : '\([^:]*\).*'`
+ path=`expr "$optarg" : '[^:]*:\([^:]*\).*'`
+ offset=`expr "$optarg" : '[^:]*:[^:]*:\([^:]*\).*'`
+ loop_mount ;;
+ esac
+ done
+fi