ubuntu 升级 16.04 to 20.04 实记

检查更新

$ sudo apt update

结果有Waring

W: An error occurred during the signature verification. The repository is not updated and the previous index files will be used. GPG error: https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu xenial InRelease: The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3F01618A51312F3F
W: Failed to fetch https://packages.gitlab.com/gitlab/gitlab-ce/ubuntu/dists/xenial/InRelease  The following signatures couldn't be verified because the public key is not available: NO_PUBKEY 3F01618A51312F3F
W: Some index files failed to download. They have been ignored, or old ones used instead.

重新获取最新的 gitlab Key

从官网查看解决方法:https://docs.gitlab.com/omnibus/update/package_signatures

# Download the new key
curl https://packages.gitlab.com/gpg.key -o /tmp/omnibus_gitlab_gpg.key

# Import the key
## Debian/Ubuntu/Raspbian
$ sudo apt-key add /tmp/omnibus_gitlab_gpg.key

# CentOS/OpenSUSE/SLES
$ sudo rpm --import /tmp/omnibus_gitlab_gpg.key

升级更新

$ sudo apt upgrade

安装发生中断

$ sudo apt-get upgrade
E: Could not get lock /var/lib/dpkg/lock-frontend - open (11: Resource temporarily unavailable)
E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), is another process using it?
$ sudo ps -eaf | grep -i apt
$ sudo lsof /var/lib/dpkg/lock-frontend
$ sudo kill -9 PID
$ sudo dpkg --configure -a

先升级到18.04

$ sudo do-release-upgrade
Checking for a new Ubuntu release
You have not rebooted after updating a package which requires a reboot. Please reboot before upgrading.

重启Server

$ sudo reboot

重新执行升级命令

$ sudo do-release-upgrade

升级完成后重启系统

System upgrade is complete.

Restart required

To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.

$ sudo reboot

重复前面的命令升级到20.04

$ sudo apt update
$ sudo apt upgrade
$ sudo do-release-upgrade

遇到了错误

Checking for a new Ubuntu release
Failed to connect to https://changelogs.ubuntu.com/meta-release-lts. Check your Internet connection or proxy settings
There is no development version of an LTS available.
To upgrade to the latest non-LTS develoment release
set Prompt=normal in /etc/update-manager/release-upgrades.

修改文件/etc/update-manager/meta-release中的https改为http

[METARELEASE]
URI = https://changelogs.ubuntu.com/meta-release
URI_LTS = http://changelogs.ubuntu.com/meta-release-lts
URI_UNSTABLE_POSTFIX = -development
URI_PROPOSED_POSTFIX = -proposed

遇到boot空间不足问题

Not enough free disk space

The upgrade has aborted. The upgrade needs a total of 137 M free
space on disk '/boot'. Please free at least an additional 14.5 M of
disk space on '/boot'. You can remove old kernels using 'sudo apt
autoremove' and you could also set COMPRESS=xz in
/etc/initramfs-tools/initramfs.conf to reduce the size of your
initramfs.

清理旧内核

$ uname -a
$ dpkg --get-selections | grep linux-image
$ sudo apt remove linux-image-xxx
$ sudo update-grub

重新执行升级命令

$ sudo do-release-upgrade

升级完成

原文地址:https://www.cnblogs.com/tianliupingzong/p/14005043.html