How to install Ubuntu 19.10 aarch64 (64bit) on RaspberryPi4

# １．Introduction
The procedure to install Ubuntu 19.10 aarch64 (64bit) on RaspberryPi4 is described below.

# ２．Environment

- Ubuntu 18.04 x86_64
- RaspberryPi4 model B (Ubuntu 19.10 aarch64 / Python 3.7)
- microSD card 32GB

# ３．Procedure

```console:Ubuntu_19.10_image_download
$ curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=1clGRI0yuyceevz9i9OsvNYvvnEYpluRy" > /dev/null
$ CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
$ curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=1clGRI0yuyceevz9i9OsvNYvvnEYpluRy" -o ubuntu-19.10.1-preinstalled-server-arm64+raspi3.img.xz
$ xz -dv ubuntu-19.10.1-preinstalled-server-arm64+raspi3.img.xz
```

```console:Download_"Etcher"_image_writing_tool
$ curl -sc /tmp/cookie "https://drive.google.com/uc?export=download&id=1E2KTzDVjzBywFVHyx1nfMoCW3hSeQkMd" > /dev/null
$ CODE="$(awk '/_warning_/ {print $NF}' /tmp/cookie)"
$ curl -Lb /tmp/cookie "https://drive.google.com/uc?export=download&confirm=${CODE}&id=1E2KTzDVjzBywFVHyx1nfMoCW3hSeQkMd" -o balenaEtcher-1.5.70-x64.AppImage
```

Insert microSD card into SD card reader/writer.

```console:
$ sudo ./balenaEtcher-1.5.70-x64.AppImage
```
![Screenshot 2019-09-23 14:52:07.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/57222756-f522-2a96-2fb1-b58b18fb8a53.png)
![Screenshot 2019-09-23 14:53:59.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/c82085ef-7dfe-aff2-ca0b-1a11a31143be.png)
![Screenshot 2019-09-23 14:54:04.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/7f938cf0-9a41-b85d-c903-571bfa0446bd.png)

Insert the microSD card into RaspberryPi and turn on the power.　The initial login ID and password is **`ubuntu / ubuntu`**.

```console:Change_time_zone
$ sudo timedatectl set-timezone Asia/Tokyo
```

```console:Switch_to_Japanese_keyboard
$ sudo dpkg-reconfigure keyboard-configuration
```
![Screenshot 2019-09-23 16:03:14.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/00605c3c-c36a-2c81-b6b5-b85133fd4c0d.png)
![Screenshot 2019-09-23 16:03:27.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/c9b0de4b-8b5d-bb7e-8503-b52ea93234e7.png)
![Screenshot 2019-09-23 16:03:38.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/f0ff2ee3-a30f-ead1-44eb-f3818d0fcb0c.png)
![Screenshot 2019-09-23 16:03:45.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/fd2bf73c-b435-6775-1614-88db7cf828a5.png)
![Screenshot 2019-09-23 16:03:55.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/27862ddf-4b3e-86d8-db13-366b25464235.png)
![Screenshot 2019-09-23 16:04:15.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/e2d86b7a-ebee-2543-9e3e-8cfd57e6430c.png)

```console:Optional_work
$ sudo apt-get update && sudo apt-get upgrade
$ sudo apt-get install wget curl git zip unzip python3-pil \
    python3-opencv python3-pip libhdf5-dev openjdk-8-jdk net-tools
$ sudo -H pip3 install pip --upgrade
```

```console:Setting_swap_space
$ sudo apt-get install -y dphys-swapfile
$ sudo nano /etc/dphys-swapfile

CONF_SWAPSIZE=2048
```
<kbd>Ctrl</kbd> + <kbd>O</kbd>
<kbd>Ctrl</kbd> + <kbd>X</kbd>

```console:
$ sudo /etc/init.d/dphys-swapfile restart swapon -s
$ free -h
$ uname -a
$ cat /etc/lsb-release
```

```console:Wi-Fi_settings
$ ifconfig
$ nano /etc/netplan/50-cloud-init.yaml
```

Replace ＜MAC address＞ with MAC address, and ＜SSID＞ with Wi-Fi SSID, and replace ＜Passphrase＞ with SSID passphrase.

```console:50-cloud-init.yaml
network:
    version: 2
    ethernets:
        eth0:
            dhcp4: true
            match:
                macaddress: <MAC address>
            set-name: eth0
    wifis:
        wlan0:
            access-points:
                <SSID>:
                    password: <Passphrase>
            dhcp4: true
            dhcp6: true
```

<kbd>Ctrl</kbd> + <kbd>O</kbd>
<kbd>Ctrl</kbd> + <kbd>X</kbd>

```console:
$ sudo netplay apply
```

Disable automatic updates.

```console:
$ sudo apt-get install -y unattended-upgrades
$ sudo dpkg-reconfigure --priority=low unattended-upgrades
```
![Screenshot 2020-01-26 08:57:44.png](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/194769/855b0bc6-f8ba-fa8a-2eb3-157abf153e71.png)

Check whether the automatic update is enabled or disabled.
**`"0"-> disabled`**
**`"1"-> enabled`**

```console:
$ cat /etc/apt/apt.conf.d/20auto-upgrades
APT::Periodic::Update-Package-Lists "0";
APT::Periodic::Unattended-Upgrade "0";
```

Installing additional packages.

```console:
$ sudo pip3 install keras_applications==1.0.8 --no-deps
$ sudo pip3 install keras_preprocessing==1.1.0 --no-deps
$ sudo apt-get install -y openmpi-bin libopenmpi-dev
$ sudo -H pip3 install -U --user six wheel mock
```

# 4. Appendix
## 4-1. Desktop Install

```console:
$ sudo apt-get install ubuntu-desktop
or
$ sudo apt-get install xubuntu-desktop
or
$ sudo apt-get install lubuntu-desktop
or
$ sudo apt-get install kubuntu-desktop

$ sudo systemctl set-default graphical.target
```

## 4-2. Overclock 1.75GHz

```console:
$ sudo nano /boot/firmware/config.txt
```

Paste at the end of config.txt.

```console:/boot/firmware/config.txt
over_voltage=2
arm_freq=1750
```
<kbd>Ctrl</kbd> + <kbd>O</kbd>
<kbd>Ctrl</kbd> + <kbd>X</kbd>

```console:
$ sudo reboot
```

## 4-3. Check the CPU clock frequency

```console:Introduction_of_cpufreq
$ sudo apt-get install -y cpufrequtils
$ cpufreq-info

cpufrequtils 008: cpufreq-info (C) Dominik Brodowski 2004-2009
Report errors and bugs to cpufreq@vger.kernel.org, please.
analyzing CPU 0:
  driver: BCM2835 CPUFreq
  CPUs which run at the same hardware frequency: 0 1 2 3
  CPUs which need to have their frequency coordinated by software: 0 1 2 3
  maximum transition latency: 355 us.
  hardware limits: 600 MHz - 1.75 GHz
  available frequency steps: 600 MHz, 1.75 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 600 MHz and 1.75 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 600 MHz.
  cpufreq stats: 600 MHz:62.33%, 1.75 GHz:37.67%  (223)
analyzing CPU 1:
  driver: BCM2835 CPUFreq
  CPUs which run at the same hardware frequency: 0 1 2 3
  CPUs which need to have their frequency coordinated by software: 0 1 2 3
  maximum transition latency: 355 us.
  hardware limits: 600 MHz - 1.75 GHz
  available frequency steps: 600 MHz, 1.75 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 600 MHz and 1.75 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.75 GHz.
  cpufreq stats: 600 MHz:62.33%, 1.75 GHz:37.67%  (223)
analyzing CPU 2:
  driver: BCM2835 CPUFreq
  CPUs which run at the same hardware frequency: 0 1 2 3
  CPUs which need to have their frequency coordinated by software: 0 1 2 3
  maximum transition latency: 355 us.
  hardware limits: 600 MHz - 1.75 GHz
  available frequency steps: 600 MHz, 1.75 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 600 MHz and 1.75 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.75 GHz.
  cpufreq stats: 600 MHz:62.33%, 1.75 GHz:37.67%  (223)
analyzing CPU 3:
  driver: BCM2835 CPUFreq
  CPUs which run at the same hardware frequency: 0 1 2 3
  CPUs which need to have their frequency coordinated by software: 0 1 2 3
  maximum transition latency: 355 us.
  hardware limits: 600 MHz - 1.75 GHz
  available frequency steps: 600 MHz, 1.75 GHz
  available cpufreq governors: conservative, ondemand, userspace, powersave, performance, schedutil
  current policy: frequency should be within 600 MHz and 1.75 GHz.
                  The governor "ondemand" may decide which speed to use
                  within this range.
  current CPU frequency is 1.75 GHz.
  cpufreq stats: 600 MHz:62.33%, 1.75 GHz:37.67%  (223)
```

```console:GOVERNOR_changes
## GOVERNOR changes
$ sudo cpufreq-set -c 0 -g performance
$ sudo cpufreq-set -c 1 -g performance
$ sudo cpufreq-set -c 2 -g performance
$ sudo cpufreq-set -c 3 -g performance

## GOVERNOR change persistence
$ sudo nano /etc/default/cpufrequtils
GORVENOR="performance"
```

# 5. Reference articles

**http://cdimage.ubuntu.com/ubuntu/releases/19.10.1/release/**