Raspberry Pi Zero W - Raspbian Stretch LITE インストール
2019.12.19
Raspberry Pi Zero の mini-HDMI ケーブルがなかったので、
Raspberry Pi 3 Model B+ に Raspbian Stretch LITE をインストールして、Raspberry Pi Zero W 用に複製したときの忘備録です。
microSD の複製には、Zero用のmicroSDを USBカードリーダー/ライターに挿して、ラズパイ本体にUSB接続して行いました。
ここでは、Raspberry Pi 3 Model B+ のローカルIPアドレスを 192.168.11.7、zero を 192.168.11.8、ブロードバンドルーターを 192.168.11.1 として説明しています。
■Download
https://www.raspberrypi.org/downloads/raspbian/
→ 2019-04-08-raspbian-stretch-lite.zip
■SDカードのフォーマット
SD card formatter
■イメージ書き込み
win32DiskImager
■解像度の変更
エクスプローラーなどでドライブを確認すると、 USBドライブとsystem-bootドライブといった2つのドライブが追加されていることがわかります。
system-boot ドライブを開いて、config.txt に下記を追記します。
# uncomment to force a console size. By default it will be display's size minus
# overscan.
framebuffer_width=480
framebuffer_height=320
# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=2
hdmi_mode=87
hdmi_cvt=480 320 60 1 0 0 0
■起動とログイン
ユーザー名:pi / パスワード:raspberry
■キーボード設定
$ sudo dpkg-reconfigure keyboard-configuration
→ generic104 pc
→ Other
→ Japanes
→ Japanes
→ The default for the keyboard layout
→ No compose key
■Locale
$ sudo raspi-config
2.Network Options
→ N2 Wi-fi
→ JP Japan
→ Please enter SSID [ブロードバンドルーターのSID]
→ Please enter passphrase
4.Locatisation Options
→ I1 Change Locale
→ ja_JP.UTF-8 UTF-8
→ None
4.Locatisation Options
→ I4 Wi-fi Country
→ JP Japan
■タイムゾーン設定
$ sudo dpkg-reconfigure tzdata
→ Asia
→ Tokyo
■無線LANを設定確認
$ sudo cat /etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP
network={
ssid="[ブロードバンドルーターのSID]"
psk="[パスフレーズ]"
}
■ネットワークIPを固定化する
下記を追加します。
$ sudo vi /etc/dhcpcd.conf
interface wlan0
SSID [ブロードバンドルーターのSID]
static ip_address=192.168.11.7/24
static routers=192.168.11.1
static domain_name_servers=192.168.11.1
■仮日時設定
時刻がずれていた場合は各種パッケージのインストールがうまくいかない可能性があるので、おおよその時刻を合わせます。
$ sudo date --date='TZ="Asia/Tokyo" 2019-06-11 09:00'
$ sudo reboot
■ユーザーpiのパスワード変更
$ passwd
********
■ssh
$ sudo service ssh status
Active: inactive (dead)
$ sudo service ssh start
Active: active (runnning)
自動起動設定
$ sudo systemctl enable ssh
■パッケージの更新
$ sudo apt update
■microSD から USBメモリー(microSD用カードリーダー/ライター)に複写する
$ df -h --total
Filesystem Size Used Avail Use% Mounted on
/dev/root 30G 1.3G 27G 5% /
devtmpfs 460M 0 460M 0% /dev
tmpfs 464M 0 464M 0% /dev/shm
tmpfs 464M 6.2M 458M 2% /run
tmpfs 5.0M 4.0K 5.0M 1% /run/lock
tmpfs 464M 0 464M 0% /sys/fs/cgroup
/dev/mmcblk0p1 43M 22M 21M 51% /boot
tmpfs 93M 0 93M 0% /run/user/1000
total 32G 1.3G 29G 5% -
現在接続されているディスクの状況を確認
$ sudo fdisk -l
.....
Disk /dev/mmcblk0: 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: 0x187dec13
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 96042 87851 42.9M c W95 FAT32 (LBA)
/dev/mmcblk0p2 98304 62521343 62423040 29.8G 83 Linux
USBメモリーをラズパイに接続します。
USBをPiに刺すと、他に余計な物を繋いでいない限り「/dev/sda」として認識されます。
$ sudo fdisk -l
....
Disk /dev/mmcblk0: 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: 0x187dec13
Device Boot Start End Sectors Size Id Type
/dev/mmcblk0p1 8192 96042 87851 42.9M c W95 FAT32 (LBA)
/dev/mmcblk0p2 98304 62521343 62423040 29.8G 83 Linux
Disk /dev/sda: 29.7 GiB, 31914983424 bytes, 62333952 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: 0x00000000
Device Boot Start End Sectors Size Id Type
/dev/sda1 8192 62333951 62325760 29.7G c W95 FAT32 (LBA)
/etc/fstabの情報を表示します(マウント状況を調べる)
$ findmnt --fstab
TARGET SOURCE FSTYPE OPTIONS
/proc proc proc defaults
/boot PARTUUID=187dec13-01 vfat defaults
/ PARTUUID=187dec13-02 ext4 defaults,noatime
■パーティションの作成
$ sudo parted /dev/sda
GNU Parted 3.2
Using /dev/sda
Welcome to GNU Parted! Type 'help' to view a list of commands.
(parted) mktable msdos
Warning: The existing disk label on /dev/sda will be destroyed and
all data on this disk will be lost. Do you want to continue?
Yes/No? Yes
(parted) mkpart primary fat32 0% 120M
(parted) mkpart primary ext4 120M 100%
(parted) print
Model: Generic- SD/MMC (scsi)
Disk /dev/sda: 31.9GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Disk Flags:
Number Start End Size Type File system Flags
1 1049kB 120MB 118MB primary fat32 lba
2 120MB 31.9GB 31.8GB primary ext4 lba
(parted) quit
Information: You may need to update /etc/fstab.
■パーティションのフォーマット
$ sudo mkfs.vfat -n boot -F 32 /dev/sda1
mkfs.fat 4.1 (2017-01-24)
$ sudo mkfs.ext4 /dev/sda2
mke2fs 1.43.4 (31-Jan-2017)
Creating filesystem with 7762432 4k blocks and 1941504 inodes
Filesystem UUID: 94683fe0-3d33-470b-9c39-ea9b04cb1ae8
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736, 1605632, 2654208,
4096000
Allocating group tables: done
Writing inode tables: done
Creating journal (32768 blocks): done
Writing superblocks and filesystem accounting information: done
■システムイメージの複写
$ sudo apt-get install -y rsync
マウントしてからrsyncでコピーします
$ sudo mkdir -p /mnt/target
$ sudo mount /dev/sda2 /mnt/target/
$ sudo mkdir /mnt/target/boot
$ sudo mount /dev/sda1 /mnt/target/boot/
$ sudo rsync -ax --progress / /boot /mnt/target
■cmdline.txtとfstabの修正
UUID,PARTUUIDを調べる
$ sudo blkid (あるいは $ ls -l /dev/disk/by-partuuid/)
/dev/mmcblk0p1: LABEL="boot" UUID="23F3-967F" TYPE="vfat" PARTUUID="187dec13-01"
/dev/mmcblk0p2: LABEL="rootfs" UUID="d065e631-6b9d-48c0-a8fe-a5884ed28ec0" TYPE="ext4" PARTUUID="187dec13-02"
/dev/sda1: LABEL="boot" UUID="D9C9-78CD" TYPE="vfat" PARTUUID="44weD634-01"
/dev/sda2: UUID="e79c02ca-5179-49ec-123e-fa58876543" TYPE="ext4" PARTUUID="44weD634-02"
/dev/mmcblk0: PTUUID="187dec13" PTTYPE="dos"
$ sudo vi /mnt/target/boot/cmdline.txt
root=PARTUUID=187dec13-02
↓変更
root=PARTUUID=44weD634-02
$ sudo vi /mnt/target/etc/fstab
PARTUUID=187dec13-01 /boot vfat defaults 0 2
PARTUUID=187dec13-02 / ext4 defaults,noatime 0 1
↓変更
PARTUUID=44weD634-01 /boot vfat defaults 0 2
PARTUUID=44weD634-02 / ext4 defaults,noatime 0 1
■ネットワークIP変更
$ sudo vi /mnt/target/etc/dhcpcd.conf
interface wlan0
SSID [ブロードバンドルーターのSID]
static 192.168.11.8/24
static routers=192.168.11.1
static domain_name_servers=192.168.11.1
別のブロードバンドルーターを使うときには下記も変更します。
$ sudo cat /mnt/target/etc/wpa_supplicant/wpa_supplicant.conf
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=JP
network={
ssid="[ブロードバンドルーターのSID]"
psk="[パスフレーズ]"
}
$ sudo umount /mnt/target/boot
$ sudo umount /mnt/target
$ sudo poweroff
SDカードを抜き、Raspberry Pi Zero に挿して起動します。
Zero の制御は、Windowsパソコンから無線LAN経由でSSH接続にて行いました。
■Raspberry Pi Zero W仕様
PCB version |
1.1 |
SoC |
Broadcom BCM2835 |
CPU |
1000MHz シングルコア ARM1176JZ-F(ARMv6) |
GPU |
デュアルコア VideoCore IV® 250MHz
OpenGL ES 2.0対応、ハードウェアOpenVG対応、1080p30 H.264 high-profileデコード
1Gピクセル/秒、1.5Gテクセル/秒、または24G FLOPの性能を持つ
|
メモリ |
512MB DDR2 低電圧 SDRAM |
電源定格 / 消費電流 |
Micro USB Bソケット 5V 1A |
外形寸法 / 質量 |
60(W) x 30(D) x 5(H) mm / 約 |
Wi-Fi(無線LAN) |
IEEE 802.11 b/g/n 2.4GHz |
インターフェイス |
USB 2.0(microUSB、USB OTG) × 1
mini HDMI(rev.1.3,1.4/オーディオ出力共有)
CSI(22ピン MIPI 2-Lane)
GPIO(40ピン 2.54mm ピンヘッダー(GPIO×26 3.3V 16mA、UART、I2C、SPI、I2S、PWM、5V(使用電源に依存)、3.3V 50mA(GPIOとの総和))
micro SDメモリーカード(SDIO)
|
|