diff options
Diffstat (limited to 'meta/packages/initrdscripts')
-rw-r--r-- | meta/packages/initrdscripts/files/init-live.sh | 70 | ||||
-rw-r--r-- | meta/packages/initrdscripts/initramfs-live-boot_1.0.bb | 12 |
2 files changed, 82 insertions, 0 deletions
diff --git a/meta/packages/initrdscripts/files/init-live.sh b/meta/packages/initrdscripts/files/init-live.sh new file mode 100644 index 0000000000..e081d44dd0 --- /dev/null +++ b/meta/packages/initrdscripts/files/init-live.sh | |||
@@ -0,0 +1,70 @@ | |||
1 | #!/bin/sh | ||
2 | |||
3 | ROOT_MOUNT="/rootfs/" | ||
4 | ROOT_IMAGE=rootfs.img | ||
5 | MOUNT="/bin/mount" | ||
6 | UMOUNT="/bin/umount" | ||
7 | |||
8 | early_setup() { | ||
9 | mkdir /proc | ||
10 | mount -t proc proc /proc | ||
11 | udevd --daemon | ||
12 | } | ||
13 | |||
14 | read_args() { | ||
15 | [ -z "$CMDLINE" ] && CMDLINE=`cat /proc/cmdline` | ||
16 | for arg in $CMDLINE; do | ||
17 | optarg=`expr "x$arg" : 'x[^=]*=\(.*\)'` | ||
18 | case $arg in | ||
19 | root=*) | ||
20 | ROOT_DEVICE=$optarg ;; | ||
21 | rootfstype=*) | ||
22 | ROOT_FSTYPE=$optarg ;; | ||
23 | rootdelay=*) | ||
24 | rootdelay=$optarg ;; | ||
25 | esac | ||
26 | done | ||
27 | } | ||
28 | |||
29 | boot_live_root() { | ||
30 | killall udevd | ||
31 | cd $ROOT_MOUNT | ||
32 | exec switch_root -c /dev/console $ROOT_MOUNT /sbin/init | ||
33 | } | ||
34 | |||
35 | fatal() { | ||
36 | echo $1 >$CONSOLE | ||
37 | echo >$CONSOLE | ||
38 | exec sh | ||
39 | } | ||
40 | |||
41 | echo "Starting initramfs boot..." | ||
42 | early_setup | ||
43 | |||
44 | [ -z "$CONSOLE" ] && CONSOLE="/dev/console" | ||
45 | |||
46 | read_args | ||
47 | |||
48 | echo "Waiting for Live image to show up..." | ||
49 | while true | ||
50 | do | ||
51 | for i in `ls /media 2>/dev/null`; do | ||
52 | if [ -f /media/$i/$ROOT_IMAGE ] ; then | ||
53 | found="yes" | ||
54 | fi | ||
55 | done | ||
56 | if [ "$found" = "yes" ]; then | ||
57 | break; | ||
58 | fi | ||
59 | sleep 1 | ||
60 | done | ||
61 | |||
62 | mkdir $ROOT_MOUNT | ||
63 | mknod /dev/loop0 b 7 0 | ||
64 | |||
65 | if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ROOT_IMAGE $ROOT_MOUNT | ||
66 | then | ||
67 | fatal "Couldnt mount rootfs image" | ||
68 | else | ||
69 | boot_live_root | ||
70 | fi | ||
diff --git a/meta/packages/initrdscripts/initramfs-live-boot_1.0.bb b/meta/packages/initrdscripts/initramfs-live-boot_1.0.bb new file mode 100644 index 0000000000..0ca962f03e --- /dev/null +++ b/meta/packages/initrdscripts/initramfs-live-boot_1.0.bb | |||
@@ -0,0 +1,12 @@ | |||
1 | DESCRIPTON = "A live image init script" | ||
2 | |||
3 | SRC_URI = "file://init-live.sh" | ||
4 | |||
5 | PR = "r0" | ||
6 | |||
7 | do_install() { | ||
8 | install -m 0755 ${WORKDIR}/init-live.sh ${D}/init | ||
9 | } | ||
10 | |||
11 | PACKAGE_ARCH = "all" | ||
12 | FILES_${PN} += " /init " | ||