2018年4月30日月曜日

Raspberry Pi Zero W でrpi-clone

Raspberry Pi Zero [|w] でrpi-cloneが動かないとの噂があります。
ホントか確かめてみました。

動作デバイス確認
# dmesg|grep Zero
[    0.000000] OF: fdt:Machine model: Raspberry Pi Zero W Rev 1.1

clone作成
# rpi-clone sda

Booted disk: mmcblk0 15.5GB                Destination disk: sda 2.0GB
---------------------------------------------------------------------------
Part      Size    FS     Label           Part   Size    FS     Label
1 /boot   43.5MB  fat32  --              1       2.0GB  fat32  --
2 root    15.4GB  ext4   --
---------------------------------------------------------------------------
== Initialize: IMAGE mmcblk0 partition table to sda - FS types mismatch ==
1 /boot               (21.5MB used)  : IMAGE     to sda1  FSCK
2 root                (1.6GB used)   : RESIZE(2.0GB) MKFS SYNC to sda2
---------------------------------------------------------------------------
Run setup script       : no
Verbose mode           : no
-----------------------:
** WARNING **          : All destination disk sda data will be overwritten!
                       :   The partition structure will be imaged from mmcblk0.
-----------------------:

Initialize and clone to the destination disk sda?  (yes/no): y
Optional destination  ext type file system label (16 chars max):

Initializing
  Imaging past the start of /boot partition 2.
  => dd if=/dev/mmcblk0 of=/dev/sda bs=1M count=50 ...
  Resizing last partition to end of disk ...
    Resize success.
  Changing destination Disk ID ...
  Delaying so partprobe can update /dev entries ...
  => fsck -p /dev/sda1 ...
  => mkfs -t ext4  /dev/sda2 ...

Syncing file systems (can take a long time)
Syncing mounted partitions:
  Mounting /dev/sda2 on /mnt/clone
  => rsync // /mnt/clone with-root-excludes ...

  Mounting /dev/sda1 on /mnt/clone/boot
  => rsync /boot/ /mnt/clone/boot  ...

Editing /mnt/clone/boot/cmdline.txt PARTUUID to use 3bc6e740
Editing /mnt/clone/etc/fstab PARTUUID to use 3bc6e740
===============================
Done with clone to /dev/sda
   Start - 08:24:22    End - 08:32:28    Elapsed Time - 8:06

Cloned partitions are mounted on /mnt/clone for inspection or customizing.

Hit Enter when ready to unmount the /dev/sda partitions ...
  unmounting /mnt/clone/boot
  unmounting /mnt/clone

旨く行きました。


2018年4月23日月曜日

boot Raspberry Pi3B+ from a USB mass storage device



















Raspberry Pi3B+ が入手できたのでちょっと触ってみました。

[デフォルト基本情報]

# cat /sys/devices/system/cpu/cpu0/cpufreq/scaling_cur_freq
600000
# cat /sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq
1400000

# vcgencmd measure_temp
temp=49.4'C

暑いね。

# iwconfig
wlan0     IEEE 802.11  ESSID:"hoge-ac"
          Mode:Managed  Frequency:5.18 GHz  Access Point: 84:AF:EC:17:87:94
          Bit Rate=200 Mb/s   Tx-Power=31 dBm
          Retry short limit:7   RTS thr:off   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=70/70  Signal level=-27 dBm
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:0   Missed beacon:0

速いね。。

#vcgencmd otp_dump | grep 17:
17:3020000a

予めusb boot modeとなっている。

[usb boot deviceの作成]

1. rpi-cloneのinstall
   #git clone https://github.com/billw2/rpi-clone.git
   # cd rpi-clone/
   #cp rpi-clone rpi-clone-setup /usr/local/sbin
2. usb memoryにclone作成
   (余ってた4GB USB memoryにclone作成)
# rpi-clone sda

Booted disk: mmcblk0 32.0GB                Destination disk: sda 4.0GB
---------------------------------------------------------------------------
Part      Size    FS     Label           Part   Size    FS     Label
1 /boot   58.4MB  fat16  --              1      58.4MB  fat16  --
2 root    31.4GB  ext4   --              2       4.0GB  ext4   --
---------------------------------------------------------------------------
== SYNC mmcblk0 file systems to sda ==
/boot                 (23.6MB used)  : SYNC to sda1 (58.4MB size)
/                     (1.6GB used)   : SYNC to sda2 (4.0GB size)
---------------------------------------------------------------------------
Run setup script       : no
Verbose mode           : no
-----------------------:

Ok to proceed with the clone?  (yes/no): y

Syncing file systems (can take a long time)
Syncing mounted partitions:
  Mounting /dev/sda2 on /mnt/clone
  => rsync // /mnt/clone with-root-excludes ...
  Mounting /dev/sda1 on /mnt/clone/boot
  => rsync /boot/ /mnt/clone/boot  ...

Editing /mnt/clone/boot/cmdline.txt PARTUUID to use 53c404bb
Editing /mnt/clone/etc/fstab PARTUUID to use 53c404bb
===============================
Done with clone to /dev/sda
   Start - 09:51:56    End - 09:58:57    Elapsed Time - 7:01

Cloned partitions are mounted on /mnt/clone for inspection or customizing.

Hit Enter when ready to unmount the /dev/sda partitions ...
  unmounting /mnt/clone/boot
  unmounting /mnt/clone

[USB device boot]
   microSDを外して、電源on
   無事、usb memoryからboot
 
  確認
   # dmesg|grep sda
[    4.244279] sd 0:0:0:0: [sda] 7897088 512-byte logical blocks: (4.04 GB/3.77 GiB)
[    4.255468] sd 0:0:0:0: [sda] Write Protect is off
[    4.261847] sd 0:0:0:0: [sda] Mode Sense: 00 00 00 00
[    4.262211] sd 0:0:0:0: [sda] Asking for cache data failed
[    4.269249] sd 0:0:0:0: [sda] Assuming drive cache: write through
[    4.398102]  sda: sda1 sda2
[    4.516456] sd 0:0:0:0: [sda] Attached SCSI removable disk
[    4.531982] EXT4-fs (sda2): mounted filesystem with ordered data mode. Opts: (null)
[    6.583668] EXT4-fs (sda2): re-mounted. Opts: (null)

# mount
/dev/sda2 on / type ext4 (rw,noatime,data=ordered)
/dev/sda1 on /boot type vfat (rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,errors=remount-ro)

# df -h
ファイルシス   サイズ  使用  残り 使用% マウント位置
/dev/root        3.6G  1.5G  1.9G   45% /
devtmpfs         484M     0  484M    0% /dev
tmpfs            489M     0  489M    0% /dev/shm
tmpfs            489M  6.5M  482M    2% /run
tmpfs            5.0M  4.0K  5.0M    1% /run/lock
tmpfs            489M     0  489M    0% /sys/fs/cgroup
/dev/sda1         56M   23M   34M   41% /boot
tmpfs             98M     0   98M    0% /run/user/0


この状態で、HDDに、clone作成してbootに成功
/boot/config.txt

program_usb_boot_timeout=1
が必要だった。