summaryrefslogtreecommitdiff
path: root/mkusbimg
diff options
context:
space:
mode:
Diffstat (limited to 'mkusbimg')
-rwxr-xr-xmkusbimg9
1 files changed, 6 insertions, 3 deletions
diff --git a/mkusbimg b/mkusbimg
index 6a41f4c..5e655b2 100755
--- a/mkusbimg
+++ b/mkusbimg
@@ -56,13 +56,16 @@ LOOPDEV=$(next_avail_loop)
TMPDIR=$(mktemp -d)
# TODO: there are better ways to do this
-# than adding 5MB to the rootsize
+# than adding 25% to the rootsize
+# XXX: doesn't seem to boot if we cut it too
+# close. even if everything fits...
# IMGSZ >= filesystem overhead + rootsize + 512bytes
# must hold or there will be insufficient space
-IMGSZ=$(( $(du -ms ${IMGROOT}|cut -f1) + 5 ))
+rootsize=$(du -bs ${IMGROOT}|cut -f1)
+IMGSZ=$(( (${rootsize}*5)/4 + 512 ))
# create the image file
-dd if=/dev/zero of="$IMG" bs=1M count="$IMGSZ"
+dd if=/dev/zero of="$IMG" bs="$IMGSZ" count=1
# loop mount the disk image
losetup "$LOOPDEV" "$IMG"