- 先决条件
- 备份您的数据
- 更新当前安装的软件包
- 将 Ubuntu 16.04 升级到 Ubuntu 18.04
- 确认更新
最新的 Ubuntu LTS 版本 Ubuntu 18.04 (Bionic Beaver) 于 2018 年 4 月 26 日发布,它将支持 5 年,直到 2023 年 4 月。在本教程中,我们将向您展示如何升级 Ubuntu 16.04 或更高版本的安装到 Ubuntu 18.04(仿生海狸)。
先决条件
在开始本教程之前,请确保您以具有 sudo 权限的用户身份登录 。
备份您的数据
首先,确保在开始对操作系统进行重大升级之前备份数据。如果您在虚拟机上运行 Ubuntu,最好拍摄完整的系统快照,以便您可以轻松恢复您的机器,以防更新失败。
更新当前安装的软件包
在开始版本升级之前,建议将您当前安装的所有软件包更新到最新版本。
代码语言:javascript复制sudo apt update
sudo apt upgrade
我们还将运行dist-upgrade
它将对已安装的软件包执行主要版本升级,并可能删除一些不必要的软件包:
sudo apt dist-upgrade
将 Ubuntu 16.04 升级到 Ubuntu 18.04
Ubuntu 提供了一个名为的工具do-release-upgrade
,它使升级过程非常简单。
该工具应该已经安装在您的系统上,但如果由于某种原因未安装它,您可以使用以下命令安装它:
sudo apt install update-manager-core
要开始升级运行do-release-upgrade
:
sudo do-release-upgrade
如果您像我一样通过 SSH 升级系统,系统会询问您是否要继续。
Reading cache
Checking package manager
Continue running under SSH?
This session appears to be running under ssh. It is not recommended
to perform an upgrade over ssh currently because in case of failure it
is harder to recover.
If you continue, an additional ssh daemon will be started at port
'1022'.
Do you want to continue?
Continue [yN]
Starting additional sshd
To make recovery in case of failure easier, an additional sshd will
be started on port '1022'. If anything goes wrong with the running
ssh you can still connect to the additional one.
If you run a firewall, you may need to temporarily open this port. As
this is potentially dangerous it's not done automatically. You can
open the port with e.g.:
'iptables -I INPUT -p tcp --dport 1022 -j ACCEPT'
To continue please press [ENTER]
升级工具下载软件包列表并计算更改后,它会询问您是否要继续。
代码语言:javascript复制Do you want to start the upgrade?
4 installed packages are no longer supported by Canonical. You can
still get support from the community.
3 packages are going to be removed. 90 new packages are going to be
installed. 397 packages are going to be upgraded.
You have to download a total of 267 M. This download will take about
1 minute with your connection.
Installing the upgrade can take several hours. Once the download has
finished, the process cannot be canceled.
再次键入y,升级过程将开始。
在升级过程中,你会被问到各种问题,比如你是要保留现有的配置文件还是要安装包维护者的版本。如果您没有对文件进行任何自定义更改,那么输入应该是安全的,Y否则以保持当前配置 enter N.
代码语言:javascript复制Configuration file '/etc/sysctl.conf'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** sysctl.conf (Y/I/N/O/D/Z) [default=N] ?
升级过程可能需要一些时间,具体取决于更新数量和您的 Internet 速度。
安装新软件包后,更新工具会询问您是否要删除过时的软件,如果您不确定键入d并检查过时的软件包列表,在大多数情况下,输入y并删除所有过时的软件包是安全的:
代码语言:javascript复制Searching for obsolete software
Reading package lists... Done
Building dependency tree
Reading state information... Done
Reading state information... Done
Remove obsolete packages?
17 packages are going to be removed.
一旦升级过程完成并假设一切顺利,您将被要求重新启动机器。输入y以继续:
代码语言:javascript复制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
确认更新
稍等片刻,直到您的服务器重新启动,然后重新连接。登录后,您将收到以下消息:
代码语言:javascript复制Welcome to Ubuntu 18.04 LTS (GNU/Linux 4.15.0-20-generic x86_64)
您还可以使用以下命令检查 Ubuntu 版本:
代码语言:javascript复制lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 18.04 LTS
Release: 18.04
Codename: bionic
就是这样,您现在可以享受新的 Ubuntu 18.04 LTS (Bionic Beaver)。