]> code.ossystems Code Review - openembedded-core.git/commitdiff
initrdscripts: fix init-live.sh and use unionfs
authorYang Shi <yang.shi@windriver.com>
Wed, 11 Apr 2012 01:33:43 +0000 (18:33 -0700)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Wed, 11 Apr 2012 11:15:16 +0000 (12:15 +0100)
[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]
Signed-off-by: Yang Shi <yang.shi@windriver.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/initrdscripts/files/init-live.sh
meta/recipes-core/initrdscripts/initramfs-live-boot_1.0.bb

index eb5ab5b7a52be87ddc1668ede51233a3b1f04dbc..737dae4cbcd54d522781e0d06e09a7b40744d89f 100644 (file)
@@ -7,6 +7,7 @@ ROOT_IMAGE="rootfs.img"
 MOUNT="/bin/mount"
 UMOUNT="/bin/umount"
 ISOLINUX=""
+UNIONFS="no"
 
 early_setup() {
     mkdir /proc
@@ -89,17 +90,31 @@ case $label in
        mkdir $ROOT_MOUNT
        mknod /dev/loop0 b 7 0 2>/dev/null
 
-       if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
-           fatal "Couldnt mount rootfs image"
+       
+       if [ "$UNIONFS" = "yes" ]; then
+           mkdir /rootfs-tmp
+
+           if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE /rootfs-tmp ; then
+               fatal "Could not mount rootfs image"
+           else
+               mkdir /cow
+               mount -t tmpfs -o rw,noatime,mode=755 tmpfs /cow
+               mount -t unionfs -o dirs=/cow:/rootfs-tmp=ro unionfs $ROOT_MOUNT
+               boot_live_root
+           fi
        else
-           boot_live_root
+           if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
+               fatal "Could not mount rootfs image"
+           else
+               boot_live_root
+           fi
        fi
        ;;
     install)
        if [ -f /media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then
            ./install.sh $i/$ISOLINUX $ROOT_IMAGE $video_mode $vga_mode
        else
-           fatal "Couldnt find install script"
+           fatal "Could not find install script"
        fi
 
        # If we're getting here, we failed...
index e85a0e11899ad6eca2c6d8ab036f67553aeaf75b..8f7511eadd4028592e646e55ae4df3dce32f0594 100644 (file)
@@ -2,14 +2,22 @@ DESCRIPTION = "A live image init script"
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 RDEPENDS = "udev"
+DEPENDS = "virtual/kernel"
 SRC_URI = "file://init-live.sh"
 
-PR = "r7"
+PR = "r9"
 
+do_compile() {
+       if grep -q "CONFIG_UNION_FS=y" ${STAGING_KERNEL_DIR}/.config; then
+               sed -i 's/UNIONFS="no"/UNIONFS="yes"/g' ${WORKDIR}/init-live.sh
+       fi
+}
 do_install() {
         install -m 0755 ${WORKDIR}/init-live.sh ${D}/init
 }
 
-inherit allarch
-
 FILES_${PN} += " /init "
+
+# Due to kernel depdendency
+PACKAGE_ARCH = "${MACHINE_ARCH}"