Skip to content

Instantly share code, notes, and snippets.

@ohmantics
Created May 22, 2025 00:51
Show Gist options
  • Save ohmantics/bf3821d5e988ab7ee9a941e23031ca5e to your computer and use it in GitHub Desktop.
Save ohmantics/bf3821d5e988ab7ee9a941e23031ca5e to your computer and use it in GitHub Desktop.
Upgrade Proxmox that uses zectl to set boot environments (with ZFSBootMenu to pick amongst them)
#!/bin/bash
set -e
if [[ $# -ne 1 ]]; then
echo 'Too many/few arguments, expecting one (new bootenv name)' >&2
exit 1
fi
name=$1
#echo "***CREATING***"
zectl create "${name}"
#echo "***MOUNTING***"
mountpoint="$(zectl mount ${name})"
pushd "${mountpoint}" > /dev/null
mount -t proc /proc proc/
mount --rbind /dev dev/
mount --rbind /sys sys/
mount --make-rslave dev/
mount --make-rslave sys/
popd
#echo "***UPGRADING***"
chroot "${mountpoint}" apt dist-upgrade
#echo "***UNMOUNTING***"
umount -R "${mountpoint}"/proc
umount -R "${mountpoint}"/dev
umount -R "${mountpoint}"/sys
zectl unmount "${name}"
rmdir "${mountpoint}"
#echo "***DONE***"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment