summaryrefslogtreecommitdiffstats
path: root/meta
diff options
context:
space:
mode:
authorChen Qi <Qi.Chen@windriver.com>2013-06-28 15:48:53 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2013-06-28 11:02:40 +0100
commit29e55997caeb9c6367f9a340e153f829228f36ed (patch)
tree847c066dd513ad9b6bc6ded84754fb99501dffcb /meta
parent76ccbba7488cd0bca729568390b4e316a90b4c8e (diff)
downloadpoky-29e55997caeb9c6367f9a340e153f829228f36ed.tar.gz
init-live.sh: try to make a union mount when possible
This patch tries to make a union mount in live image. For example, if aufs is enabled with the aufs-enable.scc configuration fragment, the init-live.sh script will use aufs to make a union mount. Although overlayfs is not supported by Yocto kernel yet, this patch still takes it into consideration with the expect that the related code should at least serve as a placeholder. [YOCTO #1487] [YOCTO #4761] (From OE-Core rev: 3cd6fedd815688b2f3fd97a56feb5f8696ebeace) Signed-off-by: Chen Qi <Qi.Chen@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta')
-rw-r--r--meta/recipes-core/initrdscripts/files/init-live.sh63
1 files changed, 56 insertions, 7 deletions
diff --git a/meta/recipes-core/initrdscripts/files/init-live.sh b/meta/recipes-core/initrdscripts/files/init-live.sh
index ca4135141f..890c56280a 100644
--- a/meta/recipes-core/initrdscripts/files/init-live.sh
+++ b/meta/recipes-core/initrdscripts/files/init-live.sh
@@ -137,15 +137,64 @@ do
137 sleep 1 137 sleep 1
138done 138done
139 139
140# Try to make a union mount of the root image.
141# If no unification filesystem is available, mount the image read-only.
142mount_and_boot() {
143 mkdir $ROOT_MOUNT
144 mknod /dev/loop0 b 7 0 2>/dev/null
145
146 # determine which unification filesystem to use
147 union_fs_type=""
148 if grep -q -w "overlayfs" /proc/filesystems; then
149 union_fs_type="overlayfs"
150 elif grep -q -w "aufs" /proc/filesystems; then
151 union_fs_type="aufs"
152 else
153 union_fs_type=""
154 fi
155
156 # make a union mount if possible
157 case $union_fs_type in
158 "overlayfs")
159 mkdir -p /rootfs.ro /rootfs.rw
160 if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE /rootfs.ro; then
161 rm -rf /rootfs.ro /rootfs.rw
162 fatal "Could not mount rootfs image"
163 else
164 mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw
165 mount -t overlayfs -o "lowerdir=/rootfs.ro,upperdir=/rootfs.rw" overlayfs $ROOT_MOUNT
166 mkdir -p $ROOT_MOUNT/rootfs.ro $ROOT_MOUNT/rootfs.rw
167 mount --move /rootfs.ro $ROOT_MOUNT/rootfs.ro
168 mount --move /rootfs.rw $ROOT_MOUNT/rootfs.rw
169 fi
170 ;;
171 "aufs")
172 mkdir -p /rootfs.ro /rootfs.rw
173 if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE /rootfs.ro; then
174 rm -rf /rootfs.ro /rootfs.rw
175 fatal "Could not mount rootfs image"
176 else
177 mount -t tmpfs -o rw,noatime,mode=755 tmpfs /rootfs.rw
178 mount -t aufs -o "dirs=/rootfs.rw=rw:/rootfs.ro=ro" aufs $ROOT_MOUNT
179 mkdir -p $ROOT_MOUNT/rootfs.ro $ROOT_MOUNT/rootfs.rw
180 mount --move /rootfs.ro $ROOT_MOUNT/rootfs.ro
181 mount --move /rootfs.rw $ROOT_MOUNT/rootfs.rw
182 fi
183 ;;
184 "")
185 if ! mount -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
186 fatal "Could not mount rootfs image"
187 fi
188 ;;
189 esac
190
191 # boot the image
192 boot_live_root
193}
194
140case $label in 195case $label in
141 boot) 196 boot)
142 mkdir $ROOT_MOUNT 197 mount_and_boot
143 mknod /dev/loop0 b 7 0 2>/dev/null
144 if ! $MOUNT -o rw,loop,noatime,nodiratime /media/$i/$ISOLINUX/$ROOT_IMAGE $ROOT_MOUNT ; then
145 fatal "Could not mount rootfs image"
146 else
147 boot_live_root
148 fi
149 ;; 198 ;;
150 install|install-efi) 199 install|install-efi)
151 if [ -f /media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then 200 if [ -f /media/$i/$ISOLINUX/$ROOT_IMAGE ] ; then