Skip to content

Instantly share code, notes, and snippets.

@ismailbay

ismailbay/create-vm.sh

Last active Apr 29, 2020
Embed
What would you like to do?
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

This comment has been minimized.

Copy link
Owner Author

@ismailbay ismailbay commented Apr 25, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.