Skip to content

Instantly share code, notes, and snippets.

@dragolabs
Last active November 28, 2024 23:07
Show Gist options
  • Save dragolabs/f391bdda050480871ddd129aa6080ac2 to your computer and use it in GitHub Desktop.
Save dragolabs/f391bdda050480871ddd129aa6080ac2 to your computer and use it in GitHub Desktop.

Revisions

  1. dragolabs revised this gist Nov 25, 2017. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions proxmox-cli-and-tips.md
    Original file line number Diff line number Diff line change
    @@ -43,7 +43,8 @@ pvesh create /nodes/kvm01/qemu \
    -ide0=local:101/vm-101-disk-0.qcow2 \
    -ide2 local:iso/ubuntu-14.04-server-amd64.iso,media=cdrom
    pvesh create /nodes/kvm01/qemu/101/status/start```
    pvesh create /nodes/kvm01/qemu/101/status/start
    ```

    ### Remove container. Be careful, it'll destroy ct without questions
    ```
    @@ -60,12 +61,12 @@ grep -R memory /etc/pve/local | awk '{sum += $NF } END {print sum;}'
    cat /etc/pve/.vmlist | grep node | cut -d '"' -f2 | sort -n
    ```

    ### View sorted list of VMs like `vmid proxmox_host type
    ### View sorted list of VMs like `vmid proxmox_host type`
    ```
    cat /etc/pve/.vmlist | grep node | tr -d '":,'| awk '{print $1" "$4" "$6 }' | sort -n | column -t
    ```

    ### View sorted list of VMs like `vmid proxmox_host type vm_name
    ### View sorted list of VMs like `vmid proxmox_host type vm_name`
    ```
    for i in $(cat /etc/pve/.vmlist | grep node | cut -d '"' -f2 | sort -n);do NAME=$(grep -R 'name:' /etc/pve/nodes/*/*/$i.conf | awk {'print $2'}); INFO=$(grep $i /etc/pve/.vmlist | grep node | tr -d '":,'| awk '{print $1"\t"$4"\t"$6 }'); printf "%s\t%s\n" "$INFO" "$NAME" ;done
    ```
  2. dragolabs revised this gist Nov 25, 2017. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions proxmox-cli-and-tips.md
    Original file line number Diff line number Diff line change
    @@ -60,12 +60,12 @@ grep -R memory /etc/pve/local | awk '{sum += $NF } END {print sum;}'
    cat /etc/pve/.vmlist | grep node | cut -d '"' -f2 | sort -n
    ```
    ### View sorted list of VMs like `vmid proxmox_host type`
    ### View sorted list of VMs like `vmid proxmox_host type
    ```
    cat /etc/pve/.vmlist | grep node | tr -d '":,'| awk '{print $1" "$4" "$6 }' | sort -n | column -t
    ```
    ### View sorted list of VMs like `vmid proxmox_host type vm_name`
    ### View sorted list of VMs like `vmid proxmox_host type vm_name
    ```
    for i in $(cat /etc/pve/.vmlist | grep node | cut -d '"' -f2 | sort -n);do NAME=$(grep -R 'name:' /etc/pve/nodes/*/*/$i.conf | awk {'print $2'}); INFO=$(grep $i /etc/pve/.vmlist | grep node | tr -d '":,'| awk '{print $1"\t"$4"\t"$6 }'); printf "%s\t%s\n" "$INFO" "$NAME" ;done
    ```
  3. dragolabs revised this gist Nov 24, 2017. 1 changed file with 29 additions and 0 deletions.
    29 changes: 29 additions & 0 deletions proxmox-cli-and-tips.md
    Original file line number Diff line number Diff line change
    @@ -16,6 +16,35 @@ pct create 100 \
    --onboot 1
    ```

    ### Create container with pvesh command
    ```
    pvesh create /nodes/promox01/lxc \
    -vmid 1001 \
    -ostemplate local:vztmpl/ubuntu-16.04-x64-base.tar.gz \
    -cores 2 -cpuunits 1024 \
    -memory 4096 -swap 128 \
    -hostname ct1001.example.com \
    -net1 name=eth1,ip=192.168.0.2/32,bridge=vmbr1 \
    -rootfs local:24 \
    -onboot 1
    ```

    ### Create KVM with pvesh command
    ```
    pvesh create /nodes/kvm01/storage/local/content \
    -filename vm-101-disk-0.qcow2 \
    -format qcow2 -size 32G -vmid 101
    pvesh create /nodes/kvm01/qemu \
    -vmid 101 -memory 2048 \
    -sockets 1 -cores 4 \
    -net0 e1000,bridge=vmbr0 \
    -net1 e1000,bridge=vmbr1 \
    -ide0=local:101/vm-101-disk-0.qcow2 \
    -ide2 local:iso/ubuntu-14.04-server-amd64.iso,media=cdrom
    pvesh create /nodes/kvm01/qemu/101/status/start```
    ### Remove container. Be careful, it'll destroy ct without questions
    ```
    pct destroy 100
  4. dragolabs revised this gist Nov 24, 2017. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions proxmox-cli-and-tips.md
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,8 @@
    ### Find next free VM ID
    ```
    pvesh get /cluster/nextid
    ```

    ### Create containter with external and internal nets
    ```
    pct create 100 \
  5. dragolabs revised this gist Jul 19, 2017. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions proxmox-cli-and-tips.md
    Original file line number Diff line number Diff line change
    @@ -30,3 +30,8 @@ cat /etc/pve/.vmlist | grep node | cut -d '"' -f2 | sort -n
    ```
    cat /etc/pve/.vmlist | grep node | tr -d '":,'| awk '{print $1" "$4" "$6 }' | sort -n | column -t
    ```

    ### View sorted list of VMs like `vmid proxmox_host type vm_name`
    ```
    for i in $(cat /etc/pve/.vmlist | grep node | cut -d '"' -f2 | sort -n);do NAME=$(grep -R 'name:' /etc/pve/nodes/*/*/$i.conf | awk {'print $2'}); INFO=$(grep $i /etc/pve/.vmlist | grep node | tr -d '":,'| awk '{print $1"\t"$4"\t"$6 }'); printf "%s\t%s\n" "$INFO" "$NAME" ;done
    ```
  6. dragolabs revised this gist Jul 19, 2017. 1 changed file with 5 additions and 0 deletions.
    5 changes: 5 additions & 0 deletions proxmox-cli-and-tips.md
    Original file line number Diff line number Diff line change
    @@ -25,3 +25,8 @@ grep -R memory /etc/pve/local | awk '{sum += $NF } END {print sum;}'
    ```
    cat /etc/pve/.vmlist | grep node | cut -d '"' -f2 | sort -n
    ```

    ### View sorted list of VMs like `vmid proxmox_host type`
    ```
    cat /etc/pve/.vmlist | grep node | tr -d '":,'| awk '{print $1" "$4" "$6 }' | sort -n | column -t
    ```
  7. dragolabs renamed this gist Jul 19, 2017. 1 changed file with 11 additions and 5 deletions.
    16 changes: 11 additions & 5 deletions proxmox-cli.md → proxmox-cli-and-tips.md
    Original file line number Diff line number Diff line change
    @@ -12,10 +12,16 @@ pct create 100 \
    ```

    ### Remove container. Be careful, it'll destroy ct without questions
    ```
    pct destroy 100
    ```
    ### View sum of memory allocated to VMs and CTs
    ```
    pct destroy 100
    ```

    ### View sum of memory allocated to VMs and CTs
    ```
    grep -R memory /etc/pve/local | awk '{sum += $NF } END {print sum;}'
    ```
    ```

    ### View sorted list of vmid
    ```
    cat /etc/pve/.vmlist | grep node | cut -d '"' -f2 | sort -n
    ```
  8. dragolabs revised this gist Jun 30, 2017. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion proxmox-cli.md
    Original file line number Diff line number Diff line change
    @@ -15,7 +15,7 @@ pct create 100 \
    ```
    pct destroy 100
    ```
    ### View sum memory allocated for VMs and CTs
    ### View sum of memory allocated to VMs and CTs
    ```
    grep -R memory /etc/pve/local | awk '{sum += $NF } END {print sum;}'
    ```
  9. dragolabs revised this gist Jun 30, 2017. 1 changed file with 5 additions and 2 deletions.
    7 changes: 5 additions & 2 deletions proxmox-cli.md
    Original file line number Diff line number Diff line change
    @@ -11,8 +11,11 @@ pct create 100 \
    --onboot 1
    ```

    ### Remove container. Be careful, it'll destroy ct without questions
    ### Remove container. Be careful, it'll destroy ct without questions
    ```
    pct destroy 100
    ```

    ### View sum memory allocated for VMs and CTs
    ```
    grep -R memory /etc/pve/local | awk '{sum += $NF } END {print sum;}'
    ```
  10. dragolabs revised this gist Jun 29, 2017. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion proxmox-cli.md
    Original file line number Diff line number Diff line change
    @@ -9,4 +9,10 @@ pct create 100 \
    --net1 name=eth1,ip=192.168.0.2/32,bridge=vmbr1 \
    --rootfs local:24 \
    --onboot 1
    ```
    ```

    ### Remove container. Be careful, it'll destroy ct without questions
    ```
    pct destroy 100
    ```

  11. dragolabs created this gist Jun 29, 2017.
    12 changes: 12 additions & 0 deletions proxmox-cli.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,12 @@
    ### Create containter with external and internal nets
    ```
    pct create 100 \
    local:vztmpl/ubuntu-16.04-standard_16.04-1_amd64.tar.gz \
    --cores 2 --cpuunits 1024 \
    --memory 4096 --swap 128 \
    --hostname ct100.example.com \
    --net0 name=eth0,ip=1.2.3.4/32,bridge=vmbr0,gw=1.2.3.0 \
    --net1 name=eth1,ip=192.168.0.2/32,bridge=vmbr1 \
    --rootfs local:24 \
    --onboot 1
    ```