0%

烧录树莓派镜像

通过命令行来烧录树莓派镜像到 SD 卡中

参考:https://blog.csdn.net/freewebsys/article/details/48980993

  1. 下载镜像

    去官网 https://www.raspberrypi.org/downloads/raspbian/ 下载镜像,我下载的是 RASPBIAN STRETCH LITE,也就是没有桌面的,会小很多。

  2. 在 OS X 下安装镜像

    1. 格式化 SD 卡

      官方推荐使用 sdcard formatter,操作简单点击下就行。

    2. 查看并卸载 SD 卡

      查看 SD 卡磁盘

      1
      2
      3
      4
      $ df -lh
      Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
      /dev/disk1 233Gi 215Gi 18Gi 93% 56386271 4592543 92% /
      /dev/disk2s1 30Gi 1.6Mi 30Gi 1% 0 0 100% /Volumes/21 1

      记住磁盘叫/dev/disk2s1

      1
      2
      $ sudo diskutil umount /dev/disk2s1                                
      Volume 21 on disk2s1 unmounted
    3. 写入镜像

      特别注意写入文件没有s1且前面多了个r,/dev/disk2s1对应的输出文件是/dev/rdisk2)

      1
      2
      3
      4
      $ sudo dd bs=1m if=2018-03-13-raspbian-stretch.img of=/dev/rdisk2  
      4125+0 records in
      4125+0 records out
      4325376000 bytes transferred in 401.205151 secs (10780958 bytes/sec)

rdisk 和 disk 的区别:

Why is “/dev/rdisk” about 20 times faster than “/dev/disk” in Mac OS X

According to the rasbery pi documentation, You can load your OS to a flash card with either /dev/disk or /dev/rdisk.

rdisk stands for raw disk.

/dev/disk is a block level device, why would rdisk be 20 times faster?

Using Mac OSX

Note: In OS X each disk may have two path references in /dev: /dev/disk# is a buffered device, which means any data being sent undergoes extra processing. /dev/rdisk# is a raw path, which is much faster, and perfectly OK when using the dd program. On a Class 4 SD card the difference was around 20 times faster using the rdisk path.

From man hdiutil:

/dev/rdisk nodes are character-special devices, but are “raw” in the BSD sense and force block-aligned I/O. They are closer to the physical disk than the buffer cache. /dev/disk nodes, on the other hand, are buffered block-special devices and are used primarily by the kernel’s filesystem code.

In layman’s terms /dev/rdisk goes almost directly to disk and /dev/disk goes via a longer more expensive route

坚持原创技术分享,您的支持将鼓励我继续创作!