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

升級完成


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM