diff options
author | Paul Sokolovsky <pmiscml@gmail.com> | 2007-07-19 21:31:06 +0000 |
---|---|---|
committer | Paul Sokolovsky <pmiscml@gmail.com> | 2007-07-19 21:31:06 +0000 |
commit | 09eda2eff81a1cbd452f2ef3e24374de9dfc6788 (patch) | |
tree | ac0e5b54ce7d5d00a88441696a3ea44a29d46983 | |
parent | d4a1e67b767c0ee4431bb3ffae60a27ba8fb6afd (diff) | |
parent | 3eb5fc2457d618e5cac52dd4d3d4ceb36f1c9f40 (diff) |
merge of '35d78dbf37aba06eaf047d4d83daf9d28ba25728'
and '6632df74a3ff0af8c91330d38e0d6018c8794762'
-rw-r--r-- | packages/images/initramfs-image.bb | 8 | ||||
-rw-r--r-- | packages/images/initramfs-minimal-image.bb | 15 | ||||
-rw-r--r-- | packages/initrdscripts/files/init.sh | 65 | ||||
-rw-r--r-- | packages/initrdscripts/files/loopboot.sh | 54 | ||||
-rw-r--r-- | packages/initrdscripts/files/nfsboot.sh | 79 | ||||
-rw-r--r-- | packages/initrdscripts/initramfs-jffs2/.mtn2git_empty | 0 | ||||
-rw-r--r-- | packages/initrdscripts/initramfs-jffs2/jffs2boot.sh | 18 | ||||
-rw-r--r-- | packages/initrdscripts/initramfs-jffs2_0.1.bb | 8 | ||||
-rw-r--r-- | packages/initrdscripts/initramfs-module-loop_0.1.bb | 8 | ||||
-rw-r--r-- | packages/initrdscripts/initramfs-module-nfs_0.1.bb | 8 | ||||
-rw-r--r-- | packages/initrdscripts/initramfs-nfsboot_0.2.bb | 8 | ||||
-rw-r--r-- | packages/initrdscripts/initramfs_0.1.bb | 8 |
12 files changed, 226 insertions, 53 deletions
diff --git a/packages/images/initramfs-image.bb b/packages/images/initramfs-image.bb index 1b60405e74..7728fd80ae 100644 --- a/packages/images/initramfs-image.bb +++ b/packages/images/initramfs-image.bb @@ -1,9 +1,13 @@ # Sample initramfs image LICENSE = "MIT" -PR = "r0" +PR = "r1" #RDEPENDS = "initramfs-boot busybox kernel-module-uinput uclibc libgcc1" -RDEPENDS = "initramfs-nfsboot busybox-static kernel-module-uinput" +RDEPENDS = "initramfs initramfs-module-nfs initramfs-module-loop \ + busybox-static" + +RRECOMENDS = "kernel-module-uinput kernel-module-fat \ + kernel-module-vfat kernel-module-loop" export IMAGE_BASENAME = "initramfs-image" export IMAGE_LINGUAS = "" diff --git a/packages/images/initramfs-minimal-image.bb b/packages/images/initramfs-minimal-image.bb new file mode 100644 index 0000000000..1b60405e74 --- /dev/null +++ b/packages/images/initramfs-minimal-image.bb @@ -0,0 +1,15 @@ +# Sample initramfs image +LICENSE = "MIT" +PR = "r0" + +#RDEPENDS = "initramfs-boot busybox kernel-module-uinput uclibc libgcc1" +RDEPENDS = "initramfs-nfsboot busybox-static kernel-module-uinput" + +export IMAGE_BASENAME = "initramfs-image" +export IMAGE_LINGUAS = "" + +PACKAGE_INSTALL = "${RDEPENDS}" +# Install only ${PACKAGE_INSTALL}, not even deps +PACKAGE_INSTALL_NO_DEPS = "1" + +inherit image diff --git a/packages/initrdscripts/files/init.sh b/packages/initrdscripts/files/init.sh new file mode 100644 index 0000000000..8c9803f21b --- /dev/null +++ b/packages/initrdscripts/files/init.sh @@ -0,0 +1,65 @@ +#!/bin/sh + +MODULE_DIR=/initrd.d +BOOT_ROOT= +ROOT_DEVICE=/dev/null + +early_setup() { + mkdir /proc + mount -t proc proc /proc + mkdir /mnt + + echo -n "creating device nodes: " + grep '^ *[0-9]' /proc/partitions | while read major minor blocks dev + do + if [ ! -e /dev/$dev ]; then + echo -n "$dev " + [ -e /dev/$dev ] || mknod /dev/$dev b $major $minor + fi + done + echo +} + +read_args() { + CMDLINE=`cat /proc/cmdline` + for arg in $CMDLINE; do + optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` + case $arg in + root=*) + ROOT_DEVICE=$optarg ;; + rootdelay=*) + rootdelay=$optarg ;; + esac + done +} + +load_modules() { + for module in $MODULE_DIR/*; do + source $module + done +} + +boot_root() { + cd $BOOT_ROOT + exec switch_root -c /dev/console $BOOT_ROOT /sbin/init +} + +boot_failed() { + echo "No valid root device was specified. Please add root=/dev/something to" + echo "the kernel command-line and try again." + echo + exec sh +} + +echo "Starting initramfs boot..." +early_setup +read_args + +if [ -n "$rootdelay" ]; then + echo "Waiting $rootdelay seconds for devices to settle..." + sleep $rootdelay +fi + +load_modules +[ -n "$BOOT_ROOT" ] && boot_root +boot_failed 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 diff --git a/packages/initrdscripts/files/nfsboot.sh b/packages/initrdscripts/files/nfsboot.sh index b536c4042b..5129a53ebb 100644 --- a/packages/initrdscripts/files/nfsboot.sh +++ b/packages/initrdscripts/files/nfsboot.sh @@ -1,50 +1,43 @@ #!/bin/sh -echo "Starting initramfs boot..." -mkdir /proc -mount -t proc proc /proc +if [ "$ROOT_DEVICE" = "/dev/nfs" ]; then -for arg in `cat /proc/cmdline`; do - echo $arg - optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` - echo $optarg - case $arg in - root=*) - root=$optarg ;; - 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 "x$device" in - usb*) - echo "USB" - modprobe g_ether - ;; -esac + # These correspond to what kernel itself uses + # DO NOT CHANGE! + NFS_OPTIONS="-o nfsvers=2,nolock" -ifconfig $device $client_ip -) + 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 + ) -mkdir /mnt -if [ "x$root" = "x/dev/nfs" ]; then echo "booting from NFS: $nfsroot" - mount -t nfs $nfsroot /mnt -else - echo "booting from: $root" - mount $root /mnt + mount -t nfs $NFS_OPTIONS $nfsroot /mnt + BOOT_ROOT=/mnt fi - -cd /mnt -exec switch_root -c /dev/console /mnt /sbin/init diff --git a/packages/initrdscripts/initramfs-jffs2/.mtn2git_empty b/packages/initrdscripts/initramfs-jffs2/.mtn2git_empty new file mode 100644 index 0000000000..e69de29bb2 --- /dev/null +++ b/packages/initrdscripts/initramfs-jffs2/.mtn2git_empty diff --git a/packages/initrdscripts/initramfs-jffs2/jffs2boot.sh b/packages/initrdscripts/initramfs-jffs2/jffs2boot.sh new file mode 100644 index 0000000000..81077eeae5 --- /dev/null +++ b/packages/initrdscripts/initramfs-jffs2/jffs2boot.sh @@ -0,0 +1,18 @@ +#!/bin/sh + +echo "Starting initrd boot..." +mkdir /proc +mount -t proc proc /proc + +modprobe mtdram total_size=24576 erase_size=256 +sleep 1 + +ID=`grep "mtdram test device" /proc/mtd | cut -d: -f1| cut -b4-` + +cat /initrd.jffs2 >/dev/mtdblock$ID + +mkdir /mnt +mount -t jffs2 /dev/mtdblock$ID /mnt + +cd /mnt +exec switch_root -c /dev/console /mnt /sbin/init diff --git a/packages/initrdscripts/initramfs-jffs2_0.1.bb b/packages/initrdscripts/initramfs-jffs2_0.1.bb new file mode 100644 index 0000000000..78034c99c9 --- /dev/null +++ b/packages/initrdscripts/initramfs-jffs2_0.1.bb @@ -0,0 +1,8 @@ +SRC_URI = "file://jffs2boot.sh" +PR = "r0" + +do_install() { + install -m 0755 ${WORKDIR}/jffs2boot.sh ${D}/init +} + +FILES_${PN} += " /init " diff --git a/packages/initrdscripts/initramfs-module-loop_0.1.bb b/packages/initrdscripts/initramfs-module-loop_0.1.bb new file mode 100644 index 0000000000..ce8f368c5a --- /dev/null +++ b/packages/initrdscripts/initramfs-module-loop_0.1.bb @@ -0,0 +1,8 @@ +SRC_URI = "file://loopboot.sh" +PR = "r0" + +do_install() { + install -m 0755 ${WORKDIR}/loopboot.sh ${D}/initrd.d/loop +} + +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 new file mode 100644 index 0000000000..9f4436a26b --- /dev/null +++ b/packages/initrdscripts/initramfs-module-nfs_0.1.bb @@ -0,0 +1,8 @@ +SRC_URI = "file://nfsboot.sh" +PR = "r1" + +do_install() { + install -m 0755 ${WORKDIR}/nfsboot.sh ${D}/initrd.d/nfs +} + +FILES_${PN} += " /initrd.d/nfs " diff --git a/packages/initrdscripts/initramfs-nfsboot_0.2.bb b/packages/initrdscripts/initramfs-nfsboot_0.2.bb deleted file mode 100644 index 1a4d48813b..0000000000 --- a/packages/initrdscripts/initramfs-nfsboot_0.2.bb +++ /dev/null @@ -1,8 +0,0 @@ -SRC_URI = "file://nfsboot.sh" -PR = "r0" - -do_install() { - install -m 0755 ${WORKDIR}/nfsboot.sh ${D}/init -} - -FILES_${PN} += " /init " diff --git a/packages/initrdscripts/initramfs_0.1.bb b/packages/initrdscripts/initramfs_0.1.bb new file mode 100644 index 0000000000..c7e44eae22 --- /dev/null +++ b/packages/initrdscripts/initramfs_0.1.bb @@ -0,0 +1,8 @@ +SRC_URI = "file://init.sh" +PR = "r0" + +do_install() { + install -m 0755 ${WORKDIR}/init.sh ${D}/init +} + +FILES_${PN} += " /init " |