[Firmware] [PATCH] Use genext2fs instead of uml to create the root file system for qemu
James Davidson
james at greycastle.net
Sun Jul 22 19:34:35 CDT 2007
Building a second image of the kernel to boot using uml just to make a root
file system for qemu is overkill, and on my laptop did not work. Using
genext2fs is a simple, fast build to get the same job done. The only
drawback is that genext2fs callocs memory to store the entire file system
it is creating in. Of course, building the file system on disk would be
nicer (nudge, nudge, wink, wink).
---
diff --git a/download.sh b/download.sh
index 8c59951..ecccfa0 100755
--- a/download.sh
+++ b/download.sh
@@ -41,6 +41,10 @@ URL=http://landley.net/code/toybox/downloads/toybox-0.0.3.tar.bz2 \
SHA1= \
download &&
+URL=http://downloads.sourceforge.net/genext2fs/genext2fs-1.4.1.tar.gz \
+SHA1=9ace486ee1bad0a49b02194515e42573036f7392 \
+download &&
+
# Ye olde emulator
#URL=http://qemu.org/qemu-0.9.0.tar.gz \
diff --git a/host-tools.sh b/host-tools.sh
index 5519271..500182b 100755
--- a/host-tools.sh
+++ b/host-tools.sh
@@ -24,29 +24,17 @@ echo which toybox
[ $? -ne 0 ] && dienow
fi
-# As a temporary measure, build User Mode Linux and use _that_ to package
-# the ext2 image to boot qemu with.
+# Build genext2fs. Used to build the ext2 image we boot qemu with.
-if [ -z "$(which linux)" ]
+if [ -z "$(which genext2fs)" ]
then
- setupfor linux &&
- cat > mini.conf << EOF
-CONFIG_MODE_SKAS=y
-CONFIG_BINFMT_ELF=y
-CONFIG_HOSTFS=y
-CONFIG_SYSCTL=y
-CONFIG_STDERR_CONSOLE=y
-CONFIG_UNIX98_PTYS=y
-CONFIG_BLK_DEV_LOOP=y
-CONFIG_LBD=y
-CONFIG_EXT2_FS=y
-CONFIG_PROC_FS=y
-EOF
- make ARCH=um allnoconfig KCONFIG_ALLCONFIG=mini.conf &&
- make -j $CPUS ARCH=um &&
- cp linux "${HOSTTOOLS}" &&
+ setupfor genext2fs &&
+ echo $PWD &&
+ ./configure &&
+ make -j &&
+ cp genext2fs "${HOSTTOOLS}" &&
cd .. &&
- rm -rf linux-*
+ rm -rf genext2fs-*
[ $? -ne 0 ] && dienow
fi
diff --git a/package-mini-native.sh b/package-mini-native.sh
index 2b69333..5249a50 100755
--- a/package-mini-native.sh
+++ b/package-mini-native.sh
@@ -8,32 +8,17 @@ source include.sh
#("${WORK}/mksquashfs" "${NATIVE}/tools" "${WORK}/tools.sqf" \
# -noappend -all-root -info || dienow) | dotprogress
-# A 256 meg sparse image
-rm -f "$IMAGE"
-dd if=/dev/zero of="$IMAGE" bs=1024 seek=$[256*1024-1] count=1 &&
-/sbin/mke2fs -b 1024 -F "$IMAGE" &&
-
-# User User Mode Linux to package this, until toybox mke2fs is ready.
-
-# Write out a script to control user mode linux
-cat > "${WORK}/uml-package.sh" << EOF &&
-#!/bin/sh
-mount -n -t ramfs /dev /dev
-mknod /dev/loop1 b 7 1
-# Jump to build dir
-echo copying files...
-cd "$BUILD"
-/sbin/losetup /dev/loop1 "$IMAGE"
-mount -n -t ext2 /dev/loop1 "$WORK"
-tar cC "$NATIVE" tools | tar xC "$WORK"
-mkdir "$WORK"/dev
-mknod "$WORK"/dev/console c 5 1
-umount "$WORK"
-losetup -d /dev/loop1
-umount /dev
-sync
+# Create a sparse root filesystem using genext2fs
+rm -f "$IMAGE" "${WORK}/device_table"
+cat > "${WORK}/device_table" << EOF &&
+# Make sure the major number is the same as the number in each device driver
+#
+#<name> <type> <mode> <uid> <gid> <major> <minor> <start> <inc> <count>
+/dev d 755 0 0 - - - - -
+/dev/null c 666 0 0 1 3 0 0 -
+/dev/zero c 640 0 0 1 5 0 0 -
+/dev/console c 640 0 0 5 1 0 0 -
EOF
-chmod +x ${WORK}/uml-package.sh &&
-linux rootfstype=hostfs rw quiet ARCH=${ARCH} PATH=${PATH} init="${HOSTTOOLS}/oneit -p ${WORK}/uml-package.sh"
-
-
+"${HOSTTOOLS}/genext2fs" -z -D "${WORK}/device_table" -d "${NATIVE}" -b $((256*1024)) "$IMAGE" &&
+/sbin/tune2fs -e panic "$IMAGE" &&
+/sbin/fsck.ext2 -p "$IMAGE"
--
James Davidson (o_
james at greycastle.net //\
http://moria.greycastle.net/ V_/_
More information about the Firmware
mailing list