#!/bin/bash # similar to mkcramfs (for use with debian mkinitrd) # mkext2fs dirname outfile # # no options are parsed # # Written by: Fabian Franz # # GPL v.2 - See: `locate gpl.txt` if [ $# -lt 2 ] then echo "Usage: $(basename $0) dirname outfile" exit 1 fi TMPDIR=/tmp/$(basename $0).$$ mkdir $TMPDIR function clean_exit { umount $TMPDIR 2>/dev/null rm -rf $TMPDIR } trap clean_exit EXIT COUNT=$[$(du -s $1 | awk '{ print $1 }' )*2+1000] dd if=/dev/zero of=$TMPDIR/image count=$COUNT mke2fs -F $TMPDIR/image mount -o loop $TMPDIR/image $TMPDIR cp -a $1/* $TMPDIR umount $TMPDIR cat $TMPDIR/image | gzip - > $2