First of all, automatically upgrading your Proxmox hosts is probably not the best idea for several reasons. However, if you decide to do it anyway, there's a package called
unattended-upgrades in Debian that can do it for you. There are a few important things you should be aware of, though:
1. By default,
unattended-upgrades only installs security updates (similiar to
apt upgrade). not new features (which you’d get with
apt full-upgrade or
apt dist-upgrade). On Proxmox, however, you should
always use
full-upgrade /
dist-upgrade. So, if you still want to use
unattended-upgrades, make sure to configure it accordingly:
https://wiki.debian.org/PeriodicUpdates#Configure_unattended-upgrades
2. While services on Debian/Ubuntu systems generally should restart automatically when they themselves are upgraded, they d
on’t automatically restart when only one of their dependencies is upgraded. This means a service may continue running with outdated (and potentially vulnerable) code until you manually restart it or reboot the host. This can be avoided by installing
needrestart: (
https://manpages.ubuntu.com/manpages/focal/man1/needrestart.1.html), which detects which services require a restart after updates and can be configured to restart them automatically.
So it's safe to "dist upgrade" then reboot ? Currently, I completely free up the node with migrations or VM shutdowns, and then I launch the dist-upgrade.
If the
qemu-guest-agent is installed on all your VMs, then yes, rebooting while the VMs are running is generally safe. In that case, all VMs will receive a graceful shutdown command from the host before the reboot. If some VMs don’t have the guest agent installed, it’s better to shut them down manually before rebooting the host.
Also, when using
needrestart (see link above), a reboot is only required if a kernel update has been installed.
My personal approach:
I prefer to update my Proxmox hosts manually and interactively. Here’s how I usually do it:
apt update && apt dist-upgrade
After the upgrade completes, needrestart tells me which services need to be restarted, and I let it restart them. It also tells me if a reboot is required. If so, I shut down my TrueNAS Core VM (yeah, I still use that ) since it doesn’t have the guest agent installed.
Then I issue the reboot command, and Proxmox gracefully shuts down all other running VMs and performs the reboot.