-
Notifications
You must be signed in to change notification settings - Fork 0
/
vm.sh
28 lines (28 loc) · 1.25 KB
/
vm.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
cd virtual-machines || mkdir virtual-machines; cd virtual-machines
read -p "Welcome! Press 1 to create a new virtual machine or 2 to load an existing virtual machine: " menu
if [ $menu -eq 1 ]
then
read -p "Name of your new virtual machine: " name
mkdir $name
cd $name
read -p "Hard drive size (GB): " hdasize
qemu-img create -f qcow2 "${name}.img" "${hdasize}G"
read -p "Number of CPUs: " cpus
read -p "Amount of RAM (MB): " ramsize
read -p "Path to your CDROM image or ISO, from / (including suffix: iso, img, etc.): " cdrompath
qemu-system-x86_64 -enable-kvm -cpu host -machine accel=kvm -smp $cpus -boot order=dc -m "${ramsize}M" -cdrom $cdrompath -hda ${name}.img -name $name & echo "VM loaded successfully. Exiting terminal.";sleep 3;exit
elif [ $menu -eq 2 ]
then
ls
read -p "Input the name of your virtual machine listed above: " vmname
cd $vmname
read -p "Number of CPUs: " cpus
read -p "Amount of RAM (MB): " ramsize
qemu-system-x86_64 -enable-kvm -cpu host -machine accel=kvm -smp $cpus -m "${ramsize}M" -hda ${vmname}.img -name $vmname & echo "VM loaded successfully. Exiting terminal.";sleep 3;exit
else
echo "I don't believe that you followed the instructions. You will receive another chance, but heed this warning."
./$0
sleep 1
exit
fi