Configure Proxmox 8.x for a Low Power Home Lab Server

Introduction

I’ve been using low power CPUs for some time. This has caused some issues when I’ve needed more CPU processing power. My goal is to move to more power hungry CPUs but still try and save power. To this end I decided to change the CPU governor Proxmox uses. I also switched to using a small form factor case with its lower power power supply.

Configure CPU for Low Power

To make these changes you’ll need to ssh into your proxmox host.

Lat’s start by looking at your current CPU freequency.
> cat /proc/cpuinfo | grep MHz

The above command returns the following for my server.

cpu MHz : 3800.000
cpu MHz : 1760.822
cpu MHz : 3800.000
cpu MHz : 3800.000

First update repos.
> sudo apt update

Install acpi utilities.
> sudo apt install acpi-support acpid acpi

Its time to edit grub.
> nano -w /etc/default/grub

Look for the line that starts with “GRUB_CMDLINE_LINUX_DEFAULT” and add “intel_pstate=disable”..

Mine looks like this.

GRUB_CMDLINE_LINUX_DEFAULT="quiet intel_pstate=disable"

Save and now rebuild grub.
> update-grub

Reboot the system and ssh back in. Change the governor being used.
> echo “conservative” | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

Check your new CPU frequency.
> cat /proc/cpuinfo | grep MHz

Mine shows then following when idle.

cpu MHz : 1605.058
cpu MHz : 1600.000
cpu MHz : 1600.000
cpu MHz : 1600.000

Edit crontab to make the changes permanent.
> crontab -e

add the following to the bottom and save.

@reboot  echo "conservative" | tee /sys/devices/system/cpu/cpu*/cpufreq/scaling_governor

pstates vs acpi

I know I should have used pstates instead. ACPI did what I wanted. So I used it.

Conclusion

This is a quick tutorial that I hope helps someone out.

How to Upgrade PHP Packages on Ubuntu 22.04 and 24.04

Background

Managing PHP versions is crucial for maintaining compatibility, security, and performance of web applications. Ubuntu often provides multiple PHP versions, but upgrading packages across versions can be tedious. This script simplifies the process by automating package upgrades, switching the active PHP version for Apache, and cleaning up outdated packages.

Prerequisites

  • You must have administrative privileges (sudo access).
  • Ensure your system is running Ubuntu 22.04 or 24.04.
  • Make sure Apache is installed if you are using PHP with a web server.

Script

#!/bin/bash

# Get installed PHP versions
php_versions=$(update-alternatives --list php | awk -F'/' '{print $NF}' | sort -V)
echo "Installed PHP versions:"
echo "$php_versions"

# Ask user which PHP version to upgrade packages to
echo -n "Enter the PHP version to upgrade packages to: "
read target_version

# Get a list of installed PHP packages
php_packages=$(dpkg -l | awk '/^ii/ && /php/{print $2}')
echo "Checking packages that need to be upgraded to PHP $target_version..."

declare -A upgrade_list
for package in $php_packages; do
    new_package=$(echo "$package" | sed "s/[0-9]\+\.[0-9]\+/$target_version/")
    if apt-cache show "$new_package" &>/dev/null; then
        upgrade_list[$package]=$new_package
        echo "$package -> $new_package (Available)"
    else
        echo "$package -> $new_package (Not Found)"
    fi
done

# Ask user if they want to proceed
echo -n "Do you want to upgrade these packages? (y/n): "
read proceed
if [[ "$proceed" != "y" ]]; then
    echo "Upgrade canceled."
    exit 1
fi

# Upgrade packages
for old_pkg in "${!upgrade_list[@]}"; do
    new_pkg=${upgrade_list[$old_pkg]}
    echo "Upgrading $old_pkg -> $new_pkg"
    sudo apt install --only-upgrade -y "$new_pkg"
done

# Show the enabled PHP version for Apache
apache_php=$(readlink -f /etc/alternatives/php | grep -oP 'php[0-9]\.[0-9]+')
echo "Apache is currently using PHP version: $apache_php"

# Ask user if they want to change the PHP version for Apache
echo -n "Do you want to switch Apache to PHP $target_version? (y/n): "
read change_php
if [[ "$change_php" == "y" ]]; then
    sudo a2dismod "$apache_php"
    sudo a2enmod "php$target_version"
    sudo systemctl restart apache2
    echo "Apache has been switched to PHP $target_version and restarted."
fi

# List PHP packages that can be removed
old_php_packages=$(dpkg -l | awk -v ver="$target_version" '/^ii/ && /php/ && !index($2, ver){print $2}')
echo "The following PHP packages from old versions can be removed:"
echo "$old_php_packages"

# Ask user if they want to remove old PHP packages
echo -n "Do you want to remove these old PHP packages? (y/n): "
read remove_old
if [[ "$remove_old" == "y" ]]; then
    sudo apt remove --purge -y $old_php_packages
    sudo apt autoremove -y
    echo "Old PHP packages removed."
fi

echo "PHP upgrade process completed."

Setup

To use the script, follow these steps:

  1. Copy the script below.
  2. Open a terminal and create a new file:
    nano php_upgrade.sh
  3. Paste the script into the file.
  4. Save and exit (Press CTRL + X, then Y, then Enter).
  5. Make the script executable:
    chmod +x php_upgrade.sh
  6. Run the script with:
    sudo ./php_upgrade.sh
  7. Download the script:
    wget -O php_upgrade.sh https://yourwebsite.com/php_upgrade.sh
  8. Make the script executable:
    chmod +x php_upgrade.sh
  9. Run the script:
    sudo ./php_upgrade.sh

Usage

  1. The script will detect installed PHP versions and display them.
  2. It will prompt you to choose the PHP version you want to upgrade packages to.
  3. A list of packages that need upgrading will be shown, including availability.
  4. Confirm if you want to proceed with the upgrade.
  5. If needed, you can switch the active PHP version for Apache.
  6. The script will then list outdated PHP packages and ask if you want to remove them.
  7. After confirmation, it will uninstall unnecessary packages and clean up dependencies.

Notes

  • The script ensures that PHP packages are upgraded without breaking dependencies.
  • If you run a PHP-based application, check compatibility with the new version before upgrading.
  • Always back up your system before making major changes.