robertsoto74 / Test-Reports

Documentary of Absolved Tests in Different Software and Hardware Try-outs
The Unlicense
0 stars 0 forks source link

Adding Disks to a running PROXMOX Installation #14

Open robertsoto74 opened 1 year ago

robertsoto74 commented 1 year ago
#!/bin/bash

# set the disk parameters
DISK_SIZE="10G"
DISK_NAME="disk2"
VM_ID="100"

# create the disk image file
qemu-img create -f qcow2 /var/lib/vz/images/${VM_ID}/${DISK_NAME}.qcow2 ${DISK_SIZE}

# add the disk to the virtual machine
qm set ${VM_ID} --scsihw virtio-scsi-pci --scsi0 /var/lib/vz/images/${VM_ID}/${DISK_NAME}.qcow2

# start the virtual machine
qm start ${VM_ID}

Here's what each line of the script does:

DISK_SIZE="10G": sets the size of the disk to be added.
DISK_NAME="disk2": sets the name of the disk image file.
VM_ID="100": sets the ID of the virtual machine to which the disk will be added.
qemu-img create -f qcow2 /var/lib/vz/images/${VM_ID}/${DISK_NAME}.qcow2 ${DISK_SIZE}: creates the disk image file in the appropriate directory.
qm set ${VM_ID} --scsihw virtio-scsi-pci --scsi0 /var/lib/vz/images/${VM_ID}/${DISK_NAME}.qcow2: adds the disk to the virtual machine using the qm set command.
qm start ${VM_ID}: starts the virtual machine.

You can modify the DISK_SIZE, DISK_NAME, and VM_ID variables to match your requirements. Save the script to a file with a .sh extension and execute it in a terminal on your Proxmox server using the bash command.