如何将Ubuntu从16.04升级到18.04

如何将Ubuntu从16.04升级到18.04

2018-08-17阅读 6K0

 

Ubuntu 18.04是一个长期支持(LTS)版本,LTS 版本每两年发布一次,而 Ubuntu 18.04 是自 2016 年以来的第一个长期支持版本。Ubuntun 长期支持版本可以获得 Canonical 官方长达五年的技术支持,这意味着在 2023 年之前所有用户都可以放心使用 Ubuntu 18.04 LTS。。本教程将展示如何将您的CVM从Ubuntu 16.04(Xenial Xerus)或Ubuntu 17.10(Artful Aardvark)升级到Ubuntu 18.04(Bionic Beaver) )。

准备

本教程需要一台已经设置好可以使用sudo命令的非root账号的CentOS服务器,并且已开启防火墙。没有服务器的同学可以在这里购买,不过我个人更推荐您使用免费的腾讯云开发者实验室进行试验,学会安装后在购买服务器。所有步骤需要root权限。请务必以root身份或使用sudo运行以下步骤。

本教程的以下步骤将:

  1. 安装Ubuntu 16.04的更新。
  2. 备份您的数据。
  3. 确保您使用的内核版本是最新版本。
  4. 停止非关键服务。
  5. 启动LISH会话以确保安装不会中断。

安装可用更新

更新包列表并安装所有更新:

apt update && apt upgrade

备份CVM

在执行重大升级之前请备份您的CVM。如果在升级过程中出现任何问题,您可以从备份恢复。我们建议您在升级到Ubuntu 18.04 LTS之前手动快照。如果您使用其他备份服务或应用程序,我们建议您在继续之前进行手动备份。

停止服务

我们建议您在升级到Ubuntu 18.04 LTS之前尽可能多的停止无关服务。这包括Web服务器守护程序(Apache和NGINX),数据库服务器(PostgreSQL和MySQL)以及任何其他非关键服务。

  • 获取当前在您的系统上运行的服务列表:
systemctl | grep running
  • 要停止服务,请输入以下命令,比如我要停止apache运行,则用下面的命令,替换为要停止的服务apache2的名称:
systemctl stop apache2

您现在可以在您的CVM上安装Ubuntu 18.04 LTS了。

从Ubuntu 16.04 LTS升级到Ubuntu 18.04 LTS

接下来,请在会话中执行以下步骤:

安装update-manager-core包:

apt install update-manager-core

打开/etc/update-manager/release-upgrades并验证该Prompt值是lts在Ubuntu 16.04或normalUbuntu 17.10上设置的:

/etc/update-manager/release-upgrades

# Default behavior for the release upgrader.
​
[DEFAULT]
# Default prompting behavior, valid options:
#
#  never  - Never check for 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 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 this option should not be
#           used if the currently-running release is not itself an LTS
#           release, since in that case the upgrader won't be able to
#           determine if a newer release is available.
Prompt=lts

您现在已准备好开始升级到Ubuntu 18.04 LTS。Ubuntu鼓励将LTS发行版升级为带.1的版本(例如18.04.1),使用-d选项强制它识别新版本:

do-release-upgrade -d

按照屏幕上的说明完成安装过程。

由于CVM为Ubuntu提供了内部包镜像,因此您可能会看到以下的某些消息:

  • 找不到有效的镜像
While scanning your repository information no mirror entry for the
upgrade was found. This can happen if you run an internal mirror or
if the mirror information is out of date.
​
Do you want to rewrite your 'sources.list' file anyway? If you choose
'Yes' here it will update all 'trusty' to 'xenial' entries.
If you select 'No' the upgrade will cancel.
​
Continue [yN]

键入y回车继续。

  • 安装包不再支持
3 installed packages are no longer supported by Canonical. You can
still get support from the community.
​
2 packages are going to be removed. 91 new packages are going to be
installed. 346 packages are going to be upgraded.
​
You have to download a total of 239 M. This download will take about
30 minutes with a 1Mbit DSL connection and about 9 hours with a 56k
modem.
​
Fetching and installing the upgrade can take several hours. Once the
download has finished, the process cannot be canceled.
​
Continue [yN] Details [d]

d阅读详细信息(然后按q退出详细信息),或按y继续。

  • 配置openssh-server:按enter键选择keep the local version currently installed

 

  • 删除过时的安装包?:输入y

升级将重新启动。输入y继续:

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]

系统重新启动后,验证它是否正在运行Ubuntu 18.04:

lsb_release -a

您应该看到类似于以下内容的输出:

No LSB modules are available.
Distributor ID: Ubuntu
Description:  Ubuntu 18.04 LTS
Release:  18.04
Codename: bionic

您的CVM现在将运行Ubuntu 18.04 LTS。

从旧的Ubuntu版本升级

如果您的Linode运行的是早于16.04 LTS的Ubuntu版本,请首先升级到Ubuntu 16.04 LTS。然后,您可以将您的CVM升级到Ubuntu 18.04 LTS。你可以参考如何将Ubuntu升级到18.04最新版我们的另一篇教程文章。更多Linux教程请前往腾讯云+社区学习更多知识。


参考文献:《How to Upgrade to Ubuntu 18.04 LTS (Bionic Beaver)》

原创声明,本文系作者授权云+社区发表,未经许可,不得转载。

如有侵权,请联系 yunjia_community@tencent.com 删除。

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值