Browse code

Final ramdisk must be a filesystem image

Dean Troyer authored on 2011/10/26 12:35:23
Showing 1 changed files
... ...
@@ -80,16 +80,24 @@ fi
80 80
 # ======================================
81 81
 
82 82
 if [ ! -r $IMG_FILE ]; then
83
-    qemu-img convert -O raw $CHROOTCACHE/natty-dev.img $IMG_FILE
84
-fi
83
+    qemu-nbd -c $NBD $CHROOTCACHE/natty-dev.img
84
+    if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then
85
+        echo "Couldn't connect $NBD"
86
+        exit 1
87
+    fi
85 88
 
86
-qemu-nbd -c $NBD $IMG_FILE
87
-if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then
88
-    echo "Couldn't connect $NBD"
89
-    exit 1
89
+    # Pre-create the image file
90
+    # FIXME(dt): This should really get the partition size to
91
+    #            pre-create the image file
92
+    dd if=/dev/zero of=$IMG_FILE bs=1 count=1 seek=$((2*1024*1024*1024))
93
+    # Create filesystem image for RAM disk
94
+    dd if=${NBD}p1 of=$IMG_FILE bs=1M
95
+
96
+    qemu-nbd -d $NBD
90 97
 fi
98
+
91 99
 MNTDIR=`mktemp -d --tmpdir mntXXXXXXXX`
92
-mount -t ext4 ${NBD}p1 $MNTDIR
100
+mount -t ext4 -o loop $IMG_FILE $MNTDIR
93 101
 cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf
94 102
 
95 103
 # git clone only if directory doesn't exist already.  Since ``DEST`` might not
... ...
@@ -174,6 +182,5 @@ chroot $MNTDIR chown stack $DEST/run.sh
174 174
 
175 175
 umount $MNTDIR
176 176
 rmdir $MNTDIR
177
-qemu-nbd -d $NBD
178 177
 
179 178
 gzip -1 $IMG_FILE