From 36387e28eb6cf1f1b2542ff5bbc4d185995c8076 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 12:05:21 +0000 Subject: initrdscripts: Introduce boot order support for universal initramfs modules. --- packages/initrdscripts/files/80-loopboot.sh | 54 ++++++++++++++++++++++ packages/initrdscripts/files/80-nfsboot.sh | 43 +++++++++++++++++ packages/initrdscripts/files/85-blockboot.sh | 8 ++++ packages/initrdscripts/files/blockboot.sh | 8 ---- packages/initrdscripts/files/loopboot.sh | 54 ---------------------- packages/initrdscripts/files/nfsboot.sh | 43 ----------------- .../initrdscripts/initramfs-module-block_0.1.bb | 4 +- .../initrdscripts/initramfs-module-loop_0.1.bb | 4 +- packages/initrdscripts/initramfs-module-nfs_0.1.bb | 4 +- 9 files changed, 111 insertions(+), 111 deletions(-) create mode 100644 packages/initrdscripts/files/80-loopboot.sh create mode 100644 packages/initrdscripts/files/80-nfsboot.sh create mode 100644 packages/initrdscripts/files/85-blockboot.sh delete mode 100644 packages/initrdscripts/files/blockboot.sh delete mode 100644 packages/initrdscripts/files/loopboot.sh delete mode 100644 packages/initrdscripts/files/nfsboot.sh (limited to 'packages/initrdscripts') diff --git a/packages/initrdscripts/files/80-loopboot.sh b/packages/initrdscripts/files/80-loopboot.sh new file mode 100644 index 0000000000..55a1948db8 --- /dev/null +++ b/packages/initrdscripts/files/80-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 diff --git a/packages/initrdscripts/files/80-nfsboot.sh b/packages/initrdscripts/files/80-nfsboot.sh new file mode 100644 index 0000000000..5129a53ebb --- /dev/null +++ b/packages/initrdscripts/files/80-nfsboot.sh @@ -0,0 +1,43 @@ +#!/bin/sh + +if [ "$ROOT_DEVICE" = "/dev/nfs" ]; then + + # These correspond to what kernel itself uses + # DO NOT CHANGE! + NFS_OPTIONS="-o nfsvers=2,nolock" + + for arg in $CMDLINE; do + echo $arg + optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` + echo $optarg + case $arg in + nfsroot=*) + nfsroot=$optarg ;; + ip=*) + ip=$optarg ;; + esac + done + + echo $ip | (IFS=: read client_ip server_ip gw_ip netmask hostname device autoconf; \ + echo client_ip=$client_ip; + echo server_ip=$server_ip; + echo gw_ip=$gw_ip; + echo netmask=$netmask; + echo hostname=$hostname; + echo device=$device; + echo autoconf=$autoconf; + + case "$device" in + usb*) + echo "USB" + modprobe g_ether + ;; + esac + + ifconfig $device $client_ip + ) + + echo "booting from NFS: $nfsroot" + mount -t nfs $NFS_OPTIONS $nfsroot /mnt + BOOT_ROOT=/mnt +fi diff --git a/packages/initrdscripts/files/85-blockboot.sh b/packages/initrdscripts/files/85-blockboot.sh new file mode 100644 index 0000000000..567f7e29b3 --- /dev/null +++ b/packages/initrdscripts/files/85-blockboot.sh @@ -0,0 +1,8 @@ +#!/bin/sh +# Allow booting from a normal block device. + +if [ -e "$ROOT_DEVICE" ]; then + echo "booting from: $ROOT_DEVICE" + mount "$ROOT_DEVICE" /mnt + BOOT_ROOT=/mnt +fi diff --git a/packages/initrdscripts/files/blockboot.sh b/packages/initrdscripts/files/blockboot.sh deleted file mode 100644 index 567f7e29b3..0000000000 --- a/packages/initrdscripts/files/blockboot.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/sh -# Allow booting from a normal block device. - -if [ -e "$ROOT_DEVICE" ]; then - echo "booting from: $ROOT_DEVICE" - mount "$ROOT_DEVICE" /mnt - BOOT_ROOT=/mnt -fi diff --git a/packages/initrdscripts/files/loopboot.sh b/packages/initrdscripts/files/loopboot.sh deleted file mode 100644 index 55a1948db8..0000000000 --- a/packages/initrdscripts/files/loopboot.sh +++ /dev/null @@ -1,54 +0,0 @@ -#!/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 diff --git a/packages/initrdscripts/files/nfsboot.sh b/packages/initrdscripts/files/nfsboot.sh deleted file mode 100644 index 5129a53ebb..0000000000 --- a/packages/initrdscripts/files/nfsboot.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/bin/sh - -if [ "$ROOT_DEVICE" = "/dev/nfs" ]; then - - # These correspond to what kernel itself uses - # DO NOT CHANGE! - NFS_OPTIONS="-o nfsvers=2,nolock" - - for arg in $CMDLINE; do - echo $arg - optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` - echo $optarg - case $arg in - nfsroot=*) - nfsroot=$optarg ;; - ip=*) - ip=$optarg ;; - esac - done - - echo $ip | (IFS=: read client_ip server_ip gw_ip netmask hostname device autoconf; \ - echo client_ip=$client_ip; - echo server_ip=$server_ip; - echo gw_ip=$gw_ip; - echo netmask=$netmask; - echo hostname=$hostname; - echo device=$device; - echo autoconf=$autoconf; - - case "$device" in - usb*) - echo "USB" - modprobe g_ether - ;; - esac - - ifconfig $device $client_ip - ) - - echo "booting from NFS: $nfsroot" - mount -t nfs $NFS_OPTIONS $nfsroot /mnt - BOOT_ROOT=/mnt -fi diff --git a/packages/initrdscripts/initramfs-module-block_0.1.bb b/packages/initrdscripts/initramfs-module-block_0.1.bb index a0cb2fd7fa..2c7079af61 100644 --- a/packages/initrdscripts/initramfs-module-block_0.1.bb +++ b/packages/initrdscripts/initramfs-module-block_0.1.bb @@ -1,11 +1,11 @@ SRC_URI = "file://blockboot.sh" -PR = "r2" +PR = "r3" RDEPENDS = "initramfs-uniboot" DESCRIPTION = "An initramfs module for booting off normal block devices." do_install() { install -d ${D}/initrd.d - install -m 0755 ${WORKDIR}/blockboot.sh ${D}/initrd.d/block + install -m 0755 ${WORKDIR}/85-blockboot.sh ${D}/initrd.d/ } FILES_${PN} += " /initrd.d/block " diff --git a/packages/initrdscripts/initramfs-module-loop_0.1.bb b/packages/initrdscripts/initramfs-module-loop_0.1.bb index d4e5aa038f..afc77a46f0 100644 --- a/packages/initrdscripts/initramfs-module-loop_0.1.bb +++ b/packages/initrdscripts/initramfs-module-loop_0.1.bb @@ -1,5 +1,5 @@ SRC_URI = "file://loopboot.sh" -PR = "r3" +PR = "r4" DESCRIPTION = "An initramfs module for booting a filesystem image by loopback \ mounting it." RDEPENDS = "initramfs-uniboot" @@ -7,7 +7,7 @@ RRECOMMENDS = "kernel-module-loop kernel-module-vfat" do_install() { install -d ${D}/initrd.d - install -m 0755 ${WORKDIR}/loopboot.sh ${D}/initrd.d/loop + install -m 0755 ${WORKDIR}/80-loopboot.sh ${D}/initrd.d/ } FILES_${PN} += " /initrd.d/loop " diff --git a/packages/initrdscripts/initramfs-module-nfs_0.1.bb b/packages/initrdscripts/initramfs-module-nfs_0.1.bb index 24284d6c5f..beadcf1c35 100644 --- a/packages/initrdscripts/initramfs-module-nfs_0.1.bb +++ b/packages/initrdscripts/initramfs-module-nfs_0.1.bb @@ -1,12 +1,12 @@ SRC_URI = "file://nfsboot.sh" -PR = "r4" +PR = "r5" DESCRIPTION = "An initramfs module for booting via NFS." RDEPENDS = "initramfs-uniboot" RRECOMMENDS = "kernel-module-g-ether kernel-module-nfs" do_install() { install -d ${D}/initrd.d - install -m 0755 ${WORKDIR}/nfsboot.sh ${D}/initrd.d/nfs + install -m 0755 ${WORKDIR}/80-nfsboot.sh ${D}/initrd.d/ } FILES_${PN} += " /initrd.d/nfs " -- cgit v1.2.3 From 505b03b2909a607e2dd8693ef95e0d62d6f3212b Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 12:07:37 +0000 Subject: initrdscripts: Initial value for ROOT_DEV is null. --- packages/initrdscripts/files/init.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'packages/initrdscripts') diff --git a/packages/initrdscripts/files/init.sh b/packages/initrdscripts/files/init.sh index 8c9803f21b..261a3b8477 100644 --- a/packages/initrdscripts/files/init.sh +++ b/packages/initrdscripts/files/init.sh @@ -2,7 +2,7 @@ MODULE_DIR=/initrd.d BOOT_ROOT= -ROOT_DEVICE=/dev/null +ROOT_DEVICE= early_setup() { mkdir /proc -- cgit v1.2.3 From d0e74671ac72a53a9864e35e16c2d27ed91874bf Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 12:16:41 +0000 Subject: initrdscripts: Separate fs kernel module loading to separate plugin. --- packages/initrdscripts/files/10-initfs.sh | 5 +++++ packages/initrdscripts/files/80-loopboot.sh | 1 - packages/initrdscripts/initramfs-module-initfs_1.0.bb | 12 ++++++++++++ 3 files changed, 17 insertions(+), 1 deletion(-) create mode 100644 packages/initrdscripts/files/10-initfs.sh create mode 100644 packages/initrdscripts/initramfs-module-initfs_1.0.bb (limited to 'packages/initrdscripts') diff --git a/packages/initrdscripts/files/10-initfs.sh b/packages/initrdscripts/files/10-initfs.sh new file mode 100644 index 0000000000..b336af6bbb --- /dev/null +++ b/packages/initrdscripts/files/10-initfs.sh @@ -0,0 +1,5 @@ +#!/bin/sh + +modprobe vfat +modprobe ext2 +modprobe ext3 diff --git a/packages/initrdscripts/files/80-loopboot.sh b/packages/initrdscripts/files/80-loopboot.sh index 55a1948db8..7fbf69a202 100644 --- a/packages/initrdscripts/files/80-loopboot.sh +++ b/packages/initrdscripts/files/80-loopboot.sh @@ -35,7 +35,6 @@ if [ "$ROOT_DEVICE" = "/dev/loop" ]; then loop_num=`expr "$loop_num" + 1` } - modprobe vfat modprobe loop loop_num=0 diff --git a/packages/initrdscripts/initramfs-module-initfs_1.0.bb b/packages/initrdscripts/initramfs-module-initfs_1.0.bb new file mode 100644 index 0000000000..f085dcd0bc --- /dev/null +++ b/packages/initrdscripts/initramfs-module-initfs_1.0.bb @@ -0,0 +1,12 @@ +SRC_URI = "file://10-initfs.sh" +PR = "r0" +DESCRIPTION = "An initramfs module for initializing filesystems." +RDEPENDS = "initramfs-uniboot" +RRECOMMENDS = "kernel-module-vfat kernel-module-ext2" + +do_install() { + install -d ${D}/initrd.d + install -m 0755 ${WORKDIR}/10-initfs.sh ${D}/initrd.d/ +} + +FILES_${PN} += " /initrd.d/* " -- cgit v1.2.3 From 17901ed364f1d8953445b5181d14977be561cad7 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 12:20:26 +0000 Subject: initrdscripts: Finish renaming for ordered module load. --- packages/initrdscripts/initramfs-module-block_0.1.bb | 11 ----------- packages/initrdscripts/initramfs-module-block_1.0.bb | 11 +++++++++++ packages/initrdscripts/initramfs-module-loop_0.1.bb | 13 ------------- packages/initrdscripts/initramfs-module-loop_1.0.bb | 13 +++++++++++++ packages/initrdscripts/initramfs-module-nfs_0.1.bb | 12 ------------ packages/initrdscripts/initramfs-module-nfs_1.0.bb | 12 ++++++++++++ 6 files changed, 36 insertions(+), 36 deletions(-) delete mode 100644 packages/initrdscripts/initramfs-module-block_0.1.bb create mode 100644 packages/initrdscripts/initramfs-module-block_1.0.bb delete mode 100644 packages/initrdscripts/initramfs-module-loop_0.1.bb create mode 100644 packages/initrdscripts/initramfs-module-loop_1.0.bb delete mode 100644 packages/initrdscripts/initramfs-module-nfs_0.1.bb create mode 100644 packages/initrdscripts/initramfs-module-nfs_1.0.bb (limited to 'packages/initrdscripts') diff --git a/packages/initrdscripts/initramfs-module-block_0.1.bb b/packages/initrdscripts/initramfs-module-block_0.1.bb deleted file mode 100644 index 2c7079af61..0000000000 --- a/packages/initrdscripts/initramfs-module-block_0.1.bb +++ /dev/null @@ -1,11 +0,0 @@ -SRC_URI = "file://blockboot.sh" -PR = "r3" -RDEPENDS = "initramfs-uniboot" -DESCRIPTION = "An initramfs module for booting off normal block devices." - -do_install() { - install -d ${D}/initrd.d - install -m 0755 ${WORKDIR}/85-blockboot.sh ${D}/initrd.d/ -} - -FILES_${PN} += " /initrd.d/block " diff --git a/packages/initrdscripts/initramfs-module-block_1.0.bb b/packages/initrdscripts/initramfs-module-block_1.0.bb new file mode 100644 index 0000000000..73f7a709f1 --- /dev/null +++ b/packages/initrdscripts/initramfs-module-block_1.0.bb @@ -0,0 +1,11 @@ +SRC_URI = "file://85-blockboot.sh" +PR = "r0" +RDEPENDS = "initramfs-uniboot" +DESCRIPTION = "An initramfs module for booting off normal block devices." + +do_install() { + install -d ${D}/initrd.d + install -m 0755 ${WORKDIR}/85-blockboot.sh ${D}/initrd.d/ +} + +FILES_${PN} += " /initrd.d/* " diff --git a/packages/initrdscripts/initramfs-module-loop_0.1.bb b/packages/initrdscripts/initramfs-module-loop_0.1.bb deleted file mode 100644 index afc77a46f0..0000000000 --- a/packages/initrdscripts/initramfs-module-loop_0.1.bb +++ /dev/null @@ -1,13 +0,0 @@ -SRC_URI = "file://loopboot.sh" -PR = "r4" -DESCRIPTION = "An initramfs module for booting a filesystem image by loopback \ - mounting it." -RDEPENDS = "initramfs-uniboot" -RRECOMMENDS = "kernel-module-loop kernel-module-vfat" - -do_install() { - install -d ${D}/initrd.d - install -m 0755 ${WORKDIR}/80-loopboot.sh ${D}/initrd.d/ -} - -FILES_${PN} += " /initrd.d/loop " diff --git a/packages/initrdscripts/initramfs-module-loop_1.0.bb b/packages/initrdscripts/initramfs-module-loop_1.0.bb new file mode 100644 index 0000000000..54e7fa29e3 --- /dev/null +++ b/packages/initrdscripts/initramfs-module-loop_1.0.bb @@ -0,0 +1,13 @@ +SRC_URI = "file://80-loopboot.sh" +PR = "r0" +DESCRIPTION = "An initramfs module for booting a filesystem image by loopback \ + mounting it." +RDEPENDS = "initramfs-uniboot" +RRECOMMENDS = "kernel-module-loop kernel-module-vfat" + +do_install() { + install -d ${D}/initrd.d + install -m 0755 ${WORKDIR}/80-loopboot.sh ${D}/initrd.d/ +} + +FILES_${PN} += " /initrd.d/* " diff --git a/packages/initrdscripts/initramfs-module-nfs_0.1.bb b/packages/initrdscripts/initramfs-module-nfs_0.1.bb deleted file mode 100644 index beadcf1c35..0000000000 --- a/packages/initrdscripts/initramfs-module-nfs_0.1.bb +++ /dev/null @@ -1,12 +0,0 @@ -SRC_URI = "file://nfsboot.sh" -PR = "r5" -DESCRIPTION = "An initramfs module for booting via NFS." -RDEPENDS = "initramfs-uniboot" -RRECOMMENDS = "kernel-module-g-ether kernel-module-nfs" - -do_install() { - install -d ${D}/initrd.d - install -m 0755 ${WORKDIR}/80-nfsboot.sh ${D}/initrd.d/ -} - -FILES_${PN} += " /initrd.d/nfs " diff --git a/packages/initrdscripts/initramfs-module-nfs_1.0.bb b/packages/initrdscripts/initramfs-module-nfs_1.0.bb new file mode 100644 index 0000000000..6555688fce --- /dev/null +++ b/packages/initrdscripts/initramfs-module-nfs_1.0.bb @@ -0,0 +1,12 @@ +SRC_URI = "file://80-nfsboot.sh" +PR = "r0" +DESCRIPTION = "An initramfs module for booting via NFS." +RDEPENDS = "initramfs-uniboot" +RRECOMMENDS = "kernel-module-g-ether kernel-module-nfs" + +do_install() { + install -d ${D}/initrd.d + install -m 0755 ${WORKDIR}/80-nfsboot.sh ${D}/initrd.d/ +} + +FILES_${PN} += " /initrd.d/nfs " -- cgit v1.2.3 From e0f4607a9d92714d1173ecfcc89cbd6af3343692 Mon Sep 17 00:00:00 2001 From: Paul Sokolovsky Date: Thu, 22 Nov 2007 15:08:12 +0000 Subject: initrdscripts: We obviously first do rootdelay, and only then create device nodes. --- packages/initrdscripts/files/init.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'packages/initrdscripts') diff --git a/packages/initrdscripts/files/init.sh b/packages/initrdscripts/files/init.sh index 261a3b8477..f8d5de9173 100644 --- a/packages/initrdscripts/files/init.sh +++ b/packages/initrdscripts/files/init.sh @@ -8,8 +8,11 @@ early_setup() { mkdir /proc mount -t proc proc /proc mkdir /mnt +} - echo -n "creating device nodes: " +dev_setup() +{ + echo -n "initramfs: Creating device nodes: " grep '^ *[0-9]' /proc/partitions | while read major minor blocks dev do if [ ! -e /dev/$dev ]; then @@ -35,6 +38,7 @@ read_args() { load_modules() { for module in $MODULE_DIR/*; do + echo "initramfs: Loading $module module" source $module done } @@ -60,6 +64,8 @@ if [ -n "$rootdelay" ]; then sleep $rootdelay fi +dev_setup + load_modules [ -n "$BOOT_ROOT" ] && boot_root boot_failed -- cgit v1.2.3