Skip to content

Instantly share code, notes, and snippets.

@scollier
Created September 22, 2014 16:50
Show Gist options
  • Save scollier/0902c4fb3461e2b26931 to your computer and use it in GitHub Desktop.
Save scollier/0902c4fb3461e2b26931 to your computer and use it in GitHub Desktop.
create a bare fedora 20 qcow2 image
#!/bin/bash
SIZE="15"
ROOTPASS="password"
OUTPUTDIR="output"
VMEXISTS=$(virsh list --all | grep -i test)
if [ ! -d "$OUTPUTDIR" ]; then
mkdir ./"$OUTPUTDIR"
fi
if [ -f "$OUTPUTDIR/fedora.qcow2" ]; then
echo "images already exists"
exit 0
fi
virt-builder fedora-20 \
--output "$OUTPUTDIR"/fedora.qcow2 \
--format qcow2 \
--size "$SIZE"G \
--root-password password:"$ROOTPASS" \
--run-command 'touch /.autorelabel'
# deploy the image
virt-install --import --name test --ram 1024 --vcpus 1 --disk path=$(pwd)/"$OUTPUTDIR"/fedora.qcow2,format=qcow2,bus=virtio --network bridge=virbr0 --force
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment