本文使用「署名 4.0 国际 (CC BY 4.0)」许可协议,欢迎转载、或从新修改使用,但须要注明来源。 署名 4.0 国际 (CC BY 4.0)html
本文做者: 苏洋linux
建立时间: 2020年04月25日 统计字数: 6119字 阅读时间: 13分钟阅读 本文连接: soulteary.com/2020/04/25/…docker
本文将介绍如何在当前时间点,将服务器版本的 Ubuntu 18.04 LTS 升级为最新的 Ubuntu 20.04 LTS,以及升级过程当中的一些细节,但愿能帮到跃跃欲试的 Ubuntu 同好。编程
将数据进行备份等操做须要自行处理,另外确保网络稳定,建议都在服务器跳板机上进行操做,更为稳妥。ubuntu
当前这篇内容已经运行在 Ubuntu 20.04 LTS 系统环境中,:)bash
先使用 apt update
看看有哪些内容能够升级。服务器
apt update
Hit:1 http://mirrors.aliyun.com/ubuntu bionic InRelease
Get:2 http://mirrors.aliyun.com/ubuntu bionic-updates InRelease [88.7 kB]
Get:3 http://mirrors.aliyun.com/ubuntu bionic-security InRelease [88.7 kB]
Get:4 http://mirrors.aliyun.com/ubuntu bionic-updates/universe Sources [281 kB]
Get:5 http://mirrors.aliyun.com/ubuntu bionic-updates/main Sources [315 kB]
Get:6 http://mirrors.aliyun.com/ubuntu bionic-updates/main amd64 Packages [915 kB]
Get:7 http://mirrors.aliyun.com/ubuntu bionic-updates/main i386 Packages [669 kB]
Get:8 http://mirrors.aliyun.com/ubuntu bionic-updates/main Translation-en [315 kB]
Get:9 http://mirrors.aliyun.com/ubuntu bionic-updates/universe i386 Packages [1,014 kB]
Get:10 http://mirrors.aliyun.com/ubuntu bionic-updates/universe amd64 Packages [1,065 kB]
Get:11 http://mirrors.aliyun.com/ubuntu bionic-updates/universe Translation-en [331 kB]
Hit:12 https://download.docker.com/linux/ubuntu bionic InRelease
Get:13 http://mirrors.aliyun.com/ubuntu bionic-security/universe Sources [168 kB]
Get:14 http://mirrors.aliyun.com/ubuntu bionic-security/main Sources [146 kB]
Get:15 http://mirrors.aliyun.com/ubuntu bionic-security/main amd64 Packages [692 kB]
Get:16 http://mirrors.aliyun.com/ubuntu bionic-security/main i386 Packages [459 kB]
Get:17 http://mirrors.aliyun.com/ubuntu bionic-security/universe amd64 Packages [657 kB]
Get:18 http://mirrors.aliyun.com/ubuntu bionic-security/universe i386 Packages [618 kB]
Fetched 7,823 kB in 3s (3,106 kB/s)
Reading package lists... Done
Building dependency tree
Reading state information... Done
19 packages can be upgraded. Run 'apt list --upgradable' to see them.
复制代码
接着执行 apt upgrade -y
耐心等待软件升级完毕便可。若是你最近已经更新过,则会获得相似下面的内容提示。网络
apt update
Reading package lists... Done
Building dependency tree
Reading state information... Done
All packages are up to date.
复制代码
若是你以为升级过程当中软件源比较慢,能够尝试替换源,好比像下面这样操做。ionic
sed -i -e "s/mirrors.cloud.aliyuncs.com/mirrors.tuna.tsinghua.edu.cn/" /etc/apt/sources.list
复制代码
当咱们执行 do-release-upgrade
尝试进行升级的时候,可能会出现三种状况告诉咱们不可以升级。ui
当你执行完毕命令后,可能会获得“Please install all available updates for your release before upgrading”的提示,这说明你其实并未将全部软件都完成升级。
do-release-upgrade
Checking for a new Ubuntu release
Please install all available updates for your release before upgrading.
复制代码
你可能会好奇,我明明执行过 update
和 upgrade
了,为何还会出现这种状况呢?
这里有一个很大的多是,使用过 apt-mark 将部分软件版本锁定,须要先执行解锁操做,好比:
apt-mark unhold docker-ce
复制代码
至于如何看到须要升级或者解锁的软件呢?
可使用 apt update && apt list --upgradable
命令进行查询:
apt list --upgradable
...
Reading package lists... Done
Building dependency tree
Reading state information... Done
1 package can be upgraded. Run 'apt list --upgradable' to see it.
...
Listing... Done
docker-ce/bionic 5:19.03.8~3-0~ubuntu-bionic amd64 [upgradable from: 5:19.03.6~3-0~ubuntu-bionic]
N: There are 23 additional versions. Please use the '-a' switch to see them.
复制代码
而后在再次执行 apt upgrade -y
便可完成全部软件升级。
可是千万别高兴太早,由于你还可能遇到接下来的事情。
当全部软件都升级就绪后,继续使用 do-release-upgrade
升级软件,会看到相似下面的提示。
do-release-upgrade
Checking for a new Ubuntu release
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.
复制代码
这里由于官网还没有正式打开版本推送,因此若是要想获得版本更新,须要对 do-release-upgrade
添加命令行参数 -d
,来容许获取最新的升级包。
Usage: do-release-upgrade [options]
Options:
-d, --devel-release If using the latest supported release, upgrade to the
development release
复制代码
若是你是 Ubuntu 18.04 LTS 用户的话,此刻咱们须要作出一个决定,是一个版本一个版本升级,仍是直接跨版本升级,而若是是 Ubuntu 19.10 的用户则简单的多,由于不涉及跨版本问题,逐版本升级后半部份内容便可。
咱们详细说说两种升级方式。
有一句流传甚远的话叫作“步子不能迈的太大”,某些时候也能够用在软件升级这件事上。
打开 /etc/update-manager/release-upgrades
文件,咱们能够看到文件说明:
[DEFAULT]
# Default prompting behavior, valid options:
#
# never - Never check for, or allow upgrading to, a new release.
# normal - Check to see if a new release is available. If more than one new
# release is found, the release upgrader will attempt to upgrade to
# the supported release that immediately succeeds the
# currently-running release.
# lts - Check to see if a new LTS release is available. The upgrader
# will attempt to upgrade to the first LTS release available after
# the currently-running one. Note that if this option is used and
# the currently-running release is not itself an LTS release the
# upgrader will assume prompt was meant to be normal.
Prompt=lts
复制代码
将 Prompt=lts
修改成 Prompt=normal
,而后执行 do-release-upgrade -d
,会开始第一阶段升级:
do-release-upgrade -d
Checking for a new Ubuntu release
Get:1 Upgrade tool signature [1,554 B]
Get:2 Upgrade tool [1,329 kB]
Fetched 1,331 kB in 0s (0 B/s)
authenticate 'eoan.tar.gz' against 'eoan.tar.gz.gpg'
extracting 'eoan.tar.gz'
Reading cache
...
复制代码
根据实际状况,咱们“一路 Next”以后,在即将完成升级时,会看到下面的提示内容:
。。。
System upgrade is complete.
Restart required
To finish the upgrade, a restart is required.
If you select 'y' the system will be restarted.
复制代码
待系统重启以后,登录系统会看到系统已经成功升级为 Ubuntu 19.10:
Welcome to Ubuntu 19.10 (GNU/Linux 5.3.0-46-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
* Ubuntu 20.04 LTS is out, raising the bar on performance, security,
and optimisation for Intel, AMD, Nvidia, ARM64 and Z15 as well as
AWS, Azure and Google Cloud.
https://ubuntu.com/blog/ubuntu-20-04-lts-arrives
复制代码
咱们将 /etc/update-manager/release-upgrades
文件中数值修改成 Prompt=lts
,再次执行 do-release-upgrade -d
就能够开始第二阶段的升级了,操做过程和上面没有区别,一杯水的功夫,服务端再次重启,Ubuntu 20.04 LTS 就升级完毕啦。
Welcome to Ubuntu 20.04 LTS (GNU/Linux 5.4.0-26-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
* Ubuntu 20.04 LTS is out, raising the bar on performance, security,
and optimisation for Intel, AMD, Nvidia, ARM64 and Z15 as well as
AWS, Azure and Google Cloud.
https://ubuntu.com/blog/ubuntu-20-04-lts-arrives
复制代码
验证完毕逐版本升级,咱们试试一步到位的跨版本升级。
跨版本升级至关因而逐版本升级的“偷懒版”,偷懒固然要到极致,升级软件包也可使用 apt full-upgrade -y
这个命令来作。
和逐版本升级不一样的是,咱们再也不须要修改 release-upgrades
配置文件,在升级前只须要确认 /etc/update-manager/release-upgrades
文件的数值是否设置为 lts
便可。
确认数值正确后,执行 do-release-upgrade -d
,根据本身需求进行升级配置选择便可,“一路 Next” 以后,Ubuntu 20.04 就升级完毕啦。
距离将全部机器升级到 18.04 刚巧一年, Ubuntu 20.04 LTS 的到来,算是一个惊喜。
通常状况下,咱们使用 update
, upgrade
, do-release-upgrade
组合技应该就能顺畅完成升级,可是在当前时间点,官网还未彻底正式提供 release 升级方案,因此就有了这篇文章。
呃,促成这篇文章还有一个缘由,回家后直接睡觉忘记喂猫,被毛孩子抗议叫醒...
--EOF
我如今有一个小小的折腾群,里面汇集了一些喜欢折腾的小伙伴。
在不发广告的状况下,咱们在里面会一块儿聊聊软件、HomeLab、编程上的一些问题,也会在群里不按期的分享一些技术沙龙的资料。
喜欢折腾的小伙伴欢迎扫码添加好友。(请注明来源和目的,不然不会经过审核)