[生命周期]
1804 LTS -> 2023年4月
2004 LTS -> 2025年4月
2204 -> 2027年4月
[升级路径]
1804 -> 2004 -> 2204
鉴于2204还不是LTS,因此本次没有直接升级到此版本。
[升级步骤]
cat /etc/os-release
NAME="Ubuntu"
VERSION="18.04.6 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.6 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic
sudo apt update
sudo apt upgrade -y
sudo apt dist-upgrade
A. 移除任何被自动安装的,但是不再被任何包所依赖的软件包:
sudo apt --purge autoremove
※ 我比较懒,一般不操作此步骤…
sudo apt install update-manager-core
A. do-release-upgrade是update-manager-core软件包的一部分,没有就手工执行一下吧。
sudo do-release-upgrade -d
A. 如果没有执行步骤3,可能会遇到如下提示:
Checking for a new Ubuntu release
Please install all available updates for your release before upgrading.
B. 如下提示后,可以执行步骤6
Checking for a new Ubuntu release
You have not rebooted after updating a package which requires a reboot. Please reboot before upgrading.
sudo reboot
sudo do-release-upgrade -d
System upgrade is complete.
Restart required
To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.
Continue [yN] y
A. 过程期间,将需要针对提示进行操作。正常来说,确认回车即可;
B. 可能会遇到ubuntu源无法升级的情况,请更换国内其它的源。
#备份源
sudo cp -a /etc/apt/sources.list /etc/apt/sources.list.bak
#切换阿里云源
sudo vi sources.list
:%d 删除所有内容并替换如下内容
deb http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-backports main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
deb-src http://mirrors.aliyun.com/ubuntu/ bionic-proposed main restricted universe multiverse
#更新资源文件
sudo apt-get update
cat /etc/os-release
----
NAME="Ubuntu"
VERSION="20.04.5 LTS (Focal Fossa)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 20.04.5 LTS"
VERSION_ID="20.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=focal
UBUNTU_CODENAME=focal
----
[风险预判]