Skip to content

Instantly share code, notes, and snippets.

@jjasghar
Forked from dustymabe/virt-import.sh
Last active August 29, 2015 14:22
Show Gist options
  • Save jjasghar/e9c321116717be0dd08a to your computer and use it in GitHub Desktop.
Save jjasghar/e9c321116717be0dd08a to your computer and use it in GitHub Desktop.
#!/bin/bash
# exit on any error
set -o errexit
# A few tunable variables
NAME='atomic'
NAME='try'
#NAME='test'
#DISK='/guests/rhel-guest-image-7.1-20150224.0.x86_64.qcow2'
DISK='/guests/rhel-atomic-cloud-7.1-1.x86_64.qcow2'
DISK='/guests/try.raw'
SEEDISO='/guests/my-seed.iso'
RAMSIZE='2048' # IN MB
DISKSIZE='20' # IN GB
VCPUS='2' # NUM of CPUs
IMAGEDIR='/guests/'
BRIDGE='virbr0'
TMPDISK=${DISK}${RANDOM}
echo "Creating backup disk $TMPDISK"
qemu-img create -f qcow2 -b $DISK $TMPDISK 10G
# Build up the virt-install command
cmd='virt-install --import'
cmd+=" --name $NAME"
cmd+=" --ram $RAMSIZE"
cmd+=" --vcpus $VCPUS"
cmd+=" --disk path=$TMPDISK"
cmd+=" --disk path=$SEEDISO"
cmd+=" --accelerate"
cmd+=" --graphics none"
cmd+=" --force"
cmd+=" --network bridge=$BRIDGE"
# Run the command
echo "Running: $cmd"
$cmd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment