← Back to team overview

ubuntu-phone team mailing list archive

No loop mount option

 

Dear all,

I've raised a merge proposal below, to allow initramfs to mount system
partition direct as an ubuntu rootfs.
At the moment this is a fallback, as apart from the emulator, it's not
possible to have a large enough system partition to hold ubuntu
rootfs.

A matching patch for build/ android project is attached as a file.

The patch for the emulator package changes the behaviour slightly:
* sdcard.img is dropped
* ubuntu-system.img & ubuntu-userdata.img are generated
* if no options specified: ubuntu-system.img is embedded inside
ubuntu-userdata.img & normal (loop) based mount is performed

* if "-no-loop" is specified to the build script, ubuntu-system.img is
not embedded.

ubuntu-system.img is provisioned as the system.img (/dev/mtdblock0)
and ubuntu-userdata.img is provisioned as userdata.img
(/dev/mtdblock1).

Once booted without loop both / and /userdata are normal partitions
(this is in RW mode)
/dev/mtdblock1 on /userdata type ext4 (rw,relatime,data=ordered)
/dev/mtdblock0 on / type ext4 (rw,relatime,data=ordered)

Note that android container is still launched from a loop-mounted
.img. I will check if it would be possible to supported unpacked
android container under /var/lib/lxc/android/rootfs
Also at the moment emulator is still using MTD partitions, instead of
GPT formatted MMC device. That's also a TODO.

Regards,

Dmitrijs.


On 13 November 2013 20:54, Dmitrijs Ledkovs <launchpad@xxxxxxxxxxxx> wrote:
> Dmitrijs Ledkovs has proposed merging lp:~xnox/ubuntu/trusty/initramfs-tools-ubuntu-touch/no-loop into lp:ubuntu/initramfs-tools-ubuntu-touch.
>
> Requested reviews:
>   Ubuntu branches (ubuntu-branches)
>
> For more details, see:
> https://code.launchpad.net/~xnox/ubuntu/trusty/initramfs-tools-ubuntu-touch/no-loop/+merge/195137
> --
> https://code.launchpad.net/~xnox/ubuntu/trusty/initramfs-tools-ubuntu-touch/no-loop/+merge/195137
> You are the owner of lp:~xnox/ubuntu/trusty/initramfs-tools-ubuntu-touch/no-loop.
>
> === modified file 'debian/changelog'
> --- debian/changelog    2013-11-11 12:13:45 +0000
> +++ debian/changelog    2013-11-13 20:54:01 +0000
> @@ -1,3 +1,12 @@
> +initramfs-tools-ubuntu-touch (0.62) UNRELEASED; urgency=low
> +
> +  * Implement generic loops to find userdata and system partitions.
> +  * If system.img is not available on the userdata patrition, and an
> +    Ubuntu system partition is provided, fallback to mounting system
> +    partition as rootfs (without a loop mount).
> +
> + -- Dmitrijs Ledkovs <xnox@xxxxxxxxxx>  Wed, 13 Nov 2013 20:50:53 +0000
> +
From 9f6a2e14c548e671b3cce9c80c1c0ed367a0e26e Mon Sep 17 00:00:00 2001
From: Dmitrijs Ledkovs <dmitrijs.ledkovs@xxxxxxxxxxxxx>
Date: Wed, 13 Nov 2013 18:48:06 +0000
Subject: [PATCH] Use mtd userdata partition, allow no-loop configuration.

---
 tools/build-emulator-sdcard.sh | 17 +++++++++++------
 tools/run-emulator.sh          |  6 +++---
 2 files changed, 14 insertions(+), 9 deletions(-)

diff --git a/tools/build-emulator-sdcard.sh b/tools/build-emulator-sdcard.sh
index df30cef..ed2f652 100755
--- a/tools/build-emulator-sdcard.sh
+++ b/tools/build-emulator-sdcard.sh
@@ -18,18 +18,23 @@
 
 set -e
 set -x
+
+export PATH=out/host/linux-x86/bin/:$PATH
 OUT=out/target/product/generic/
+
 if [ ! -e $OUT/ubuntu-rootfs.tar.xz ]; then
     wget -O $OUT/ubuntu-rootfs.tar.xz `./build/tools/get-tarball-url.py`
 fi
 
 sudo umount $OUT/mnt || true
 
-dd if=/dev/zero of=$OUT/ubuntu-system.img bs=1 count=1 seek=3G
-mkfs.ext4 -F -L UBUNTU $OUT/ubuntu-system.img
+rm -f $OUT/ubuntu-system.img $OUT/ubuntu-userdata.img
+
+dd if=/dev/zero of=$OUT/ubuntu-system.img bs=1 count=0 seek=2G
+mkfs.ext4 -F -L SYSTEM $OUT/ubuntu-system.img
 
-dd if=/dev/zero of=$OUT/sdcard.img bs=1 count=1 seek=4G
-mkfs.ext4 -F -L USERDATA $OUT/sdcard.img
+dd if=/dev/zero of=$OUT/ubuntu-userdata.img bs=1 count=0 seek=3G
+mkfs.ext4 -F -L USERDATA $OUT/ubuntu-userdata.img
 
 mkdir -p $OUT/mnt
 
@@ -61,8 +66,8 @@ sudo cp $OUT/system.img $OUT/mnt/var/lib/lxc/android/system.img
 sync
 sudo umount $OUT/mnt
 
-sudo mount $OUT/sdcard.img $OUT/mnt
-sudo cp $OUT/ubuntu-system.img $OUT/mnt/system.img
+sudo mount $OUT/ubuntu-userdata.img $OUT/mnt
+[ "$1" != "-no-loop" ] && sudo cp $OUT/ubuntu-system.img $OUT/mnt/system.img
 sudo touch $OUT/mnt/.writable_image
 sync
 sudo umount $OUT/mnt
diff --git a/tools/run-emulator.sh b/tools/run-emulator.sh
index c371f67..b7f7ee1 100755
--- a/tools/run-emulator.sh
+++ b/tools/run-emulator.sh
@@ -18,10 +18,10 @@
 
 export PATH=out/host/linux-x86/bin/:$PATH
 
-if [ ! -e out/target/product/generic/sdcard.img ]
+if [ ! -e out/target/product/generic/ubuntu-userdata.img ]
 then
-    echo "No sdcard.img, run build-emulator-sdcard.sh first!"
+    echo "No ubuntu-userdata.img, run build-emulator-sdcard.sh first!"
     exit 1
 fi
 
-emulator -memory 512 -sysdir out/target/product/generic/ -system out/target/product/generic/system.img -data out/target/product/generic/userdata.img -cache out/target/product/generic/cache.img -sdcard out/target/product/generic/sdcard.img -kernel out/target/product/generic/ubuntu/kernel/vmlinuz -shell -no-jni -show-kernel -verbose -no-snapstorage -qemu -cpu cortex-a8 -append 'apparmor=0'
+emulator -memory 512 -sysdir out/target/product/generic/ -system out/target/product/generic/ubuntu-system.img -data out/target/product/generic/ubuntu-userdata.img -cache out/target/product/generic/cache.img -kernel out/target/product/generic/ubuntu/kernel/vmlinuz -ramdisk out/target/product/generic/initrd.img -shell -no-jni -show-kernel -verbose -no-snapstorage -qemu -cpu cortex-a9 -append "apparmor=0 datapart=/dev/mtdblock1 systempart=/dev/mtdblock0"
-- 
1.8.4.3


Follow ups