Proxmox VM Auto-Upgrade Script (qm + vzdump) with Network Tests and Auto-Restore

Proxmox VM Auto-Upgrade Script (qm + vzdump) with Network Tests and Auto-Restore

This article describes a simple (but effective) automation script for Proxmox VE that:

  • creates a backup of a VM (optional),
  • starts the VM if it was originally stopped,
  • runs apt upgrade + reboot inside the VM,
  • performs network tests before and after the update,
  • restores from backup automatically if tests fail (optional),
  • shuts down the VM again if it was originally stopped.

Where to download the script

You can download the script directly from my website:

soban.pl/bash/upgrade_proxmox_qm.sh

Required folders

Before you run anything, create two folders for scripts and logs:

Install the script

Download the file into /root/automate_scripts/ and make it executable:

How it works (high level)

  • Backup (vzdump snapshot + zstd) is executed first (if enabled).
  • If the VM was stopped, the script starts it and waits WAIT_TIME seconds.
  • Runs network tests BEFORE update:
  • Executes apt update/upgrade/dist-upgrade/autoremove/clean and finally reboots the VM.
  • Waits again (WAIT_TIME) and runs the same tests AFTER update.
  • If tests fail and a backup exists, it performs qmrestore automatically.
  • If the VM was originally stopped, it shuts down the VM at the end.

Usage

The script expects exactly two arguments:

  • VMID – the Proxmox VM ID
  • TIME_SEC – how long to wait after start/reboot (in seconds)

Tip: choose a WAIT_TIME that matches your VM boot time and apt upgrade duration. Typical values are 300 to 1000 seconds depending on the VM.

Full script (for reference)

If you prefer to keep everything in one place, below is the full script exactly as used in this setup:

Cron jobs (weekly schedule + per-VM logs)

Below is an example crontab that runs upgrades once a week (different VM each weekday) and writes separate logs to /root/logs/.

Edit root crontab:

Paste rules like these (comments in English):

Quick checks / troubleshooting

  • Make sure root can SSH into the VM by hostname (the script uses ssh root@<vm-hostname>).
  • Make sure DNS (or /etc/hosts) resolves the VM hostname correctly from the Proxmox host.
  • If apt needs user interaction, ensure your VMs are set up for non-interactive upgrades (or pin/hold packages that prompt).

That’s it. Drop the script into /root/automate_scripts/, send logs into /root/logs/, and your weekly VM maintenance becomes mostly fire-and-forget.

Dell WD19/WD19S: firmware update on Proxmox/Debian without USB timeouts (fwupd + autosuspend fix)


If you’re trying to update the firmware of a Dell WD19/WD19S docking station on Proxmox (or Debian) using fwupdmgr, you may hit the classic Operation timed out error during the Erasing… stage. In practice, the update fails due to USB power management (autosuspend). Below you’ll find a simple, effective fix and a ready-to-run script you can use on a server or laptop.

Symptoms

Most commonly, during a dock firmware update (WD19/WD19S), you’ll see an error similar to:

At this point, fwupdmgr may show the WD19S device as Update State: Failed or keep reporting pending activation, but the flash process never completes.

Why does this happen?

During flashing, the dock performs long-running operations. If the system tries to save power on USB (autosuspend), control transfers can fail. The result is a timeout exactly during the flash bank erase stage (erase bank).

Quick fix: disable USB autosuspend during the update

The simplest solution is to temporarily set autosuspend to -1 (disabled). This setting lasts until reboot (unless you make it permanent in the kernel cmdline), but it’s more than enough for the update process.

Then run the firmware update:

After the update: “pending activation” and unplug requirement

After a successful firmware installation for WD19/WD19S, fwupdmgr often prints the following message:

Do the following in this exact order:

  • Unplug the USB-C cable from the dock (from the laptop).
  • (Optional) Unplug the dock power for 10–15 seconds and plug it back in.
  • Plug the USB-C cable back in.
  • Run the activation step:

Finally, verify the status:

Ready-to-use script: install + update + autosuspend disable (with restore)

