Post

Proxmox - Cheatsheet

Nice-to-know commands to manage Proxmox

This article will be updated while experimenting on Proxmox.

Cheatsheet for Proxmox

List of commands I might need to use again some day.

PVE Official Documentation

Basic Linux Log Commands

1
2
3
4
5
# Observe for new dmesg messages
dmesg -W

# Follow journal log
journalctl --follow

qm - Virtual Machine

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
vmid=100

# Config
/etc/pve/qemu-server/${vmid}.conf

# Start and observe VM terminal
qm start ${vmid} && sleep 1 && qm terminal ${vmid}

# Stop
qm stop ${vmid}

# VM Locked, cannot stop
qm unlock ${vmid}

# Forcely stop VM (last resort, not recommended)
ps aux | grep "/usr/bin/kvm -id ${vmid}"
kill -9 PID

Sources: qm cmd, qm.conf, qm PCI Passthrough,

lscpi - List PCI device details

1
2
3
4
5
6
7
8
# List devices and their vendor id information
lspci -nn

# List devices and which kernel module and driver is in use
lspci -k

# List device capabilities identified by system
lspci -vv

PCI device control

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
# Query power state
cat /sys/bus/pci/devices/0000\:03\:00.0/power_state 
D0

# Query reset state
cat /sys/bus/pci/devices/0000\:03\:00.0/reset_method 
pm bus

# Query If d3Cold allowed
cat /sys/bus/pci/devices/0000\:03\:00.0/d3cold_allowed
1

# Remove PCI device
echo 1 > /sys/bus/pci/devices/0000\:03\:00.0/remove

# Initiate scan, re-adds removed PCI device if it is not in failed state
echo 1 > /sys/bus/pci/rescan

LUKS

Create Vault

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# Create an empty file for encrypted container (512 MB)
dd if=/dev/urandom of=filevault.img bs=1M count=512

# Create LUKS volume within the empty file
cryptsetup --verify-passphrase luksFormat filevault.img

# Open the LUKS volume
cryptsetup open --type luks filevault.img keyvault

# Create filesystem labeled as keyvault
mkfs.ext4 -L keyvault /dev/mapper/keyvault

# Mount
mount /dev/mapper/keyvault /media/keyvault

Controlling LUKS Vault

1
2
3
4
5
6
7
8
9
# Open
cryptsetup open --type luks vaultfile preferred-name

# Location of opened vaults
/dev/mapper

# Close, unmount before closing
umount /media/mountpoint
cryptsetup close preferred-name

Other Sources

This post is licensed under CC BY 4.0 by the author.