summaryrefslogtreecommitdiff
path: root/others/vm3/compute
diff options
context:
space:
mode:
authorYour Name <you@example.com>2024-12-21 16:45:32 +0800
committerYour Name <you@example.com>2024-12-21 16:45:32 +0800
commite94b275f5630e032a6971831f8be520ae81a5d02 (patch)
treec6819daab6bceff1477647f40d52fa23f2c88628 /others/vm3/compute
parentbe3dde6ce14698c5818f21f65037a4beef1199cf (diff)
v1vm3-done
Diffstat (limited to 'others/vm3/compute')
-rwxr-xr-xothers/vm3/compute/create.sh11
-rw-r--r--others/vm3/compute/start.sh4
2 files changed, 11 insertions, 4 deletions
diff --git a/others/vm3/compute/create.sh b/others/vm3/compute/create.sh
index 6d83a03..649cd86 100755
--- a/others/vm3/compute/create.sh
+++ b/others/vm3/compute/create.sh
@@ -14,6 +14,9 @@ disk_gb=$5
14if [ $# -ne 5 ]; then 14if [ $# -ne 5 ]; then
15 echo "Usage: $0 <vm-name> <os> <vcpu> <ram(gb)> <disk(gb)>" 15 echo "Usage: $0 <vm-name> <os> <vcpu> <ram(gb)> <disk(gb)>"
16 echo "seed.iso and image file have to be present!" 16 echo "seed.iso and image file have to be present!"
17 echo ""
18 echo "Available images"
19 sudo ls /var/lib/libvirt/images/.image_store
17 exit 1 20 exit 1
18fi 21fi
19 22
@@ -41,20 +44,20 @@ fi
41sudo virt-install --name $vmname \ 44sudo virt-install --name $vmname \
42 --vcpus $vcpu \ 45 --vcpus $vcpu \
43 --memory "$((ram_gb * 1024))"\ 46 --memory "$((ram_gb * 1024))"\
44 --disk path=$new_vm_path,size=$disk_gb,format=qcow2 \ 47 --disk path=$new_vm,format=qcow2 \
45 --disk path=$seed_iso,device=cdrom \ 48 --disk path=$seed_iso,device=cdrom \
46 --os-type linux \ 49 --os-type linux \
47 --os-variant $os \ 50 --os-variant $os \
48 --virt-type kvm \ 51 --virt-type kvm \
49 --graphics none \ 52 --graphics none \
50 --network bridge=virbr0,model=virtio \ 53 --network bridge=virbr0,model=virtio \
51 --print-xml > $xml || { echo "Failed to print XML."; exit 1; } 54 --print-xml > $xml #|| { echo "Failed to print XML."; exit 1; }
52 55
53sudo virsh define $xml &> /dev/null || { echo "Failed to define the new VM."; exit 1; } 56sudo virsh define $xml #&> /dev/null || { echo "Failed to define the new VM."; exit 1; }
54 57
55sudo qemu-img resize $new_vm +$disk_gb"G" #&> /dev/null 58sudo qemu-img resize $new_vm +$disk_gb"G" #&> /dev/null
56 59
57sudo virsh start $vmname 60sudo virsh start $vmname
58 61
59sudo rm "${workingdir}"/* 62#sudo rm "${workingdir}"/*
60 63
diff --git a/others/vm3/compute/start.sh b/others/vm3/compute/start.sh
new file mode 100644
index 0000000..5a2b3aa
--- /dev/null
+++ b/others/vm3/compute/start.sh
@@ -0,0 +1,4 @@
1#!/bin/bash
2
3# starts vm
4# need to remove seed.iso first if vm have the seed iso