summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYang Shi <yang.shi@windriver.com>2012-04-11 01:33:43 (GMT)
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-04-11 11:15:32 (GMT)
commitb23b2b42a0c1ff6243227cb7d38c8cb6ae388bcf (patch)
tree72b522f9b00dd127dbc4263ba866e95a0ab20d02
parent88b399bb2c8adcf8563d144c0838cbcdd45c0694 (diff)
downloadpoky-b23b2b42a0c1ff6243227cb7d38c8cb6ae388bcf.tar.gz
initrdscripts: fix init-live.sh and use unionfs
[YOCTO #1487] When booting up with liveCD image, init scripts can't work well on read-only filesystem. Unionfs, which is supported in Yocto kernel, allows a filesystem to appear as writeable, but without actually allowing writes to change the filesystem. Use unionfs to mount rootfs and make root file system can be writen when using liveCD to boot up. Set UNION_FS variable depending on kernel config, so that it can work with kernel which doesn't have unionfs feature. [RP: Mark recipe as machine specific due to kernel dependency] (From OE-Core rev: b7f4e8d153c2aebbcf6556e7e926f6b94801d6aa) Signed-off-by: Yang Shi <yang.shi@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
-rw-r--r--meta/recipes-core/initrdscripts/files/init-live.sh23
-rw-r--r--meta/recipes-core/initrdscripts/initramfs-live-boot_1.0.bb14
2 files changed, 30 insertions, 7 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index eb5ab5b..737dae4 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -7,6 +7,7 @@ ROOT_IMAGE="rootfs.img"
7MOUNT="/bin/mount" 7MOUNT="/bin/mount"
8UMOUNT="/bin/umount" 8UMOUNT="/bin/umount"
9ISOLINUX="" 9ISOLINUX=""
10UNIONFS="no"
10 11
11early_setup() { 12early_setup() {
12 mkdir /proc 13 mkdir /proc
@@ -89,17 +90,31 @@ case $label in
89 mkdir $ROOT_MOUNT 90 mkdir $ROOT_MOUNT
90 mknod /dev/loop0 b 7 0 2>/dev/null 91 mknod /dev/loop0 b 7 0 2>/dev/null
91 92
92 if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then 93
93 fatal "Couldnt mount rootfs image" 94 if [ "$UNIONFS" = "yes" ]; then
95 mkdir /rootfs-tmp
96
97 if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE /rootfs-tmp ; then
98 fatal "Could not mount rootfs image"
99 else
100 mkdir /cow
101 mount -t tmpfs -o rw,noatime,mode=755 tmpfs /cow
102 mount -t unionfs -o dirs=/cow:/rootfs-tmp=ro unionfs $ROOT_MOUNT
103 boot_live_root
104 fi
94 else 105 else
95 boot_live_root 106 if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
107 fatal "Could not mount rootfs image"
108 else
109 boot_live_root
110 fi
96 fi 111 fi
97 ;; 112 ;;
98 install) 113 install)
99 if [ -f /media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then 114 if [ -f /media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then
100 ./install.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode 115 ./install.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode
101 else 116 else
102 fatal "Couldnt find install script" 117 fatal "Could not find install script"
103 fi 118 fi
104 119
105 # If we're getting here, we failed... 120 # If we're getting here, we failed...
diff --git a/meta/recipes-core/initrdscripts/initramfs-live-boot_1.0.bb b/meta/recipes-core/initrdscripts/initramfs-live-boot_1.0.bb
index e85a0e1..8f7511e 100644
--- a/meta/recipes-core/initrdscripts/initramfs-live-boot_1.0.bb
+++ b/meta/recipes-core/initrdscripts/initramfs-live-boot_1.0.bb
@@ -2,14 +2,22 @@ DESCRIPTION = "A live image init script"
2LICENSE = "MIT" 2LICENSE = "MIT"
3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420" 3LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
4RDEPENDS = "udev" 4RDEPENDS = "udev"
5DEPENDS = "virtual/kernel"
5SRC_URI = "file://init-live.sh" 6SRC_URI = "file://init-live.sh"
6 7
7PR = "r7" 8PR = "r9"
8 9
10do_compile() {
11 if grep -q "CONFIG_UNION_FS=y" ${STAGING_KERNEL_DIR}/.config; then
12 sed -i 's/UNIONFS="no"/UNIONFS="yes"/g' ${WORKDIR}/init-live.sh
13 fi
14}
15
9do_install() { 16do_install() {
10 install -m 0755 ${WORKDIR}/init-live.sh ${D}/init 17 install -m 0755 ${WORKDIR}/init-live.sh ${D}/init
11} 18}
12 19
13inherit allarch
14
15FILES_${PN} += " /init " 20FILES_${PN} += " /init "
21
22# Due to kernel depdendency
23PACKAGE_ARCH = "${MACHINE_ARCH}"