#!/bin/zsh set -e if [[ ! -x ../e2fsimage-0.2.0/src/e2fsimage ]]; then echo "Please make e2fsimage" exit 1 fi if [[ ! -f source/rand ]]; then echo "source/rand expected. Grab a large file (< 128MB) or run" echo " dd if=/dev/urandom of=rand bs=1048576 count=120" exit 1 fi echo "Creating blank image" qemu-img create test.img 128M echo "Partitioning image" echo ",,L" | /sbin/sfdisk -H 16 -S 63 -L test.img info=(`/sbin/fdisk -l -u test.img | grep '^test' | sed '1!d'`) start=$info[2] blocks=${info[4]/+/} echo "Creating ext2 FS ($blocks blocks)" ../e2fsimage-0.2.0/src/e2fsimage -f foo.img -d source -s $blocks echo "Pasting file system into test.img image (at $start blocks)" dd if=foo.img of=test.img conv=notrunc bs=512 seek=$start echo "Cleaning up" rm foo.img