Wait for partition device to appear
diff --git a/tools/build_ramdisk.sh b/tools/build_ramdisk.sh
index 3a757df..d169b9f 100755
--- a/tools/build_ramdisk.sh
+++ b/tools/build_ramdisk.sh
@@ -81,7 +81,7 @@
 
 if [ ! -r $IMG_FILE ]; then
     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
+    if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then
         echo "Couldn't connect $NBD"
         exit 1
     fi
@@ -101,7 +101,7 @@
 cp -p /etc/resolv.conf $MNTDIR/etc/resolv.conf
 
 # We need to install a non-virtual kernel and modules to boot from
-if [ ! -r `ls $MNTDIR/boot/vmlinuz-2.6.*-generic | head -1` ]; then
+if [ ! -r "`ls $MNTDIR/boot/vmlinuz-*-generic | head -1`" ]; then
     chroot $MNTDIR apt-get install -y linux-generic
 fi
 
@@ -187,5 +187,3 @@
 
 umount $MNTDIR
 rmdir $MNTDIR
-
-gzip -1 $IMG_FILE