はじめに
Ubuntu 22.04 LTSがリリースされ利用できるようになりました。そこで、既存の環境からアップグレードする方法を紹介します。
例えばAzureなどのクラウド環境では20.04を利用しているケースが多いと思います。これをアップグレードします。
追記:アップグレードバスについて修正しています。
アップグレードパス
アップグレードパスはバージョンによって異なります。バージョンアップはAzure環境で行っています。
- Ubunut 18.04 LTSの場合
- Ubuntu 20.04 LTSにアップグレードしてから22.04にアップグレードする
- Ubutnu 20.04 LTSの場合
- 直接22.04にアップグレードできます
- Ubunut 21.10の場合
- Ubunut 22.04にアップグレードする
2022/06/23 本文修正しました。
release-upgrades の設定
Ubunut 22.04へのアップグレードはLTSへのアップグレードのため通常は変更必要ないと思われます。
ただし、既存環境がLTSでない場合は注意が必要です。Prompt=normalに設定されてる場合があります。その場合は下記のように変更が必要です。
/etc/update-manager/release-upgrades
# Default behavior for the release upgrader. [DEFAULT] # Default prompting and upgrade behavior, valid options: # # never - Never check for, or allow upgrading to, 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 supported 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 if this option is used and # the currently-running release is not itself an LTS release the # upgrader will assume prompt was meant to be normal. Prompt=lts
に変更します。
アップグレード
アップグレードを行う前に事前にパッケージのアップデートを行います。これは全てのバージョンに共通です。
sudo apt update sudo apt upgrade
update-manager-coreをインストールします。これでディストリビューションをアップグレードを行います。
sudo apt install update-manager-core
Azureの仮想マシンの場合にはもともとインストールされています。
Ubuntu 18.04 LTSからUbuntu 20.04 LTSのアップグレード
アップグレードは下記のコマンドで行います。
sudo do-release-upgrade
アップグレード中に何度か質問が対話式であります。
Azureの環境での例です。
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
を入力して進めます。
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]
を入力します。
Do you want to start the upgrade? 8 installed packages are no longer supported by Canonical. You can still get support from the community. 10 packages are going to be removed. 168 new packages are going to be installed. 496 packages are going to be upgraded. You have to download a total of 300 M. This download will take about 38 minutes with a 1Mbit DSL connection and about 11 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
を入力して進めます。
アップグレードを中止できるのはここまでです。
下記は環境によって表示される場合とされない場合があります。また、他の質問が出る場合もあります。
Configuring libc6 There are services installed on your system which need to be restarted when certain libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may cause interruptions of service for the system, you will normally be prompted on each upgrade for the list of services you wish to restart. You can choose this option to avoid being prompted; instead, all necessary restarts will be done for you automatically so you can avoid being asked questions on each library upgrade. Restart services during package upgrades without asking?
y
を入力して進めます。
Configuration file '/etc/default/useradd' ==> 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. *** useradd (Y/I/N/O/D/Z) [default=N] ?
N
を入力して進めます。
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 3.0 4.0
4.0
を選択して進めます。
Configuring openssh-server A new version (/tmp/tmp.iqSuVddMWD) of configuration file /etc/ssh/sshd_config is available, but the version installed currently has been locally modified. What do you want to do about modified configuration file sshd_config? install the package maintainer's version keep the local version currently installed show the differences between the versions show a side-by-side difference between the versions show a 3-way difference between available versions do a 3-way merge between available versions start a new shell to examine the situation
keep the local version currently installed
を選択し進めます。
Remove obsolete packages? 66 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
を入力して再起動します。
再ログイン時にバージョンが表示されるのでUbuntu 20.04 LTSにアップグレードされていることを確認します。
次にUbuntu 20.04 LTSからのアップグレードに進んでください。
Ubuntu 20.04 からUbuntu 22.04 LTSのアップグレード
アップグレードは下記のコマンドで行います。上記とは異なり -d が必要です。
sudo do-release-upgrade -d
アップグレード中になんどか質問が対話式であります。
Azureの環境での例です。
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
を入力して進めます。
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]
を入力します。
Do you want to start the upgrade? 1 installed package is no longer supported by Canonical. You can still get support from the community. 4 packages are going to be removed. 92 new packages are going to be installed. 565 packages are going to be upgraded. You have to download a total of 248 M. This download will take about 49 seconds with a 40Mbit connection and about 6 minutes with a 5Mbit connection. Fetching and installing the upgrade can take several hours. Once the download has finished, the process cannot be canceled. Continue [yN] Details [d]
y
を入力して進めます。
アップグレードを中止できるのはここまでです。
下記は環境によって表示される場合とされない場合があります。また、他の質問が出る場合もあります。
Configuring libc6 There are services installed on your system which need to be restarted when certain libraries, such as libpam, libc, and libssl, are upgraded. Since these restarts may cause interruptions of service for the system, you will normally be prompted on each upgrade for the list of services you wish to restart. You can choose this option to avoid being prompted; instead, all necessary restarts will be done for you automatically so you can avoid being asked questions on each library upgrade. Restart services during package upgrades without asking?
y
を入力して進めます。
Modified configuration file A new version (/usr/share/chrony/chrony.conf) of configuration file /etc/chrony/chrony.conf is available, but the version installed currently has been locally modified. What do you want to do about modified configuration file chrony.conf? install the package maintainer's version keep the local version currently installed show the differences between the versions show a side-by-side difference between the versions show a 3-way difference between available versions do a 3-way merge between available versions start a new shell to examine the situatio
keep the local version currently installed
を選択し進めます。
Configuring openssh-server A new version (/tmp/tmp.iqSuVddMWD) of configuration file /etc/ssh/sshd_config is available, but the version installed currently has been locally modified. What do you want to do about modified configuration file sshd_config? install the package maintainer's version keep the local version currently installed show the differences between the versions show a side-by-side difference between the versions show a 3-way difference between available versions do a 3-way merge between available versions start a new shell to examine the situation
keep the local version currently installed
を選択し進めます。
Remove obsolete packages? 77 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
を入力して再起動します。
再ログイン時にバージョンが表示されるのでUbuntu 22.04 LTSにアップグレードされていることを確認します。
Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-1003-azure x86_64) * Documentation: https://help.ubuntu.com * Management: https://landscape.canonical.com * Support: https://ubuntu.com/advantage System information as of Fri Apr 22 16:45:38 UTC 2022 System load: 0.19921875 Processes: 133 Usage of /: 6.7% of 28.90GB Users logged in: 0 Memory usage: 3% IPv4 address for eth0: 172.17.0.4 Swap usage: 0% 0 updates can be applied immediately.
まとめ
Ubuntuのアップグレードの方法は非常に簡単です。ただし本番機でのアップグレードは推奨しません。検証環境だけにしましょう。
行う場合でも、アプリの動作など念入りに検証したうえでアップグレードしてください。
クラウドでUbuntu 22.04 LTSを利用したい場合はすでに各社イメージが用意されているのでそれらを利用しましょう。