Compare commits

..

1 Commits

Author SHA1 Message Date
whiskerz007
50c639216a
Create empty EFI disk then import #61
Sometimes pvesm will timeout when running `pvesm alloc` against ZFS pool
2020-08-17 08:47:43 +02:00
2 changed files with 22 additions and 25 deletions

View File

@ -3,7 +3,7 @@
This script will create a new Proxmox VM with the latest version of Home Assistant. To create a new VM, run the following in a SSH session or the console from Proxmox interface
```
bash -c "$(wget -qLO - https://git.sfs.ddnss.org/Erik/proxmox_hassos_install/raw/branch/master/install.sh)"
bash -c "$(wget -qLO - https://github.com/whiskerz007/proxmox_hassos_install/raw/master/install.sh)"
```
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 disk` button above (_Note: additional steps must be taken for storage to take effect in the VM after 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.

View File

@ -81,21 +81,24 @@ info "Container ID is $VMID."
# Get latest Home Assistant disk image archive URL
msg "Getting URL for latest Home Assistant disk image..."
RELEASE_TYPE=vmdk
RELEASE_EXT=vmdk.gz
URL=$(cat<<EOF | python3
import requests
url = "https://api.github.com/repos/home-assistant/operating-system/releases"
url = 'https://api.github.com/repos/home-assistant/operating-system/releases'
r = requests.get(url).json()
if "message" in r:
if 'message' in r:
exit()
for release in r:
if release["prerelease"]:
if release['prerelease']:
continue
for asset in release["assets"]:
if asset["name"].find("$RELEASE_TYPE") != -1:
image_url = asset["browser_download_url"]
for asset in release['assets']:
if asset['name'].endswith('$RELEASE_EXT'):
global image_url
image_url = asset['browser_download_url']
break
if 'image_url' in globals():
print(image_url)
exit()
break
EOF
)
if [ -z "$URL" ]; then
@ -110,12 +113,7 @@ FILE=$(basename $URL)
# Extract Home Assistant disk image
msg "Extracting disk image..."
case $FILE in
*"gz") gunzip -f $FILE;;
*"xz") xz -d $FILE;;
*"zip") unzip $FILE;;
*) die "Unable to handle file extension '${FILE##*.}'.";;
esac
gunzip -f $FILE
# Create variables for container disk
STORAGE_TYPE=$(pvesm status -storage $STORAGE | awk 'NR>1 {print $2}')
@ -132,16 +130,15 @@ done
# Create VM
msg "Creating VM..."
VM_NAME=$(sed -e "s/\_//g" -e "s/.${RELEASE_TYPE}.*$//" <<< $FILE)
VM_NAME=$(sed -e "s/\_//g" -e "s/.${RELEASE_EXT}//" <<< $FILE)
qm create $VMID -agent 1 -bios ovmf -name $VM_NAME -net0 virtio,bridge=vmbr0 \
-onboot 1 -ostype l26 -scsihw virtio-scsi-pci
pvesm alloc $STORAGE $VMID $DISK0 128 1>&/dev/null
qm importdisk $VMID ${FILE%.*} $STORAGE ${IMPORT_OPT:-} 1>&/dev/null
qm set $VMID \
-efidisk0 ${DISK0_REF},size=128K \
EFI_SIZE=128K
truncate -s $EFI_SIZE efi
qm importdisk $VMID efi $STORAGE ${IMPORT_OPT:-} 1>&/dev/null
qm importdisk $VMID ${FILE%".gz"} $STORAGE ${IMPORT_OPT:-} 1>&/dev/null
qm set $VMID -bootdisk sata0 -efidisk0 ${DISK0_REF},size=$EFI_SIZE \
-sata0 ${DISK1_REF},size=6G > /dev/null
qm set $VMID \
-boot order=sata0 > /dev/null
# Add serial port and enable console output
set +o errtrace