Ubuntu18.04から20.04へのアップグレード手順(AWS Lightsail)

アップグレード手順

SSHポートを一時的に開けておく

# nft add rule ip filter input iifname eth0 tcp dport 1022 accept

$ sudo apt update
$ sudo apt upgrade
$ sudo apt full-upgrade

$ sudo apt autoremove

A new version of /boot/grub/menu.lst is available, but the version installed currently has been locally  modified.

What would you like to do about menu.lst?

install the package maintainer's version ←こっち選択

keep the local version currently installed


$ sudo apt install update-manager-core ←インストール済みだった

$ do-release-upgrade -c

$ sudo do-release-upgrade

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] y ←yを押す

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.
Asthis 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を押す

Updating repository information
Third party sources disabled
Some third party entries in your sources.list were disabled. You can
re-enable them after the upgrade with the 'software-properties' tool
or your package manager.

To continue please press [ENTER] ←Enterを押す

Do you want to start the upgrade?

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

3 packages are going to be removed. 140 new packages are going to be
installed. 537 packages are going to be upgraded.

You have to download a total of 267 M. This download will take about
33 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を押す

The LXD project puts out monthly feature releases which while backward compatible at an API and CLI level, will contain some behavior change and potentially require manual intervention during an upgrade. 

In addition to those, every 2 years a LTS release is made which comes with 5 years of support through frequent bugfix-only releases.                                                                                             

The LXD team recommends you pick "4.0" for production environments and use "latest" if you're interested in getting the latest LXD features.

LXD snap track

latest
3.0
4.0 ←選択してEnterを押す

Configuration file '/etc/vim/vimrc'
 ==> 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.
*** vimrc (Y/I/N/O/D/Z) [default=N] ? ←Enterを押す

A new version (/tmp/file65YM5R) of configuration file /etc/ssh/sshd_config is available, but the version installed currently has been locally modified.                                                             x

What do you want to do about modified configuration file sshd_config?

keep the local version currently installed ←選択してEnterを押す

古いパッケージ一覧が表示されるので削除

/etc/kernel/postinst.d/zz-update-grub:
Sourcing file `/etc/default/grub'
Sourcing file `/etc/default/grub.d/50-cloudimg-settings.cfg'
Sourcing file `/etc/default/grub.d/init-select.cfg'
Generating grub configuration file ...
Found linux image: /boot/vmlinuz-5.4.0-1039-aws
Found initrd image: /boot/microcode.cpio /boot/initrd.img-5.4.0-1039-aws
Found linux image: /boot/vmlinuz-5.4.0-1038-aws
Found initrd image: /boot/microcode.cpio /boot/initrd.img-5.4.0-1038-aws
Found linux image: /boot/vmlinuz-4.15.0-1021-aws
Found initrd image: /boot/microcode.cpio /boot/initrd.img-4.15.0-1021-aws
done
Processing triggers for dbus (1.12.16-2ubuntu2.1) ...
Processing triggers for rkhunter (1.4.6-8) ...
Invalid SCRIPTWHITELIST configuration option: Non-existent pathname: /usr/bin/egrep
Invalid SCRIPTWHITELIST configuration option: Non-existent pathname: /usr/bin/fgrep
Reading package lists... Done
Building dependency tree
Reading state information... Done

Searching for obsolete software
Reading state information... Done

Remove obsolete packages?

51 packages are going to be removed.

Continue [yN]  Details [d] ←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] ←yを押す(押すと再起動する)

2~3分待ってからSSHで接続する

以下のコマンドを実行してVERSIONが20.04になっていたら成功
$ more /etc/os-release