Issues upgrading PVE

hvnoclabs

New Member
Apr 2, 2021
11
1
3
26
Hi Proxmox community,

I am having an issue upgrading my OS with a "sudo apt-get upgrade" I've Googled/looked here according to the error message I see and I cannot make heads or tails.
When upgrading I see that the PVE kernel wants to be updated, but it needs to remove the old Debian kernels. When first trying to update I realized that this script was completely missing from my OS so I manually created it: /usr/share/pve-kernel-helper/scripts/functions

After placing that script there, I see there is a "Syntax" error and I am not sure why since I pulled the script from an already functioning PVE machine.
Could anyone point me in the right direction? I am trying to upgrade to the lastest version, here is my current version:

Linux PVE-Hypervisor 5.0.21-5-pve #1 SMP PVE 5.0.21-10 (Wed, 13 Nov 2019 08:27:10 +0100) x86_64 GNU/Linux




This is a log from "sudo apt-get upgrade"

Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
linux-image-4.19.0-10-amd64 linux-image-4.19.0-14-amd64
linux-image-4.19.0-16-amd64
The following packages will be upgraded:
libldb1 python-ldb
2 upgraded, 0 newly installed, 3 to remove and 0 not upgraded.
4 not fully installed or removed.
Need to get 173 kB of archives.
After this operation, 809 MB disk space will be freed.
Do you want to continue? [Y/n] y
Get:1 http://security.debian.org/debian-security buster/updates/main amd64 python-ldb amd64 2:1.5.1+really1.4.6-3+deb10u1 [38.1 kB]
Get:2 http://security.debian.org/debian-security buster/updates/main amd64 libldb1 amd64 2:1.5.1+really1.4.6-3+deb10u1 [135 kB]
Fetched 173 kB in 0s (1,936 kB/s)
Reading changelogs... Done
(Reading database ... 100991 files and directories currently installed.)
Removing linux-image-4.19.0-10-amd64 (4.19.132-1) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.19.0-10-amd64
/etc/kernel/postrm.d/pve-auto-removal:
/etc/kernel/postrm.d/pve-auto-removal: 103: /usr/share/pve-kernel-helper/scripts/functions: Syntax error: end of file unexpected (expecting ")")
run-parts: /etc/kernel/postrm.d/pve-auto-removal exited with return code 2
dpkg: error processing package linux-image-4.19.0-10-amd64 (--remove):
installed linux-image-4.19.0-10-amd64 package post-removal script subprocess returned error exit status 1
Removing linux-image-4.19.0-14-amd64 (4.19.171-2) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.19.0-14-amd64
/etc/kernel/postrm.d/pve-auto-removal:
/etc/kernel/postrm.d/pve-auto-removal: 103: /usr/share/pve-kernel-helper/scripts/functions: Syntax error: end of file unexpected (expecting ")")
run-parts: /etc/kernel/postrm.d/pve-auto-removal exited with return code 2
dpkg: error processing package linux-image-4.19.0-14-amd64 (--remove):
installed linux-image-4.19.0-14-amd64 package post-removal script subprocess returned error exit status 1
Removing linux-image-4.19.0-16-amd64 (4.19.181-1) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.19.0-16-amd64
/etc/kernel/postrm.d/pve-auto-removal:
/etc/kernel/postrm.d/pve-auto-removal: 103: /usr/share/pve-kernel-helper/scripts/functions: Syntax error: end of file unexpected (expecting ")")
run-parts: /etc/kernel/postrm.d/pve-auto-removal exited with return code 2
dpkg: error processing package linux-image-4.19.0-16-amd64 (--remove):
installed linux-image-4.19.0-16-amd64 package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-4.19.0-10-amd64
linux-image-4.19.0-14-amd64
linux-image-4.19.0-16-amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)


Thanks!
 
Same result:

