-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathmachine-i440fx.sh
66 lines (59 loc) · 2.33 KB
/
machine-i440fx.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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#!/bin/bash
#Create template
#args:
# vm_id
# vm_name
# file name in the current directory
function create_template() {
#Print all of the configuration
echo "Creating template $2 ($1)"
#Create new VM
#Feel free to change any of these to your liking
qm create $1 --name $2 --ostype l26
#Set networking to default bridge
qm set $1 --net0 virtio,bridge=vmbr0
#Set display to serial
qm set $1 --serial0 socket --vga serial0
#Set memory, cpu, type defaults
#If you are in a cluster, you might need to change cpu type
qm set $1 --memory 1024 --cores 4 --cpu host
#Set boot device to new file
qm set $1 --scsi0 ${storage}:0,import-from="$(pwd)/$3",discard=on
#Set scsi hardware as default boot disk using virtio scsi single
qm set $1 --boot order=scsi0 --scsihw virtio-scsi-single
#Enable Qemu guest agent in case the guest has it available
qm set $1 --agent enabled=1,fstrim_cloned_disks=1
#Add cloud-init device
qm set $1 --ide2 ${storage}:cloudinit
#Set CI ip config
#IP6 = auto means SLAAC (a reliable default with no bad effects on non-IPv6 networks
#IP = DHCP means what it says, so leave that out entirely on non-IPv4 networks to avoid DHCP delays
qm set $1 --ipconfig0 "ip6=auto,ip=dhcp"
#Import the ssh keyfile
qm set $1 --sshkeys ${ssh_keyfile}
#If you want to do password-based auth instaed
#Then use this option and comment out the line above
#qm set $1 --cipassword password
#Add the user
qm set $1 --ciuser ${username}
#Resize the disk to 8G, a reasonable minimum. You can expand it more later.
#If the disk is already bigger than 8G, this will fail, and that is okay.
qm disk resize $1 scsi0 8G
#I had to run the following command to get "snippets" to show up as a type in the GUI:
pvesm set local --content backup,iso,snippets
#qm set $1 --cicustom "users=local:snippets/debian-12.yaml"
#Make it a template
qm template $1
#Remove file when done
rm $3
}
#Path to your ssh authorized_keys file
#Alternatively, use /etc/pve/priv/authorized_keys if you are already authorized
#on the Proxmox system
export ssh_keyfile=/root/.ssh/id_rsa.pub
#Username to create on VM template
export username=thyan
#Name of your storage
export storage=local-lvm
#The images that I've found premade
#Feel free to add your own