Below is a ready-to-run script that:

  • installs fwupd
  • refreshes LVFS metadata
  • temporarily disables USB autosuspend (so WD19S won’t fail with timeouts)
  • runs firmware updates
  • restores the previous autosuspend value afterwards (even if the update fails)

You can copy the script directly from this article, but if you prefer a faster way, you can download it from:

https://soban.pl/bash/dell_updage.sh

Example download and run:

If you want to preview the script before running it:

If you don’t have less installed:

Script (full content)

Running the script

The simplest way:

FAQ & tips

  • The update still fails? Disconnect all peripherals from the dock (monitors/LAN/USB), leave only power and USB-C, do a hard reset of the dock (unplug power for 30s), and try again.
  • “pending activation” after update – this is normal for WD19/WD19S. You must unplug USB-C, plug it back in, then run fwupdmgr activate.
  • Does this update the laptop BIOS? Not always. fwupdmgr shows “System Firmware” (BIOS/UEFI) separately from the dock. This article focuses on the dock and the USB timeout issue.

Summary

If Dell WD19/WD19S firmware updates fail on Proxmox/Debian during the Erasing… stage, in most cases it’s enough to disable USB autosuspend temporarily. The script above does that automatically and restores the previous setting afterwards, so your system keeps working normally.

How to Upgrade Proxmox VE 8.x to 9.0 (Debian 12 to Debian 13) – Step-by-Step with Script

Introduction

Proxmox VE 9.0 (based on Debian 13 “Trixie”) has been released, and it brings updated packages, a new kernel, and improved stability. This guide will walk you through the in-place upgrade from Proxmox VE 8.4.x (Debian 12 “Bookworm”) to Proxmox VE 9.0.

The process will be automated using a ready-made upgrade script that:

  • Checks your current version
  • Runs the pve8to9 pre-upgrade check
  • Backs up your current APT sources
  • Updates repositories from Bookworm to Trixie
  • Performs a full dist-upgrade
  • Logs all changes before and after the upgrade

Download and run the upgrade script

You can download the ready upgrade script directly from our server, make it executable, and run it:

If you lose connection (which can happen during a Proxmox upgrade), you can follow the logs with:

Be patient and wait for the script to finish — it may take some time.

Full script source

Below is the full content of the script for reference. It is recommended to download the latest version from the link above to ensure you have the most up-to-date fixes.

Post-upgrade verification

Expected output should look like:

pve-manager/9.x.x/xxxxxxxx (running kernel: 6.x.x-x-pve)
Check the running kernel version:

Review the upgrade log to confirm no errors occurred:

If you used the post-check service created by the script, you can view its results:

Dynamic Tmux Window Titles with SSH and Hostname


Want your Tmux window titles to automatically show the hostname you connect to via SSH — and restore the local name after you disconnect? This guide will walk you through setting that up step by step.

1. Tmux configuration – ~/.tmux.conf

In your Tmux configuration file, set the default shell command to a custom Bash init file (.bash_tmux) that will handle window title updates.

2. Bash init script – ~/.bash_tmux

This file runs at shell startup inside Tmux. It sets the window name to your local hostname and overrides the ssh command to change the window title dynamically.

3. Reload Tmux config without restarting

To apply the changes without restarting the Tmux session, run the following:

To manually reload the current shell with the new .bash_tmux configuration:

4. Final result

  • New Tmux windows automatically show the local hostname
  • When connecting via SSH, the window is renamed to the remote host
  • When disconnecting, the original local name is restored

Clean, readable, and perfect for sysadmins, devops engineers, and Tmux lovers who appreciate automatic order in their terminal tabs 💪

The most important Linux commands that every user should know

The Linux system is a powerful tool that offers users tremendous flexibility and control over their working environment. However, to fully harness its potential, it is worth knowing the key commands that are essential for both beginners and advanced users. In this article, we will present and discuss the most important Linux commands that every user should know.