[sudo] password for PVE-Hypervisor:
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be REMOVED:
linux-image-4.19.0-10-amd64
The following packages will be upgraded:
libldb1 python-ldb
2 upgraded, 0 newly installed, 1 to remove and 0 not upgraded.
4 not fully installed or removed.
Need to get 0 B/96.9 MB of archives.
After this operation, 269 MB disk space will be freed.
Do you want to continue? [Y/n] y
Reading changelogs... Done
(Reading database ... 100991 files and directories currently installed.)
Removing linux-image-4.19.0-10-amd64 (4.19.132-1) ...
/etc/kernel/postrm.d/initramfs-tools:
update-initramfs: Deleting /boot/initrd.img-4.19.0-10-amd64
/etc/kernel/postrm.d/pve-auto-removal:
/etc/kernel/postrm.d/pve-auto-removal: 103: /usr/share/pve-kernel-helper/scripts/functions: Syntax error: end of file unexpected (expecting ")")
run-parts: /etc/kernel/postrm.d/pve-auto-removal exited with return code 2
dpkg: error processing package linux-image-4.19.0-10-amd64 (--remove):
installed linux-image-4.19.0-10-amd64 package post-removal script subprocess returned error exit status 1
Errors were encountered while processing:
linux-image-4.19.0-10-amd64
E: Sub-process /usr/bin/dpkg returned an error code (1)
 
/etc/kernel/postrm.d/pve-auto-removal: 103: /usr/share/pve-kernel-helper/scripts/functions: Syntax error: end of file unexpected (expecting ")")
seems some file is corrupted... can you post both those files?
 
Sure here they are:

pve-auto-removal:
#! /bin/sh
set -e

. /usr/share/pve-kernel-helper/scripts/functions

eval "$(apt-config shell APT_CONF_D Dir::Etc::parts/d)"
test -n "${APT_CONF_D}" || APT_CONF_D="/etc/apt/apt.conf.d"

config_file="${APT_CONF_D}/76pveconf"

generate_apt_config() {

kernels="$(kernel_keep_versions "$@")"

cat <<- EOF
// DO NOT EDIT! File autogenerated by $0
APT::NeverAutoRemove
{
EOF
for kernel in $kernels; do
escaped_kver="$(echo "$kernel" | sed -e 's#\([\.\+]\)#\\\1#g')"
echo " \"^pve-kernel-${escaped_kver}$\";"
done
echo '};'
if [ "${APT_AUTO_REMOVAL_KERNELS_DEBUG:-false}" = 'true' ]; then
cat <<-EOF
/* Debug information:
# dpkg list:
$(dpkg -l | grep -F 'pve-kernel' || true)
# list of installed kernel packages:
$kernels
*/
EOF
fi
}

generate_apt_config "$@" > "${config_file}.dpkg-new"
mv -f "${config_file}.dpkg-new" "$config_file"
chmod 444 "$config_file"



And here is Fuctions:

#! /bin/sh
set -e

ESP_LIST="/etc/kernel/pve-efiboot-uuids"
ESPTYPE='c12a7328-f81f-11d2-ba4b-00a0c93ec93b'

MANUAL_KERNEL_LIST="/etc/kernel/pve-efiboot-manual-kernels"

# relative to the ESP mountpoint
PMX_ESP_DIR="EFI/proxmox"
PMX_LOADER_CONF="loader/loader.conf"

# adapted from /etc/kernel/postinst.d/apt-auto-removal as present in
# debian's apt package:
#
# Mark as not-for-autoremoval those kernel packages that are:
# - the currently booted version, if still installed
# - the kernel version we've been called for
# - the latest kernel version (as determined by debian version number)
# - the second-latest kernel version
# - the latest kernel version of each series (e.g. 4.13, 4.15, 5.0) by
# marking the meta-packages

kernel_keep_versions() {
eval "$(apt-config shell DPKG Dir::bin::dpkg/f)"
test -n "$DPKG" || DPKG="/usr/bin/dpkg"

list="$("${DPKG}" -l | awk '/^[ih][^nc][ ]+pve-kernel-[0-9]+\./ && $2 !~ /-dbg:).*)?$/ && $2 !~ /-dbgsym:).*)?$/ { print $2; }' \
| sed -e 's#^pve-kernel-##' -e 's#:[^:]\+ # #')"

sorted_list="$(echo "$list" | sort --unique --reverse --version-sort)"

[ -n "$1" ] && install_version="$1"

running_version="$(uname -r | tr 'A-Z' 'a-z')"

# ignore the currently running version if attempting a reproducible build
if [ -n "${SOURCE_DATE_EPOCH}" ]; then
running_version=""
elif [ ! -e "/boot/vmlinuz-$running_version" ]; then
# ignore the current version if it got removed, the "auto-remove" logic
# will not be affected, because either it is installed and thus we keep
# it in the list, or it's already removed anyway
running_version=""
fi

latest_2_versions="$(echo "$sorted_list" | grep -E '^[^ ]+-pve' | head -n2 )"

series_metapackages="$(echo "$sorted_list" | grep -Ev '^[^ ]+-pve' | head -n2)"

oldseries="$(echo "$series_metapackages" | tail -n1)"
oldseries_latest_kernel="$(echo "$sorted_list" | grep -E "^${oldseries}\.[^ ]+-pve" | head -n1 )"

if [ -e "$MANUAL_KERNEL_LIST" ]; then
manual_kernels="$(cat "$MANUAL_KERNEL_LIST")"
fi

kernels="$(cat <<-EOF
$running_version
$install_version
$manual_kernels
$latest_2_versions
$series_metapackages
$oldseries_latest_kernel
EOF
)"

echo "$kernels" | sort -u | sed -e '/^$/ d'
}

