From 61be92420904629cfb08f79f9dc5fef402a4f53a Mon Sep 17 00:00:00 2001 From: Dean Troyer Date: Tue, 25 Oct 2011 22:35:23 -0500 Subject: [PATCH] Final ramdisk must be a filesystem image --- tools/build_ramdisk.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh index 146e3fccd7..c220f0294c 100755 --- a/tools/build_ramdisk.sh +++ b/tools/build_ramdisk.sh @@ -80,16 +80,24 @@ fi # ====================================== if [ ! -r $IMG_FILE ]; then - qemu-img convert -O raw $CHROOTCACHE/natty-dev.img $IMG_FILE + qemu-nbd -c $NBD $CHROOTCACHE/natty-dev.img + if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then + echo "Couldn't connect $NBD" + exit 1 + fi + + # Pre-create the image file + # FIXME(dt): This should really get the partition size to + # pre-create the image file + dd if=/dev/zero of=$IMG_FILE bs=1 count=1 seek=$((2*1024*1024*1024)) + # Create filesystem image for RAM disk + dd if=${NBD}p1 of=$IMG_FILE bs=1M + + qemu-nbd -d $NBD fi -qemu-nbd -c $NBD $IMG_FILE -if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then - echo "Couldn't connect $NBD" - exit 1 -fi MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX` -mount -t ext4 ${NBD}p1 $MNTDIR +mount -t ext4 -o loop $IMG_FILE $MNTDIR cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf # git clone only if directory doesn't exist already. Since ``DEST`` might not @@ -174,6 +182,5 @@ chroot $MNTDIR chown stack $DEST/run.sh umount $MNTDIR rmdir $MNTDIR -qemu-nbd -d $NBD gzip -1 $IMG_FILE