Skip to content

Instantly share code, notes, and snippets.

@mrpeardotnet
Last active March 20, 2024 10:43
Show Gist options
  • Save mrpeardotnet/e6bc57ed899c948ba53b3193a202eb2c to your computer and use it in GitHub Desktop.
Save mrpeardotnet/e6bc57ed899c948ba53b3193a202eb2c to your computer and use it in GitHub Desktop.
PVE-postinstall-6.x

Proxmox PVE 6.x Post Installation Steps

This cheatsheet helps to set up your Proxmox Virtual Environment (PVE) host after fresh installation. Designed and tested on PVE version 6.x.

Note about sudo

I do not prepend sudo command to any of commands listed here, but keep in mind that nearly all commands requires su privileges, so use sudo if your account happen to not have root access.

How to edit config files

The simplest way to edit config file is to use vim.tiny editor, for example to edit vzdump.conf file use this command:

vim.tiny /etc/vzdump.conf

Or just use any of your favourite editors (I use mc a lot, too).

Change enterprise repository to no-subscription or test repository

Proxmox uses enterprise repository by default, but this repository requires subscription key to authenticate. Still there are two more free repos available:

  • Test repository (contains newest updates released, good for testing, not so good for production)
  • No-subscription repository (more stable channel, but still officialy not recommended for production use, but this is the repo to go with if you can't use enterprise repository.

Remove enterprise repository:

rm /etc/apt/sources.list.d/pve-enterprise.list

Add no-subscription repository (recommended)

echo "deb http://download.proxmox.com/debian/pve buster pve-no-subscription" > /etc/apt/sources.list.d/pve-no-subscription.list

Add test repository (for testlabs only!)

echo "deb http://download.proxmox.com/debian/pve buster pvetest" > /etc/apt/sources.list.d/pve-test.list

Do system update

Now you can do system update using PVE GUI or using command line.

apt update && apt dist-upgrade && apt autoremove

Install your favourite tools

Now it is time to install your favourite tools, this heavily depends on your needs and preferences, for example:

apt install mc htop

Remove old kernels

System updates may bring new kernels quite often and old kernels are not removed automatically. It is good practice to keep your system clean.

Check running kernel version

uname -r

Remove (purge) unused kernel(s)

Use with caution!

apt purge pve-kernel-<version>

Use TAB key to display available kernels at the end of the command line. Do not remove currently running kernel even when you have new one ready to be used after reboot, so you can always fall back to last tested and available kernel.

Set low swappiness level

Heavy swapping on PVE host can kill performance so it is good idea to set lower swappiness level to prevent unnecessary swapping. Keep in mind that your PVE host should always have enough RAM available for it's guests to prevent memory pressure - do not overprovision memory unless you know what you are doing. To read more about (Linux kernel) swappiness reffer to Swappiness on Wikipedia.

Check current swappiness level

sysctl vm.swappiness

Default value is 60.

Temporary change swappiness level

To temporary set swapinness level to 1 use this command:

echo 1 > /proc/sys/vm/swappiness

Permanent swappiness level setting

Edit the /etc/sysctl.conf config to follow this example block: set vm.swappiness for example to 1:

###################################################################
# vm.swappiness
# value 0 - 100 
#    0 Swap is disabled, this meant that the kernel would swap only to avoid an out of memory condition (only on older kernels)
#    1 Minimum amount of swapping without disabling it entirely (on kernels 3.5 and new, same as 0 on older kernels).
#   10 This value is sometimes recommended to improve performance when sufficient memory exists in a system.
#   60 The default value.
#  100 The kernel will swap aggressively.
#
# Set this value to 1 to prevent unnecessary swapping when memory is getting low, 
# but don't forget that this requires good memory planing on VMs to avoid getting out of memory.
vm.swappiness = 1

Reboot system to apply changes.

Disable swapping

Setting low swappines level might help, but host will usualy swap even on low swappines level. It is recommended to disable host's swap if you want to avoid swapping completely. It is safe as far as you do not overprovision your host's RAM, so plan VM's resources carefully.

Temporary disable swap

This command flushes swap contents (back to RAM) and then disables the swap. This is not persistent across reboots.

swapoff -a

Disable swap permanently

To disable swap permanently you have to edit /etc/fstab and comment out (with #) line where swap is defined, for example:

#/dev/pve/swap none swap sw 0 0

Now swap will be disabled after reboot. You can uncomment the line to enable swap again anytime later.

Configure KSM sharing

KSM sharing (kernel same-page merging) is running in the Linux kernel and scans the memory of all the virtual machines running on a single host, looking for duplication and consolidating. To read more about KSM sharing reffer to Kernel same-page merging on Wikipedia.

KSM sharing is activated when host's free memory drops below defined threshold, default value is 20%. To change threshold value to e.g. 40% edit the /etc/ksmtuned.conf config file and set:

KSM_THRES_COEF = 40

Restart ksmtuned service to applay changes:

service ksmtuned restart

Configure VZDump

Use multithreaded pigz (parallel zip)

If you want to speed up .gz dumps you can use multi-threaded pigz instead of single-threaded gzip. To do so, you need to install pigz package and configute it in vzdump.conf config.

1) Installing the pigz package

apt install pigz

2) Configure VZDum to use pigz

Edit the /etc/vzdump.conf config file, uncomment pigz: N: line and replace N: with number of threads you want to pigz to use, e.g. to use 6 threads the line should be like this:

pigz: 6

Configure temp directory for LXC container backups to NFS

This configuration is required to ensure LXC containers backups are not failing when backing up to network (NFS) share. If your backup fails with the following error:

ERROR: Backup of VM XXX failed ... failed: exit code 2

Then uncomment or add this line to /etc/vzdump.conf file:

tmpdir: /var/tmp
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment