Ubuntu16.04のカーネルを新しいバージョン(HWEカーネル)にアップグレード

## <INS>アップグレードできるカーネルを見る

```Bash
$ apt-cache search linux-generic-lts
linux-generic-lts-utopic - Complete Generic Linux kernel and headers (dummy transitional package)
linux-generic-lts-vivid - Complete Generic Linux kernel and headers (dummy transitional package)
linux-generic-lts-wily - Complete Generic Linux kernel and headers (dummy transitional package)
linux-generic-lts-xenial - Complete Generic Linux kernel and headers (dummy transitional package)
```

出力されたなかで、適切なものをapt installして再起動すればアップグレードできます。

## <INS>適切なものを自動で選択してアップグレードする

```Bash
$ sudo apt install linux-generic-hwe-16.04
```

## <INS>更に新しい(本当に最新の)カーネルにアップグレードする

```Bash
$ apt-cache search 4.15 | grep image
linux-image-4.15.0-1013-azure - Signed kernel image azure
linux-image-4.15.0-1014-azure - Signed kernel image azure
linux-image-4.15.0-13-generic - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-4.15.0-13-lowlatency - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-4.15.0-15-generic - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-4.15.0-15-lowlatency - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-4.15.0-20-generic - Signed kernel image generic
linux-image-4.15.0-20-lowlatency - Signed kernel image lowlatency
linux-image-4.15.0-22-generic - Signed kernel image generic
linux-image-4.15.0-22-lowlatency - Signed kernel image lowlatency
linux-image-4.15.0-23-generic - Signed kernel image generic
linux-image-4.15.0-23-lowlatency - Signed kernel image lowlatency
linux-image-4.15.0-24-generic - Signed kernel image generic
linux-image-4.15.0-24-lowlatency - Signed kernel image lowlatency
linux-image-extra-4.15.0-13-generic - Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP
linux-image-extra-4.15.0-15-generic - Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-1013-azure - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-1014-azure - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-20-generic - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-20-lowlatency - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-22-generic - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-22-lowlatency - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-23-generic - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-23-lowlatency - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-24-generic - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-24-lowlatency - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-signed-image-4.15.0-13-generic - Signed kernel image generic
linux-signed-image-4.15.0-13-lowlatency - Signed kernel image lowlatency
linux-signed-image-4.15.0-15-generic - Signed kernel image generic
linux-signed-image-4.15.0-15-lowlatency - Signed kernel image lowlatency
linux-image-4.15.0-1005-azure-edge - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
linux-image-4.15.0-1012-azure - Signed kernel image azure
linux-image-extra-4.15.0-1005-azure-edge - Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP
linux-image-unsigned-4.15.0-1012-azure - Linux kernel image for version 4.15.0 on 64 bit x86 SMP
```

この中では一番「linux-image-4.15.0-24-generic」がそれっぽいのですね。しかし、実際にインストールする前に確認しなければならないことが一つあります。

## <INS>アップグレード前のバージョンのカーネルパッケージ諸々を確認する

```Bash
$ dpkg -l *4.4.0*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                     Version                   Architecture              Description
+++-========================================-=========================-=========================-=====================================================================================
ii  linux-headers-4.4.0-128-generic          4.4.0-128.154             amd64                     Linux kernel headers for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-4.4.0-128-generic            4.4.0-128.154             amd64                     Linux kernel image for version 4.4.0 on 64 bit x86 SMP
ii  linux-image-extra-4.4.0-128-generic      4.4.0-128.154             amd64                     Linux kernel extra modules for version 4.4.0 on 64 bit x86 SMP
ii  linux-tools-4.4.0-119-generic            4.4.0-119.143             amd64                     Linux kernel version specific tools for version 4.4.0-119
```

extraはドライバ、headerはヘッダファイル(Cで`#include "linux/hoge.h"`とか書くやつ)、toolsはperfとかとか、というようなものが入っています。

## <INS>カーネルのアップグレードとカーネルパッケージ諸々をインストール

まずはカーネルをアップグレードします。

```Bash
$ sudo apt install linux-image-4.15.0-24-generic -y
```

再起動して、新しいバージョンのカーネルパッケージ諸々を確認します。

```Bash
$ dpkg -l *4.15*
Desired=Unknown/Install/Remove/Purge/Hold
| Status=Not/Inst/Conf-files/Unpacked/halF-conf/Half-inst/trig-aWait/Trig-pend
|/ Err?=(none)/Reinst-required (Status,Err: uppercase=bad)
||/ Name                                                  Version                         Architecture                    Description
+++-=====================================================-===============================-===============================-===============================================================================================================
un  linux-headers-4.15.0-24-generic                       <none>                          <none>                          (no description available)
ii  linux-image-4.15.0-24-generic                         4.15.0-24.26~16.04.1            amd64                           Signed kernel image generic
un  linux-image-unsigned-4.15.0-24-generic                <none>                          <none>                          (no description available)
ii  linux-modules-4.15.0-24-generic                       4.15.0-24.26~16.04.1            amd64                           Linux kernel extra modules for version 4.15.0 on 64 bit x86 SMP
```

いれられるものをいれます。

```Bash
$ sudo apt install linux-headers-4.15.0-24-generic linux-image-unsigned-4.15.0-24-generic linux-modules-4.15.0-24-generic -y
```

「カーネルを削除しようとしています。これを実行すると起動できなくなります。」といった画面が出たら、Noを選択してください。

installが終了したら、再起動します。

```Bash
$ sudo rebot
```