1. Basic Navigation Commands

  • pwd – Displays the current directory path you are in:
  • ls – Lists the contents of a directory. You can use the -l option for a detailed view or -a to show hidden files:
  • cd – Changes the directory. For example, cd /home/user will move you to the /home/user directory:
  • mkdir – Creates a new directory:
  • rmdir – Removes an empty directory:

2. File Management

  • cp – Copies files or directories:
  • mv – Moves or renames files/directories:
  • rm – Removes files or directories. Use the -r option to remove a directory with its contents:
  • touch – Creates an empty file or updates the modification time of an existing file:

3. Process Management

  • ps – Displays currently running processes. Use the -aux option to see all processes:
  • top – Displays a dynamic list of processes in real time:
  • kill – Stops a process by its ID:
  • bg and fg – Manage background and foreground processes:

4. User and Permission Management

  • sudo – Allows a command to be executed with administrator privileges:
  • chmod – Changes permissions for files/directories:
  • chown – Changes the owner of a file/directory:
  • useradd and userdel – Adds and removes users:

5. Networking and Communication

  • ping – Checks the connection with another host:
  • ifconfig – Displays information about network interfaces:
  • ssh – Connects remotely to another computer:
  • scp – Copies files over SSH:

6. Command Usage Examples

Below is an example of using several discussed commands:

  • chmod – Changes permissions for files/directories:
  • chown – Changes the owner of a file/directory:
  • useradd and userdel – Adds and removes users:

7. Disk and File System Management

  • df – Displays information about disk space availability:
  • du – Shows the size of files and directories:
  • mount – Mounts a file system:
  • umount – Unmounts a file system:

8. Searching for Files

  • find – Searches for files in the system:
  • locate – Quickly searches for files in the system:
  • grep – Searches for patterns in files:
  • which – Finds the full path to an executable file:

9. Communicating with the System

  • echo – Displays text on the screen:
  • cat – Displays the contents of a file:
  • more – Displays the contents of a file page by page:
  • less – Similar to more, but offers more navigation options:
  • man – Displays the user manual for a command:

10. Working with Archives

  • tar – Creates or extracts archives:
  • zip – Creates a ZIP archive:
  • unzip – Extracts ZIP files:
  • tar -xvzf – Extracts a TAR.GZ archive:
  • gzip – Compresses files in .gz format:
  • gunzip – Extracts .gz files:

11. System Monitoring

  • uptime – Displays the system uptime and load:
  • dmesg – Displays system messages related to boot and hardware:
  • iostat – Shows input/output system statistics:
  • free – Displays information about RAM:
  • netstat – Displays information about network connections:
  • ss – A modern version of netstat, used for monitoring network connections:

12. Working with System Logs

  • journalctl – Reviews system logs:
  • tail – Displays the last lines of a file:
  • logrotate – Automatically manages logs:

13. Advanced File Operations

  • ln – Creates a link to a file:
  • xargs – Passes arguments from input to other commands:
  • chmod – Changes permissions for files/directories:
  • chattr – Changes file attributes:

Linux offers a wide array of commands that allow for complete control over the computer. Key commands such as ls, cd, cp, and rm are used daily to navigate through the file system, manage files, and directories. To effectively master these commands, it’s best to start with those that are most useful in everyday work. For instance, commands for navigating directories and managing files are fundamental and require practice to become intuitive. Other commands, such as ps for monitoring processes, ping for testing network connections, or chmod for changing permissions, are also worth knowing to fully leverage the power of the Linux system.

To learn effectively, it’s advisable to start by experimenting with commands in practice. Creating files, directories, copying, and deleting data allows for familiarity with their operation. Over time, it’s worthwhile to start combining different commands to solve more advanced problems, such as monitoring processes, managing users, or working with system logs. One can also use documentation, such as man or websites, to delve into the details of each command and its options.

Remember, regular use of the terminal allows for learning habits that make handling the Linux system more natural. Frequent use of commands, solving problems, and experimenting with new commands is the best way to master the system and fully utilize it.

