LoginSignup
54
46

More than 5 years have passed since last update.

ubuntu 18.04 LTS にアップグレードする(コマンドライン編)

Last updated at Posted at 2018-04-29

概要

コマンドラインでUbuntu 16.04LTS またはUbuntu 17.10 からUbuntu 18.04 LTS にアップグレードする手順です。
留意事項としてssh で接続してアップグレードすることもできますが、トラブルが起きたときに接続できなくなる可能性を考慮してコンソール接続で実施されることを推奨します。

コマンドライン編

update-manager-core がインストールされていない場合はインストールします。

$ sudo apt-get install update-manager-core

/etc/update-manager/release-upgrades のPrompt がnormal もしくはlts になっていることを確認します。
ただし、Ubuntu 17.10 からアップグレードする場合は、update-manager が正しくリリースを検出できるようにnormal にするようにしてください。
normal にすることで、LTS かそうでないかに関係なく、新しいリリースが出され次第アップグレードができるようになります。
lts にすることで新しいLTS がリリースされた時のみアップグレードができるようになります。

/etc/update-manager/release-upgrades
$ sudo vim /etc/update-manager/release-upgrades
......
Prompt=normal or lts
......

do-release-upgrade を実行します。

sudodo-release-upgrade-d
$ sudo do-release-upgrade -d

あとは画面の指示に従って処理を進めていくだけです。
これより以下は自分の環境で出てきた選択肢などについて解説していきます。
お使いの環境により選択肢は変わってくると思うので参考程度にご覧いただければと思います。

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'.

Continue [yN] y

SSH 接続でアップグレードしようとして上記のメッセージが出ても継続しても大丈夫です(ただし、やはりトラブルが発生したときのためにSSH ではなくコンソール推奨ではあります)。
何かの契機で接続が切れてしまったら、1022 ポートでssh が起動するので、そこに再接続すればOK という旨のメッセージです。

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 を押下すると1022 番ポートでsshd が始まります。iptables 等で許可されていない場合は1022 TCP を開けておくようにしてください。

例)
$ sudo iptables -I INPUT -p tcp --dport 1022 -j ACCEPT
アップグレードの概要
3 installed packages are no longer supported by Canonical. You can
still get support from the community.

3 packages are going to be removed. 108 new packages are going to be
installed. 402 packages are going to be upgraded.

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

上記のようにアップグレードの概要が表示される。同意するならy を入力。

暫くすると、grub インストールが完了した後に、/etc/default/grub の設定ファイルを新しいので置き換えるか今までのを使い続けるか聞かれました。

p.png

  • show the differences between the versions で一旦差分を確認してみます。
diff/etc/default/grub
Line by line differences between versions                                            

--- /etc/default/grub root.root 0644 2018-04-05 08:38:35                             
+++ /tmp/grub.TiLQgkytWu root.root 0644 2018-04-27 04:36:06                          
@@ -8,7 +8,7 @@                                                                      
 GRUB_HIDDEN_TIMEOUT_QUIET=true                                                      
 GRUB_TIMEOUT=0                                                                      
 GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`                    
-GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0"                             
+GRUB_CMDLINE_LINUX_DEFAULT="console=tty1 console=ttyS0 nvme.io_timeout=4294967295"  
 GRUB_CMDLINE_LINUX=""                                                               

 # Uncomment to enable BadRAM filtering, modify to suit your needs                   
@@ -17,7 +17,7 @@                                                                    
 #GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"                          

 # Uncomment to disable graphical terminal (grub-pc only)                            
-GRUB_TERMINAL=console                                                               
+#GRUB_TERMINAL=console                                                              

 # The resolution used on graphical terminal                                         
 # note that you can use only modes which your graphic card supports via VBE         

                                       <Ok>

今回は仮想環境上のubuntu で GRUB_TERMINAL=console が無くなると困る環境だったので念の為古い方を使い続ける選択にしました。
keep the local version currently installedを選択します。

暫くすると/etc/ssh/sshd_config についても同様な選択肢が来ました。差分を確認して適宜置換をおこなってください(詳細は割愛します)。

/etc/ssh/sshd_config
sshd_config: A new version (/tmp/filehV7Xqu) 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?

次に使用されなくなったパッケージの削除が聞かれます。
削除して問題なければy で回答します。

Removeobsoletepackages
Remove obsolete packages?

28 packages are going to be removed.

 Continue [yN]  Details [d]y

アップグレードが完了すると再起動するか聞かれますので、y で回答します。

restart
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 のバージョンがアップしたことを確認して完了です。

cat/etc/*release
$ sudo cat /etc/*release
...
VERSION="18.04 LTS (Bionic Beaver)"
...

参考

54
46
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
54
46