#bootable kernels are the same as the no_autoremove ones without the meta-package
boot_kernel_list() {
list="$(kernel_keep_versions "$@")"

echo "$list" | grep -vE '^[0-9]+\.[0-9]+$' || true
}

warn() {
echo "$@" 1>&2
}

reexec_in_mountns() {
if [ -z "$PVE_EFIBOOT_UNSHARED" ]; then
export PVE_EFIBOOT_UNSHARED=1
echo "Re-executing '$0' in new private mount namespace.."
unshare --mount --propagation private "$0" "$@"
exit 0
fi
}

loop_esp_list() {
if [ ! -e ${ESP_LIST} ]; then
return 2
fi

cat "${ESP_LIST}" | while IFS= read -r curr_uuid; do
if [ -z "$curr_uuid" ]; then
continue
fi
"$@"
done
}
 
I have a few VMs installed in Proxmox but nothing major... should I uninstall it then re-install to the latest since it seems corrupt?
If I uninstall will it save the VMs since they are QEMU? I'm hoping I can remove the current version and just update the kernel with the latest.
 
can you please either attach the files directly, or post it with a 'code' tag?

otherwise it garbles some things (e.g. the smilies) and it is not clear if there is something wrong there or not
 
Alright I have attached both script files. (Named after scripts)
 

Attachments

  • pve-auto-removal.txt
    1.1 KB · Views: 11
  • functions.txt
    5 KB · Views: 12
Yeah someone please advise since I cannot remove Proxmox from the system.. Something is very stuck and broken, I guess that's what happens when there is a older Kernel.
 
@hvnoclabs
I'm facing the same issue, if I find the answer - I'll post it here
EDIT:
I think I found it.
Edit this file:
Bash:
nano /usr/share/pve-kernel-helper/scripts/functions
And take a look around line 65 and remove all spaces/tabs before word EOF, like so:
BEFORE:
Bash:
        kernels="$(cat <<-EOF
                $running_version
                $install_version
                $manual_kernels
                $latest_2_versions
                $series_metapackages
                $oldseries_latest_kernel
                EOF
                )"
AFTER:
Bash:
        kernels="$(cat <<-EOF
                $running_version
                $install_version
                $manual_kernels
                $latest_2_versions
                $series_metapackages
                $oldseries_latest_kernel
EOF
                )"

It allowed me to move on, but I faced another problem:
Bash:
/etc/initramfs/post-update.d//pve-efiboot-sync: 10: /etc/initramfs/post-update.d//pve-efiboot-sync: /usr/sbin/pve-efiboot-tool: not found
run-parts: /etc/initramfs/post-update.d//pve-efiboot-sync exited with return code 127
dpkg: error processing package initramfs-tools (--configure):
installed initramfs-tools package post-installation script subprocess returned error exit status 1
Errors were encountered while processing:
initramfs-tools
E: Sub-process /usr/bin/dpkg returned an error code (1)

EDIT2:
I've just copied content from another proxmox and pasted it inside
Bash:
/usr/sbin/pve-efiboot-tool
then
Bash:
chmod 777 /usr/sbin/pve-efiboot-tool
(777 is likely dangerous, I know it)
And then just installed what I wanted with no problem.
 
Last edited:
I'll take a look. Also for your setup check that you have pve-efiboot-sync, if I recall I didn't have this script and I needed to manually add it.
 
Oh my goodness it worked! I just changed the positioning of EOF in the "functions" script. I will now need to work on the full upgrade.
So far so good!
 
  • Like
Reactions: logiczny

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!