Linux is indeed a powerful tool that provides great control over the system… but remember, don’t experiment on production! After all, experimenting on a production server is a bit like playing Russian roulette — only with bigger consequences. If you want to feel like a true Linux wizard, always test your commands in a development environment. Only then will you be able to learn from mistakes instead of searching for the cause of several gigabytes of data disappearance. And if you don’t know what you’re doing, simply summon your trusty weapon: man!

Enhancing Virtual Machine Management with QEMU Guest Agent on Proxmox


Ever wondered how to streamline the management and monitoring of virtual machines in your Proxmox environment? QEMU Guest Agent is a game-changer, offering tools that significantly enhance the way you interact with virtual systems. Let’s dive into how this tool can transform your setup.

What Makes QEMU Guest Agent Indispensable?

  • Time Synchronization: Keeping time consistent across your virtual machines and the host can be tricky, but QEMU Guest Agent automates this, ensuring that time-sensitive operations run smoothly.
  • Power Management: Imagine being able to shut down or reboot your virtual machines right from the Proxmox panel — no need to log in to each VM. It’s not only convenient but also a time saver.
  • System Monitoring: Get detailed insights into file systems, network activities, and other operational parameters directly from your host. This level of monitoring allows for timely diagnostics and adjustments.
  • Disk Management: Handling disk operations without having to intervene directly on the VM makes backing up and restoring data more straightforward than ever.

Setting Up QEMU Guest Agent on Your Proxmox Server

Getting started with QEMU Guest Agent involves a few simple steps:

  • Enable the Agent: Log in to your Proxmox panel, go to the ‘Options’ section of your desired VM, and make sure the ‘QEMU Guest Agent’ option is checked.

Next up, installing it on an Ubuntu VM:

To check whether the qeumu-guest-agent that can make the change is working properly:

The QEMU Guest Agent doesn’t just make life easier by automating the mundane tasks — it also enhances the security and efficiency of your virtual environment. Whether you’re managing a single VM or a whole fleet, it’s an invaluable addition to your toolkit.

Automatic deletion of files on QNAP drive via SSHFS


Automation of Disk Space Management in a Linux Environment

In today’s digital world, where data is being accumulated in ever-increasing amounts, managing disk space has become a key aspect of maintaining operational efficiency in systems. In this article, I will present a script that automates the process of managing space on a remote disk mounted via SSHFS, particularly useful for system administrators who regularly deal with filling storage media.

Prerequisites

Before starting, ensure that SSHFS and all necessary packages enabling its proper operation are installed on your system. SSHFS allows remote file systems to be mounted via SSH, which is crucial for our script’s operation. To install SSHFS and the necessary tools, including a package that enables password forwarding (sshpass), use the following command:

Bash Script for Disk Space Management

Our Bash script focuses on monitoring and maintaining a defined percentage of free disk space on a remote disk mounted via SSHFS. Here are the script’s main functions:

Goal Definition:

TARGET_USAGE=70 – the percentage of disk space we want to maintain as occupied. The script will work to keep at least 30% of the disk space free.

Mount Point and Paths:

MOUNT_POINT=”/mnt/qnapskorupki” – the local directory where the remote disk is mounted. TARGET_DIRS=”$MOUNT_POINT/up*.soban.pl” – the directories where the script will look for files to delete if needed.

Function check_qnap: This function checks whether the disk is mounted and whether the mount directory is not empty. If there are issues, the script attempts to unmount and remount the disk using sshfs with a password forwarded through sshpass.

File Deletion: The script monitors disk usage and, if TARGET_USAGE is exceeded, it finds and deletes the oldest files in specified directories until the target level of free space is achieved.

Example Script Execution:

script starts working and gradually deletes files

The script will run until it reaches 70% usage as planned:

Script runs until reaching 70%

Downloading the script and adding it to crontab

Of course, the script should be adjusted to meet your specific needs. However, if you want to download it and add it to crontab, follow these steps:

If you want to automate the file removal process, for example, at the end of the day, add the following entry to crontab:

In this case, the script will run every day at 11:55 PM:

