Skip to content

Commit

Permalink
add option -N
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Lange committed Sep 10, 2015
1 parent 0531095 commit aa6a0b1
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions dev-utils/fai-kvm
Expand Up @@ -49,6 +49,7 @@ usage() {
fai-kvm [options] cd [imagename] # start a host booting from a ISO image
-n create a new empty disk image, which is used as a local disk
-N recreate a new empty disk image, even if one already exists
-s <size> size of the local disk (GB, defaults to 5GB)
-d <num> number of local disks (default is one)
-m <mem> RAM size (MB, defaults to 2000MB)
Expand All @@ -60,9 +61,10 @@ EOF
}
# - - - - - - - - - - - - - - - - - - - - - - - - -

while getopts "Uhnu:s:m:d:V" opt ; do
while getopts "UhnNu:s:m:d:V" opt ; do
case "$opt" in
n) newdisk=1 ;;
N) newdisk=2 ;;
U) usernet=1 ;;
u) user=$OPTARG ;;
m) ram=$OPTARG ;;
Expand Down Expand Up @@ -108,10 +110,15 @@ for i in `seq 1 $disks` ; do
done
gopt="$fix $vga -m $ram -smp 2 -name FAI-test"

# create new disk image
if [ X$newdisk = X1 ]; then

# create new disk images
if [ X$newdisk != X0 ]; then
for i in `seq 1 $disks` ; do
rm -f $diskfile-$i.qcow2
if [ X$newdisk = X1 -a -f $diskfile-$i.qcow2 ]; then
echo "Cannot overwrite disk image. Please use -N."
exit 3
fi
rm -f $diskfile-$i.qcow2
qemu-img create -f qcow2 -o preallocation=metadata $diskfile-$i.qcow2 ${size}G
done
fi
Expand Down

0 comments on commit aa6a0b1

Please sign in to comment.