LoginSignup
13

More than 5 years have passed since last update.

Raspberry Pi 3 B+にUbuntu desktop18.04 をインストールする

Last updated at Posted at 2018-07-12

概要

  • 色々試した結果、Raspberry Pi 3 B+では、ubuntu classic 18.04 serverインストール後にubuntu-desktop(通常のUbuntu-desktop)のインストールが可能ということがわかりました。
    • Raspberry Pi 3 Bでは、ubuntu-desktopを入れると、ログイン後にメニューバーが表示されなかったり色々表示が不足していた。
    • Raspberry Pi 3 Bでは、xubuntu-desktopやlubuntu-desktopを使う対応方法もあります。
  • 今回は画面も含めて使いたかったのでKuman LCD 3.5 inchで画面表示を行えるように組み立てました。
  • Raspberry Pi 3+にubuntu calssic 16.04.4のインストールを試みましたが、2ndパーティションに/lib/firmware/4.15.0-1010-raspi2/device-tree/bcm2710-rpi-3-b-plus.dtbが存在しておらず、ubuntu-desktopのインストール後に不安定になるためあきらめました。

ハードウェアの組み立て

  • Raspberry Pi 3 B+
  • HDMI接続のLCD3.5インチを購入して接続

OSのインストール

https://wiki.ubuntu.com/ARM/RaspberryPi#Updating_the_Pi_GPU_firmware_and_bootloader_files
を参考に以下Pi3 B+向けの環境を作る。

イメージをダウンロード
# wget http://cdimage.ubuntu.com/ubuntu/releases/18.04/release/ubuntu-18.04-preinstalled-server-armhf+raspi2.img.xz
# unxz ubuntu-18.04-preinstalled-server-armhf+raspi2.img

イメージをsdcardに書き込み
# dd bs=4M if=ubuntu-18.04-preinstalled-server-armhf+raspi2.img of=/dev/sdX status=progress conv=fsync    # X=sdcard

disk拡張
# fdisk /dev/sdX
p
  Command (m for help): p
  Disk /dev/sdX: 29.8 GiB, 32010928128 bytes, 62521344 sectors
  Units: sectors of 1 * 512 = 512 bytes
  Sector size (logical/physical): 512 bytes / 512 bytes
  I/O size (minimum/optimal): 512 bytes / 512 bytes
  Disklabel type: dos
  Disk identifier: 0xbb3b9f98

  Device     Boot  Start     End Sectors  Size Id Type
  /dev/sdX1  *      8192  270335  262144  128M  c W95 FAT32 (LBA)
  /dev/sdX2       270336 4610047 4339712  2.1G 83 Linux   # Startブロック270336をメモっておく
d   # パーティション削除
2   # 2ndを選択
p
n   # パーティション作成
p
2   # 2nd
270336  # 先ほどの/dev/sdX2 27036の値を使う
Enter   # MAXまでパーティションとする
p
  Device     Boot  Start      End  Sectors  Size Id Type
  /dev/sdX1  *      8192   270335   262144  128M  c W95 FAT32 (LBA)
  /dev/sdX2       270336 62521343 62251008 29.7G 83 Linux
w
起動後にresize2fsを行う事で拡張が実施される
q

# mount /dev/sdX1 /media/usb
# mount /dev/sdX2 /media/usb2
# vi /media/usb/config.txt
修正
#kernel=***
#device_tree_address=0x02000000
kernel=vmlinuz
initramfs initrd.img followkernel

ドライバを更新。以下OSパーティションからsystem-boot領域にコピー
for 18.04
# cp -ip /media/usb2/lib/firmware/4.15.0-1010-raspi2/device-tree/bcm2710-rpi-3-b-plus.dtb /media/usb/
# cp -ip /media/usb2/lib/firmware/4.15.0-1010-raspi2/device-tree/bcm2710-rpi-3-b.dtb /media/usb/
# cp -rip /media/usb2/lib/firmware/4.15.0-1010-raspi2/device-tree/overlays /media/usb/

GPUファームウェアを更新
  これが無いと画面表示が虹色画像のまま変化しなくなる
http://archive.raspberrypi.org/debian/pool/main/r/raspberrypi-firmware/raspberrypi-bootloader_1.20180417-11_armhf.deb
# mkdir pi-bootloader
# dpkg-deb -x raspberrypi-bootloader_1.20180417-1_armhf.deb pi-bootloader
  # or 7zipで開き、boot/*を以下にコピー
# cp -p pi-bootloader/boot/* /media/usb/

WiFiドライバーを更新。以下/lib/firmware/brcm/直下に配置。
https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43455-sdio.bin
https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43455-sdio.clm_blob
https://github.com/RPi-Distro/firmware-nonfree/raw/master/brcm/brcmfmac43455-sdio.txt 
# cp -p brcmfmac43455-sdio.* /media/usb2/lib/firmware/brcm/

rootのパスワードを初期化
# vi /media/usb2/etc/shadow
  root::~ に修正。:の二番目の値を*->空にする

起動時間短縮
  これをやらないと起動時にNetwork探索で無限ループになる
# rm /media/usb2/etc/systemd/system/network-online.target.wants/systemd-networkd-wait-online.service
# mv /media/usb2/etc/systemd/system/cloud-init.target.wants /media/usb2/root/

IP設定
# vi /media/usb2/etc/systemd/network/20-wired.network
[Match]
Name=eth0

[Network]
Address=192.168.0.100/24
Gateway=192.168.0.1
DNS=192.168.0.1

flash-kernelのall.db更新
# vi /media/usb2/usr/share/flash-kernel/db/all.db
以下最後に追記
# Raspberry Pi 3 Plus (BCM2710)
Machine: BCM2710
Machine: Raspberry Pi 3 Model B Plus Rev 1.3
DTB-Id: bcm2710-rpi-3-b-plus.dtb
U-Boot-Script-Name: bootscr.rpi3
Required-Packages: u-boot-tools
Boot-DTB-Path: /boot/firmware/bcm2710-rpi-3-b-plus.dtb
Boot-Kernel-Path: /boot/firmware/vmlinuz
Boot-Initrd-Path: /boot/firmware/initrd.img
Boot-Script-Path: /boot/firmware/boot.scr

アンマウント
# unmount /media/usb
# unmount /media/usb2

ラズパイ3B+で起動
rootでログイン
# passwd

ディスク拡張
# resize2fs /dev/mmcblk0p2

ssh設定
# vi /etc/ssh/sshd_config
  PermitRootLogin yes
  PasswordAuthentication yes
# ssh-keygen -t rsa -f /etc/ssh/ssh_host_rsa_key
# ssh-keygen -t dsa -f /etc/ssh/ssh_host_dsa_key
  鍵が無いので作成する
# systemctl restart sshd
# ssh接続を確認

aptの自動更新をOFF
# systemctl disable apt-daily.service
# systemctl disable apt-daily.timer

apt最新化
# apt update

再起動
# reboot

Desktop化

# apt-get install ubuntu-desktop
# systemctl set-default graphical.target

再起動
reboot

GUIで以下設定
keyboard : japanese
date : tokyo, japan
user : ubuntu

メモ

  • wlan0, Bluetoothが認識されることを確認

次やること

  • アプリを入れて動かす

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
13