Creating nested ESXi inside Proxmox

Ok, sounds a little silly, but there are times when you might want to have a nested ESX VM inside your proxmox environment – I found this great page on how to do it, but I’d rather do it via CLI so it’s repeatable.

This is the CLI I found which worked for me:

qm create 703 --balloon "0" --boot "order=sata0;ide2;net0" --cores "2" --cpu "host" --ide2 "ISOs:iso/VMware-VMvisor-Installer-201912001-15160138.x86_64.iso,media=cdrom,size=343064K" --machine "q35" --memory "8192" --name "pveESX3" --net0 "vmxnet3,bridge=vmbr0" --numa "1" --onboot "1" --ostype "l26" --sata0 "nvmeLVMlocal:32,backup=0,discard=on,ssd=1"

In the lead up to that, I also found a page on stackoverflow asking if there was an easy way to take the output of “qm config” and turn it into “qm create”. It doesn’t seem like there is exactly that – “qm showcmd” as recommended on there isn’t terrible, but isn’t enough.

So this is what I came up with – unfortunately it only gets 90% of the way there –

qm config 703 | grep -v 'vmgenid' | grep -v 'smbios1' | grep -v 'meta' | sed -e 's/vmxnet3=.*,/vmxnet3,/g' -e 's/://' | awk '{ printf("--%s \"%s\" ",$1,$2);} END {print("\n");}'

The issue is that it outputs “nvmeLVMlocal:vm-701-disk-0,backup=0,discard=on,size=32G,ssd=1”, but really it needs to be “nvmeLVMlocal:32,backup=0,discard=on,ssd=1” (replace 32 with desired size).

But it’s better than nothing.

Hope this helps someone one day!

Setting up a LVM LV quickly..

I’m playing with proxmox right now, and had a need to setup LVM locally on each node. I figure why not script it.. I’ve ended up with this abomination of a script. You probably want to do better, but it’s a start:

set -x;
pvcreate /dev/sda; 
vgcreate vg_$lvmid /dev/sda; 
vgs; l
vcreate -n lv_$lvmid -l 100%FREE vg_$lvmid;
mkdir -p /local/vg_$lvmid-lv_$lvmid; 
mkfs.ext4 /dev/mapper/vg_$lvmid-lv_$lvmid;
echo /dev/mapper/vg_$lvmid-lv_$lvmid /local/vg_$lvmid-lv_$lvmid ext4 defaults 0 0 >> /etc/fstab; 
mount /local/vg_$lvmid-lv_$lvmid; 
df -h

Or on one line..

set -x;lvmid=`hostname`_localLVM; pvcreate /dev/sda; pvs; vgcreate vg_$lvmid /dev/sda; vgs; lvcreate -n lv_$lvmid -l 100%FREE vg_$lvmid;lvs; mkdir -p /local/vg_$lvmid-lv_$lvmid; mkfs.ext4 /dev/mapper/vg_$lvmid-lv_$lvmid;echo /dev/mapper/vg_$lvmid-lv_$lvmid /local/vg_$lvmid-lv_$lvmid ext4 defaults 0 0 >> /etc/fstab; mount /local/vg_$lvmid-lv_$lvmid; df -h

Hope this helps someone in the future.. maybe me!