리눅스를 사용한다면 여기에 약간의 스크립트가 있습니다 :
#!/bin/bash
# Automatic Image file resizer
# Written by SirLagz
strImgFile=$1
export PATH=$PATH:/sbin
if [[ ! $(whoami) =~ "root" ]]; then
echo ""
echo "**********************************"
echo "*** This should be run as root ***"
echo "**********************************"
echo ""
exit
fi
if [[ -z $1 ]]; then
echo "Usage: ./autosizer.sh <Image File>"
exit
fi
if [[ ! -e $1 || ! $(file $1) =~ "x86" ]]; then
echo "Error : Not an image file, or file doesn't exist"
exit
fi
partinfo=`parted -ms $1 unit B p | awk '{if (NR!=2) {print}}'`
fileSystemType=`echo "$partinfo" | grep -o 'ext4\|ext3'`
numberOfMatchPart=`echo "$fileSystemType" | wc -l`
if [[ $fileSystemType == "" || $numberOfMatchPart -eq 0 || $numberOfMatchPart -gt 1 ]] ; then
echo "Error : Your partition layout is not currently supported by this tool."
exit
fi
partnumber=`echo "$partinfo" | grep $fileSystemType | awk -F: ' { print $1 } '`
partstart=`echo "$partinfo" | grep $fileSystemType | awk -F: ' { print substr($2,0,length($2)) } '`
loopback=`losetup -f --show -o $partstart $1`
e2fsck -f $loopback
minsize=`resize2fs -P $loopback | awk -F': ' ' { print $2 } '`
minsize=`echo $minsize+200000 | bc`
resize2fs -p $loopback $minsize
sleep 1
losetup -d $loopback
partnewsize=`echo "$minsize * 4096" | bc`
newpartend=`echo "$partstart + $partnewsize" | bc`
parted $1 rm $partnumber
parted $1 unit B mkpart primary $partstart $newpartend
endresult=`parted -m $1 unit B print free | tail -1 | awk -F: ' { print substr($2,0,length($2)) } '`
truncate -s $endresult $1
크레디트 : Sirlagz (soooo 죄송합니다!)