■debian busterでRaspberry Pi 4BのSDイメージをMicroSDに書き込む。
$ lsb_release -d
Description: Debian GNU/Linux 10 (buster)
$ uname -r
4.19.0-9-amd64
■ubuntu用のimager_amd64パッケージをダウンロード
Downloads
https://www.raspberrypi.org/downloads/
$ md5sum imager_amd64.deb
6dc9049b4bac142452bfe71ced580d4f imager_amd64.deb
■imager_amd64パッケージの情報を表示
$ dpkg -I imager_amd64.deb | sed 's/, /&\n /g'
new Debian package,
version 2.0.
size 352184 bytes: control archive=892 bytes.
837 バイト、 12 行 control
356 バイト、 5 行 md5sums
Package: rpi-imager
Version: 1.3
Architecture: amd64
Maintainer: Floris Bos <bos@je-eigen-domein.nl>
Installed-Size: 883
Depends: libarchive13 (>= 3.0.4),
libc6 (>= 2.14),
libcurl3-gnutls (>= 7.16.2),
libgcc1 (>= 1:3.0),
libqt5core5a (>= 5.9.0~beta),
libqt5dbus5 (>= 5.0.2),
libqt5gui5 (>= 5.2.0),
libqt5network5 (>= 5.0.2),
libqt5qml5 (>= 5.1.0),
libqt5widgets5 (>= 5.0.2),
libssl1.1 (>= 1.1.0),
libstdc++6 (>= 5.2),
qml-module-qtquick2,
qml-module-qtquick-controls2,
qml-module-qt-labs-settings,
qml-module-qtquick-layouts,
qml-module-qtquick-templates2,
qml-module-qtquick-window2,
qml-module-qtgraphicaleffects,
dosfstools,
fdisk
Recommends: udisks2
Section: admin
Priority: optional
Homepage: https://www.raspberrypi.org/
Description: Raspberry Pi imaging utility
Graphical user-interface to write disk images and format SD cards.
■imager_amd64パッケージの依存環境を確認
※「1:3.0」と間違っているので修正
$ dpkg -I imager_amd64.deb | sed -e 's/1:3.0/1.3.0/' | \
awk -F"[,:]" '/Depends/{for(a=2;a<=NF;a++){print $a}}' > imager_depends.list
$ awk '{print "dpkg -l | grep -F "$1" || echo \042nn \042"$1 | "sh"}' imager_depends.list | awk '{print $1,$2,$3}'
ii libarchive13:amd64 3.3.3-4+deb10u1
ii libc6:amd64 2.28-10
ii libcurl3-gnutls:amd64 7.64.0-4+deb10u1
ii libgcc1:amd64 1:8.3.0-6
ii libqt5core5a:amd64 5.11.3+dfsg1-1+deb10u3
ii libqt5dbus5:amd64 5.11.3+dfsg1-1+deb10u3
ii libqt5gui5:amd64 5.11.3+dfsg1-1+deb10u3
ii libqt5network5:amd64 5.11.3+dfsg1-1+deb10u3
ii libqt5qml5:amd64 5.11.3-4
ii libqt5widgets5:amd64 5.11.3+dfsg1-1+deb10u3
ii libssl1.1:amd64 1.1.1d-0+deb10u3
ii libstdc++6:amd64 8.3.0-6
nn qml-module-qtquick2
nn qml-module-qtquick-controls2
nn qml-module-qt-labs-settings
nn qml-module-qtquick-layouts
nn qml-module-qtquick-templates2
nn qml-module-qtquick-window2
nn qml-module-qtgraphicaleffects
ii dosfstools 4.1-2
ii fdisk 2.33.1-0.1
ii gdisk 1.0.3-1.1
ii libfdisk1:amd64 2.33.1-0.1
■nnの未インストールの依存関係パッケージをインストールする。
$ awk '{print "dpkg -l | grep -F "$1" || echo \042nn \042"$1 | "sh"}' imager_depends.list | \
awk '($1 ~ /nn/){print "apt-get install -y "$2 | "sudo sh"}'
$ awk '{print "dpkg -l | grep -F "$1" || echo \042nn \042"$1 | "sh"}' imager_depends.list | \
awk '{print $1,$2,$3}'ii libarchive13:amd64 3.3.3-4+deb10u1
ii libc6:amd64 2.28-10
ii libcurl3-gnutls:amd64 7.64.0-4+deb10u1
ii libgcc1:amd64 1:8.3.0-6
ii libqt5core5a:amd64 5.11.3+dfsg1-1+deb10u3
ii libqt5dbus5:amd64 5.11.3+dfsg1-1+deb10u3
ii libqt5gui5:amd64 5.11.3+dfsg1-1+deb10u3
ii libqt5network5:amd64 5.11.3+dfsg1-1+deb10u3
ii libqt5qml5:amd64 5.11.3-4
ii libqt5widgets5:amd64 5.11.3+dfsg1-1+deb10u3
ii libssl1.1:amd64 1.1.1d-0+deb10u3
ii libstdc++6:amd64 8.3.0-6
ii qml-module-qtquick2:amd64 5.11.3-4
ii qml-module-qtquick-controls2:amd64 5.11.3+dfsg-2
ii qml-module-qt-labs-settings:amd64 5.11.3-4
ii qml-module-qtquick-layouts:amd64 5.11.3-4
ii qml-module-qtquick-templates2:amd64 5.11.3+dfsg-2
ii qml-module-qtquick-window2:amd64 5.11.3-4
ii qml-module-qtgraphicaleffects:amd64 5.11.3-2
ii dosfstools 4.1-2
ii fdisk 2.33.1-0.1
ii gdisk 1.0.3-1.1
ii libfdisk1:amd64 2.33.1-0.1
■比較
2つ余計なパッケージが含まれているが、いずれも要件は満たしているので、今回はこれでよしとする。
バージョンは「vimdiff -R」で色を付けても仕方ないので目視チェックとした。
$ awk '{print "dpkg -l | grep -F "$1" || echo \042nn \042"$1 | "sh"}' imager_depends.list | \
awk '{print $2,"("$3")"}' > imager_present.list
$ sdiff imager_present.list imager_depends.list
libarchive13:amd64 (3.3.3-4+deb10u1) | libarchive13 (>= 3.0.4)
libc6:amd64 (2.28-10) | libc6 (>= 2.14)
libcurl3-gnutls:amd64 (7.64.0-4+deb10u1) | libcurl3-gnutls (>= 7.16.2)
libgcc1:amd64 (1:8.3.0-6) | libgcc1 (>= 1.3.0)
libqt5core5a:amd64 (5.11.3+dfsg1-1+deb10u3) | libqt5core5a (>= 5.9.0~beta)
libqt5dbus5:amd64 (5.11.3+dfsg1-1+deb10u3) | libqt5dbus5 (>= 5.0.2)
libqt5gui5:amd64 (5.11.3+dfsg1-1+deb10u3) | libqt5gui5 (>= 5.2.0)
libqt5network5:amd64 (5.11.3+dfsg1-1+deb10u3) | libqt5network5 (>= 5.0.2)
libqt5qml5:amd64 (5.11.3-4) | libqt5qml5 (>= 5.1.0)
libqt5widgets5:amd64 (5.11.3+dfsg1-1+deb10u3) | libqt5widgets5 (>= 5.0.2)
libssl1.1:amd64 (1.1.1d-0+deb10u3) | libssl1.1 (>= 1.1.0)
libstdc++6:amd64 (8.3.0-6) | libstdc++6 (>= 5.2)
qml-module-qtquick2:amd64 (5.11.3-4) | qml-module-qtquick2
qml-module-qtquick-controls2:amd64 (5.11.3+dfsg-2) | qml-module-qtquick-controls2
qml-module-qt-labs-settings:amd64 (5.11.3-4) | qml-module-qt-labs-settings
qml-module-qtquick-layouts:amd64 (5.11.3-4) | qml-module-qtquick-layouts
qml-module-qtquick-templates2:amd64 (5.11.3+dfsg-2) | qml-module-qtquick-templates2
qml-module-qtquick-window2:amd64 (5.11.3-4) | qml-module-qtquick-window2
qml-module-qtgraphicaleffects:amd64 (5.11.3-2) | qml-module-qtgraphicaleffects
dosfstools (4.1-2) | dosfstools
fdisk (2.33.1-0.1) | fdisk
gdisk (1.0.3-1.1) <
libfdisk1:amd64 (2.33.1-0.1) <
■imager_amd64パッケージのインストール
$ sudo dpkg -i imager_amd64.deb
$ dpkg -L rpi-imager
/.
/usr
/usr/bin
/usr/bin/rpi-imager
/usr/share
/usr/share/applications
/usr/share/applications/rpi-imager.desktop
/usr/share/doc
/usr/share/doc/rpi-imager
/usr/share/doc/rpi-imager/changelog.gz
/usr/share/doc/rpi-imager/copyright
/usr/share/icons
/usr/share/icons/hicolor
/usr/share/icons/hicolor/128x128
/usr/share/icons/hicolor/128x128/apps
/usr/share/icons/hicolor/128x128/apps/rpi-imager.png
■rpi-imagerコマンドの確認
$ file /usr/bin/rpi-imager | sed -e 's/, /&\n /g'
/usr/bin/rpi-imager: ELF 64-bit LSB shared object,
x86-64,
version 1 (GNU/Linux),
dynamically linked,
interpreter /lib64/ld-linux-x86-64.so.2,
for GNU/Linux 3.2.0,
BuildID[sha1]=01a5d518d0b154a9d84e97c3a6610cc92048ce7d,
stripped
$ apt-file search bin/strings
9base: /usr/lib/plan9/bin/strings
binutils: /usr/bin/strings
$ strings /usr/bin/rpi-imager | grep "^\-\-"
--debug
--help
--version
--bytes
--json
--paths
--output-all
$ rpi-imager --version
rpi-imager version 1.3
Repository: https://downloads.raspberrypi.org/os_list_imagingutility.json
$ rpi-imager --help
rpi-imager [--debug] [--version] [--repo <repository URL>] [<image file to write>]
■rpi-imagerで出てくる[Choose]メニューはJSONなので、CLI/CUIでも確認できる。
$ w3m -dump https://downloads.raspberrypi.org/os_list_imagingutility.json | awk -F\" '/name/{print $(NF-1)}'
Raspberry Pi OS (32-bit)
Raspberry Pi OS (other)
Raspberry Pi OS Lite (32-bit)
Raspberry Pi OS Full (32-bit)
LibreELEC
Ubuntu
RetroPie
TLXOS
Misc utility images
Raspberry Pi 4 EEPROM boot recovery
■64bit版を優先して探す。
デスクトップPCおよびノートPC向けUbuntu LTS ServerがRaspberry Pi 4に対応していて、
64bit OSなのでこれをまず試すことにする。
$ w3m -dump https://changelogs.ubuntu.com/raspi/os_list_imagingutility_ubuntu.json | \
awk -F\" '/name|64.bit|amd64/{if($0 ~ /name/){print $(NF-1)}else{print " "$(NF-1)}}'
Ubuntu 20.04 LTS (Raspberry Pi 2/3/4)
Ubuntu 20.04 LTS (Raspberry Pi 3/4)
64-bit server OS for arm64 architectures
Ubuntu Core 18 (Raspberry Pi 2/3/4)
Ubuntu Core 18 (Raspberry Pi 3/4)
Ubuntu Core 18 64-bit IoT OS for arm64 architectures
■fdiskで読み取り確認
$ sudo fdisk -l /dev/sdb
Disk /dev/sdb: 59.5 GiB, 63864569856 bytes, 124735488 sectors
Disk model: Storage Device
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/sdb1 32768 124735487 124702720 59.5G 7 HPFS/NTFS/exFAT
$ sudo awk 'BEGIN{f=0}{if($0 ~ /detected/){f++;getline} \
{if(f > 0){a[f]=a[f]"__"$0}}} \
END{gsub("__","\n",a[f]);print a[f]}' /var/log/messages
Jul 11 22:57:59 acer-debian kernel: [171705.826380] scsi host6: usb-storage 3-4:1.0
Jul 11 22:57:59 acer-debian mtp-probe: checking bus 3, device 10: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-4"
Jul 11 22:57:59 acer-debian mtp-probe: bus: 3, device: 10 was not an MTP device
Jul 11 22:57:59 acer-debian mtp-probe: checking bus 3, device 10: "/sys/devices/pci0000:00/0000:00:14.0/usb3/3-4"
Jul 11 22:57:59 acer-debian mtp-probe: bus: 3, device: 10 was not an MTP device
Jul 11 22:58:00 acer-debian kernel: [171706.844852] scsi 6:0:0:0: Direct-Access MXT-USB Storage Device 1308 PQ: 0 ANSI: 0 CCS
Jul 11 22:58:00 acer-debian kernel: [171706.846161] sd 6:0:0:0: [sdb] 124735488 512-byte logical blocks: (63.9 GB/59.5 GiB)
Jul 11 22:58:00 acer-debian kernel: [171706.846306] sd 6:0:0:0: Attached scsi generic sg1 type 0
Jul 11 22:58:00 acer-debian kernel: [171706.846399] sd 6:0:0:0: [sdb] Write Protect is off
Jul 11 22:58:00 acer-debian kernel: [171706.852118] sdb: sdb1
Jul 11 22:58:00 acer-debian kernel: [171706.852946] sd 6:0:0:0: [sdb] Attached SCSI removable disk
Jul 11 22:58:01 acer-debian kernel: [171707.564383] fuse init (API version 7.27)
Jul 11 22:58:01 acer-debian udisksd[535]: Mounted /dev/sdb1 at /media/labunix/3665-3066 on behalf of uid 1000
sudo ls -l /sys/block/
合計 0
lrwxrwxrwx 1 root root 0 7月 9 23:16 sda -> ../devices/pci0000:00/0000:00:1f.2/ata1/host0/target0:0:0/0:0:0:0/block/sda
lrwxrwxrwx 1 root root 0 7月 11 22:58 sdb -> ../devices/pci0000:00/0000:00:14.0/usb3/3-4/3-4:1.0/host6/target6:0:0/6:0:0:0/block/sdb
$ sudo ls -l /dev/sdb
brw-rw---- 1 root disk 8, 16 7月 11 22:58 /dev/sdb
■MicroSDに書き込み
$ sudo rpi-imager
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to '/tmp/runtime-root'
QObject::setParent: Cannot set parent, new parent is in a different thread
Available disk space for caching: 17 GB
mountutils: Reading /proc/mounts
mountutils: Mount point /dev/sdb1 belongs to drive /dev/sdb
mountutils: Closing /proc/mounts
mountutils: Unmounting /media/labunix/3665-3066...
mountutils: Unmount MNT_EXPIRE /media/labunix/3665-3066: EAGAIN
mountutils: Unmount /media/labunix/3665-3066: success
Sector size: 512 Device size: 63864569856
Try to perform TRIM/DISCARD on device
BLKDISCARD not supported
Image URL: "http://cdimage.ubuntu.com/releases/focal/release/ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz"
Received header: HTTP/1.1 200 OK
Received header: Date: Sat, 11 Jul 2020 15:09:10 GMT
Received header: Server: Apache/2.4.18 (Ubuntu)
Received header: Last-Modified: Thu, 23 Apr 2020 15:21:10 GMT
Received header: ETag: "29b05e90-5a3f6cc64e580"
Received header: Accept-Ranges: bytes
Received header: Content-Length: 699424400
Received header: Content-Type: application/x-xz
Received header:
Download done in 7353 seconds
Write done in 7529 seconds
Hash of uncompressed image: "266e7762f9c0019cd7b0b3e469648a78d5d38eb9a95fc66ed075500895ab0fa5"
Done writing cache file
Verify done in 595.634 seconds
Verify hash: "266e7762f9c0019cd7b0b3e469648a78d5d38eb9a95fc66ed075500895ab0fa5"
Writing first block (which we skipped at first)
mountutils: Reading /proc/mounts
mountutils: Closing /proc/mounts
■手動で行う場合。手動の方が楽だと思うのは私だけだろうか。。。
$ lsb_release -d
Description: Debian GNU/Linux 10 (buster)
Install Ubuntu Server on a Raspberry Pi 2, 3 or 4
https://ubuntu.com/download/raspberry-pi
$ md5sum < ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz
b359567d8aa53de99f9a52ce75b80b47 -
■起動フラグ「0xAA55」があるのでそのまま書き込める。
$ whereis unxz
unxz: /usr/bin/unxz /usr/share/man/man1/unxz.1.gz
$ unxz ubuntu-20.04-preinstalled-server-arm64+raspi.img.xz
$ dd if=ubuntu-20.04-preinstalled-server-arm64+raspi.img bs=2 skip=255 count=1 | hexdump -C
1+0 レコード入力
1+0 レコード出力
2 bytes copied, 0.00067831 s, 2.9 kB/s
00000000 55 aa |U.|
■MicroSDが「sdb」なら、下記で書き込む
TARGETに各自の環境のデバイスに変える。
$ TARGET=/dev/sdb; \
sudo dd bs=4M if=ubuntu-20.04-preinstalled-server-arm64+raspi.img \
of=${TARGET} status=progress conv=fsync