Added feature to select storage where VM is created #7

This commit is contained in:
whiskerz007 2019-02-20 16:26:49 +01:00
parent 12350dd855
commit 487f24fe42
2 changed files with 13 additions and 8 deletions

View File

@ -1,12 +1,12 @@
# Proxmox HassOS Install
# New Proxmox VM with HassOS
To create a new HassOS VM in Proxmox with the latest version, run the following in a SSH session or the console from Proxmox interface
This script will create a new Proxmox VM with the latest version of HassOS. To create a new VM in the `local-lvm` storage, run the following in a SSH session or the console from Proxmox interface
```
TMP=`mktemp -d`;pushd $TMP > /dev/null;wget -qO - https://raw.githubusercontent.com/whiskerz007/proxmox_hassos_install/master/install.sh | bash;popd > /dev/null;rm -rf $TMP;unset TMP
TMP=`mktemp -d`;pushd $TMP > /dev/null;wget -qO - https://raw.githubusercontent.com/whiskerz007/proxmox_hassos_install/master/install.sh local-lvm | bash;popd > /dev/null;rm -rf $TMP;unset TMP
```
After script completes, click on the new VM (_the script will tell you the ID_), click on the `Hardware` tab for the VM and change the `Memory` and `Processors` settings to what you desire. The `Hard Disk` can be expanded by clicking on it, then click on the `Resize` button above. The network MAC address can be changed by selecting `Network Device` and clicking `Edit` above. Once all changes have been made, click `Start` above.
After script completes, click on the new VM (_the script will tell you the ID_), click on the `Hardware` tab for the VM and change the `Memory` and `Processors` settings to what you desire. The `Hard Disk` can be expanded by clicking on it, then click on the `Resize` button above (_Note: for the additional storage to take effect in the VM, you must apply this before the first boot_). The network MAC address can be changed by selecting `Network Device` and clicking `Edit` above. Once all changes have been made, click `Start` above.
To get the DHCP address assigned to the VM, open the console after the VM has been started, when the messages slow down press the `Enter` key a couple of times until you see the following

View File

@ -1,5 +1,10 @@
#!/bin/bash
VM_STORAGE=${1:-local-lvm} && \
pvesm list $VM_STORAGE >& /dev/null || { \
echo -e "\n\n\nERROR: '$VM_STORAGE' is not a valid storage ID.\n\n\n" && \
exit 1
} && \
VMID=$(cat<<EOF | python3
import json
with open('/etc/pve/.vmlist') as vmlist:
@ -45,12 +50,12 @@ echo -e "\n\n\n" \
"********************************\n" \
"* Creating new VM *\n" \
"********************************\n" && \
qm create $VMID -bios ovmf -bootdisk sata0 -efidisk0 local-lvm:vm-${VMID}-disk-0,size=128K \
qm create $VMID -bios ovmf -bootdisk sata0 -efidisk0 ${VM_STORAGE}:vm-${VMID}-disk-0,size=128K \
-name $(sed -e "s/\_//g" -e "s/.vdi.gz//" <<< $FILE) -net0 virtio,bridge=vmbr0 \
-onboot 1 -ostype l26 -sata0 local-lvm:vm-${VMID}-disk-1,size=6G \
-onboot 1 -ostype l26 -sata0 ${VM_STORAGE}:vm-${VMID}-disk-1,size=6G \
-scsihw virtio-scsi-pci && \
pvesm alloc local-lvm $VMID vm-${VMID}-disk-0 128 1>&/dev/null && \
qm importdisk $VMID ${FILE%".gz"} local-lvm 1>&/dev/null && \
pvesm alloc $VM_STORAGE $VMID vm-${VMID}-disk-0 128 1>&/dev/null && \
qm importdisk $VMID ${FILE%".gz"} $VM_STORAGE 1>&/dev/null && \
echo -e "\n\n\n" \
"********************************\n" \
"* Completed Successfully *\n" \