Make sure to use the correct path to the script.

Security and Optimization

The script uses a password directly in the command line, which can pose a security risk. In practical applications, it is recommended to use more advanced authentication methods, such as SSH keys, which are more secure and do not require a plaintext password in the script. However, in the case of QNAP, we used a password when writing this script.

Conclusion

The presented script is an example of how daily administrative tasks, such as disk space management, can be automated, thus increasing efficiency and reliability. Its implementation in real IT environments can significantly streamline data management processes, especially in situations where quick response to changes in disk usage is critical.

How to automatically turn off your laptop when battery status is displayed in Linux


Automatically Shutting Down Your Laptop at Low Battery Levels

Maintaining long battery life and protecting data are crucial for laptop users. In this article, we’ll show you how to create a simple Bash script that automatically shuts down your laptop when the battery level falls below 20%. Additionally, you’ll learn how to set up a crontab to run the script every 10 minutes, ensuring continuous monitoring.

Creating a Bash Script

The Bash script we have prepared will check the current battery level and compare it to a set minimum threshold. If the battery level drops below this threshold, the script initiates a system shutdown, helping to protect your data and hardware.

Also you can download script:

Don’t forget to grant permissions to run it:

Crontab Configuration

Crontab is a tool that allows you to schedule tasks in the Linux system. With it, we can set up regular battery checks.

Summary

With this setup, you can rest assured about the condition of your laptop even during intensive use. Automatic shutdown at low battery levels not only protects the equipment but also helps maintain a longer battery life.

Expanding Storage Space in Linux: Step-by-Step Guide using LVM and fdisk

Expanding disk space in Linux virtual machines is a key aspect of server system management. In this article, we show how to effectively increase disk space using LVM and fdisk tools, based on real system data.

Preliminary Preparations

Before making changes to partitions and volumes, it is important to check the current state of the disks in the system. We will use the lsblk command to identify available disks and partitions.

Here is an example of the lsblk command output on a machine:

Creating Snapshots

Before making changes to disk configurations, it is advisable to create a snapshot of the LVM volumes to ensure data can be restored in case of unexpected issues.

Modifying Partitions

Next, we proceed to modify the partitions using fdisk. We remove the existing partition and then create a new one that utilizes the entire available space on disk sdb.

Saving Changes

After properly configuring the partitions, we use the w command in fdisk to save the changes and update the partition table.

Executing pvscan

After modifying the partitions, we execute the pvscan command so the system can update information about available physical volumes.

Configuring LVM

After saving changes to the partition table, we need to update the LVM configuration to include the new disk space. We use the lvextend command with automatic file system resizing.

Summary

Expanding disk space on a Linux virtual machine enhances performance and the availability of storage space. Thanks to the steps described, managing disk space in systems using LVM becomes simpler and more efficient.

Troubleshooting Proxmox clusters and restoring the LXC container

Managing Proxmox clusters can sometimes present technical difficulties, such as inconsistencies in cluster configuration or issues with restoring LXC containers. Finding and resolving these issues is crucial for maintaining the stability and performance of the virtualization environment. In this article, I present a detailed guide on how to diagnose and resolve an issue with an unreachable node and how to successfully restore an LXC container.

Before you begin any actions, make sure you have a current backup of the system.

Diagnosing the State of the Proxmox Cluster

and:

To understand the state of the cluster, execute the following command on the node-up-page-04 node:

Expected output:

Then check the detailed cluster information with the following command:

Expected output:

Removing the Container Configuration File and Cleaning Data

I discovered that the configuration file for container 107 still exists on the cluster’s file system at the path:

Output:

To remove this file and any remaining data associated with the detached node, execute:

Restoring the Container

After removing the configuration file, I restored the LXC container on the node-up-page-04 node using the command:

Output:

The restoration process was successful, and the container was ready for use. This case illustrates the importance of thorough diagnostics and configuration file management in Proxmox when working with clusters. Regular reviews of configurations are advisable to avoid inconsistencies and operational issues in the future.