Skip to content

Instantly share code, notes, and snippets.

@ismailbay
Last active April 29, 2020 19:43
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismailbay/c87f4b608e007e169bec3c8002834a45 to your computer and use it in GitHub Desktop.
Save ismailbay/c87f4b608e007e169bec3c8002834a45 to your computer and use it in GitHub Desktop.
create ubuntu18.04 VMs
#!/bin/sh
# https://blog.alexellis.io/kvm-kubernetes-primer/
NAME=$1
CPUS=$2
RAM=$3
if [ -z "$NAME" ] ;
then
echo Specify a virtual-machine name.
exit 1
fi
if [ -z "$RAM" ] ;
then
RAM=4096
fi
if [ -z "$CPUS" ] ;
then
CPUS=2
fi
echo creating VM $NAME with $CPUS cpus and $RAM RAM
sudo virt-install \
--name $NAME \
--ram $RAM \
--disk path=/var/lib/libvirt/images/$NAME.img,size=30 \
--vcpus $CPUS \
--os-type linux \
--os-variant ubuntu18.04 \
--network bridge:br0,model=virtio \
--graphics none \
--console pty,target_type=serial \
--location 'http://at.archive.ubuntu.com/ubuntu/dists/bionic/main/installer-amd64/' \
--extra-args 'console=ttyS0,115200n8 serial'
@ismailbay
Copy link
Author

ismailbay commented Apr 25, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment