Add support to build an ext4 image from a filesystem
This is suitable for passing to Qemu with -hda which makes it appear
as a disk to a Qemu instance. Once it appears, one can chroot into it.
Note:
- Device need not be connected, this option is only used to prepare
a standalone image.
- BCC isn't built but is just cloned into the image.
- Other options such as --buildtar are ignored.
Signed-off-by: Joel Fernandes (Google) <joel@joelfernandes.org>
diff --git a/buildimage b/buildimage
new file mode 100755
index 0000000..ccdc65d
--- /dev/null
+++ b/buildimage
@@ -0,0 +1,11 @@
+#!/bin/bash
+set -e
+
+# Given a path, make an ext4 image out of it, store it in $2
+dd if=/dev/zero of=$2 bs=4k count=$((256 * 1024 * 2))
+mkfs.ext4 $2
+
+OUT=`mktemp -d`
+mount -o loop $2 $OUT/
+rsync -ra $1/ $OUT/
+umount $OUT/