Distribution Upgrade

最後更新: 2020-08-24

 


Upgrade Ubuntu server from 16.04 to 18.04

 

# Check Current Version of Ubuntu Server

lsb_release -a

No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04.2 LTS
Release:        16.04
Codename:       xenial

# Check Current Kernel Version

uname -a

# Update & Install manager core package

apt-get update

apt-get upgrade

apt-get install update-manager-core

# 先升級部分 Package

apt-get dist-upgrade

# 再 Upgrade 其餘部分

# 此 CLI 只會 upgrade 下一 LTS (假設現在是 16.04, 它只會升上 18.04 而不會跳到 20.04)

do-release-upgrade

apt-auto autoremove

升級後測試

reboot             # 必須的 !

 * 由於升級過程會更新 bootloader (grub), 最好手上有 Rescue CD 以防萬一

升級過程

#Q1: 問你是否要 upgrade

Answer ” Y ” to upgrade.

#Q2: Disable SSH password authentication for root?”

升級期間建議另外開啟一個 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'

/usr/sbin/sshd -o PidFile=/var/run/release-upgrader-sshd.pid -p 1022

 

Creative Commons license icon Creative Commons license icon