Distribution Upgrade

最後更新: 2020-08-24

 


準備

 

# 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

 

 


Upgrade Ubuntu server from 20.04 to 22.04

 

 

修改 /etc/apt/sources.list

deb http://hk.archive.ubuntu.com/ubuntu/ jammy main restricted universe multiverse
deb http://hk.archive.ubuntu.com/ubuntu/ jammy-updates main restricted universe multiverse
deb http://security.ubuntu.com/ubuntu jammy-security main restricted universe multiverse

apt-get update

apt-get upgrade

reboot

apt install update-manager-core    # 必須成功安裝, 否則不應下一步

apt-get dist-upgrade

reboot

apt-auto autoremove --purge

 


Upgrade Ubuntu server from 16.04 to 18.04

 

修改 /etc/apt/sources.list

deb http://hk.archive.ubuntu.com/ubuntu bionic main restricted universe
deb http://hk.archive.ubuntu.com/ubuntu/ bionic-updates main restricted universe
deb http://security.ubuntu.com/ubuntu bionic-security main restricted universe

# 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