KAGOYA(カゴヤ)のVPSでUbuntuを18.04にアップグレードしよう

2018/08/16UbuntuUbuntu, VPS

前々回前回からの続き。

今回はUbuntuを18.04へアップグレードします。

それでは行ってみましょう。

事前準備

update-manager-coreの確認

まずはupdate-manager-coreがインストールされているかを確認。

hugahuga@hogehoge-vps:~$ dpkg -l |grep update-manager-core
ii  update-manager-core  1:16.04.13  all  manage release upgrades

もしインストールされていなければ、

sudo apt install update-manager-core

でインストールしてください。

続いて設定の確認

hugahuga@hogehoge-vps:~$ sudo cat /etc/update-manager/release-upgrades

Prompt=lts

Promptがlts、もしくはnormalになっていればオッケーです。
ltsの場合は、LTSがリリースされた時だけアップグレード。
normalは、新しいリリースがされ次第アップグレードできるようになります。

今回は16.04 LTSからのアップグレードなのでltsで問題ないですが、17.10等を使用している場合はnormalでないと更新できない場合があるので注意してください。

Prompt=normal or lts

こんな感じで、両方対応でもオッケーです。

Port 1022 TCPの開放

作業途中に何らかの原因でsshが途切れてしまった場合に、緊急用に接続するためのポートが1022になります。
ufw等で許可に指定しておかないとssh接続できなくなってしまうので、予めポート開放しておきます。
(可能であればsshではなくコンソールからの作業が推奨です)

sudo ufw allow 1022

それではアップグレードいってみよう

アップグレードコマンドの実行

準備ができたらアップグレードを実行します。

sudo do-release-upgrade -d

ここから先は、画面の指示に従って選択肢を選んで行きます。
ご利用中の環境によって選択は変わってきますので、参考程度に留めてください。

Reading cache

Checking package manager

Continue running under SSH? 

This session appears to be running under ssh. It is not recommended 
to perform a 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]

先述のssh接続への注意事項ですね。
1022番ポートを開放済であれば先に進みます。

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]

ENTERを押して進みます。

4 installed packages are no longer supported by Canonical. You can 
still get support from the community. 

3 packages are going to be removed. 113 new packages are going to be 
installed. 416 packages are going to be upgraded. 

You have to download a total of 277 M. This download will take about 
35 minutes with a 1Mbit DSL connection and about 10 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]

yを押して同意。

/etc/default/grubの設定

しばらく経つとこんな表示がでます。

/etc/default/grubの設定内容をどうしますか?
ってことが書いてあります。

#新しい設定で上書き
install the package maintainer's version

#以前の設定を残す
keep the local version currently installed

#差分の確認
show the differences between the versions

今回は特に設定した項目も無いので

install the package maintainer's version

を選びます。

何かしらの設定をしてあったり、不安な場合は

keep the local version currently installed

差分の確認は適宜行ってください。

/etc/ssh/sshd_configの設定

またしばらく経つと、今度はこんな画面になります。

先程の同様で、今度は/etc/ssh/sshd_configの設定内容をどうしますか?
ってことが書いてあります。

これはヤバイですね。
間違って上書きしたら、折角の設定がパーになってしまいます。

keep the local version currently installed

基本的にはkeep一択で。
もしくは差分を確認して必要箇所を書き換えてください。

パッケージ削除の確認

続いては、使われなくなったパッケージの削除について。
問題なければyで続行。

Remove obsolete packages? 

34 packages are going to be removed. 

 Continue [yN]  Details [d]

再起動の確認

Restart required 

To finish the upgrade, a restart is required. 
If you select 'y' the system will be restarted. 

Continue [yN]

ここまで来れば、ほとんど完了。
yで再起動してください。

Ubuntuのバージョンを確認

hugahuga@hogehoge-vps:~# sudo cat /etc/*release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=18.04
DISTRIB_CODENAME=bionic
DISTRIB_DESCRIPTION="Ubuntu 18.04.1 LTS"
NAME="Ubuntu"
VERSION="18.04.1 LTS (Bionic Beaver)"
ID=ubuntu
ID_LIKE=debian
PRETTY_NAME="Ubuntu 18.04.1 LTS"
VERSION_ID="18.04"
HOME_URL="https://www.ubuntu.com/"
SUPPORT_URL="https://help.ubuntu.com/"
BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
VERSION_CODENAME=bionic
UBUNTU_CODENAME=bionic

無事、18.04.1 LTSにアップグレードされていますね。

お疲れ様でした!

スポンサーリンク

Ubuntu, VPS

Posted by gcga