OSX下给树莓派安装Raspbian系统

树莓派官网下载镜像

插入SD卡,用df命令查看当前已挂载的卷

1
2
3
4
5
6
7
JiaWeiGedeMBP:book gejw$ df -h
Filesystem Size Used Avail Capacity iused ifree %iused Mounted on
/dev/disk1 112Gi 80Gi 31Gi 72% 21068699 8254563 72% /
devfs 187Ki 187Ki 0Bi 100% 646 0 100% /dev
map -hosts 0Bi 0Bi 0Bi 100% 0 0 100% /net
map auto_home 0Bi 0Bi 0Bi 100% 0 0 100% /home
/dev/disk2s1 56Mi 19Mi 37Mi 34% 512 0 100% /Volumes/boot

对比Size和Name可以找到SD卡的分区在系统里对应的设备文件(这里是/dev/disk2s1),如果你有多个分区,可能还会有disk1s2之类的。

使用diskutil unmount将这些分区卸载:

1
2
JiaWeiGedeMBP:book gejw$ diskutil unmount /dev/disk2s1
Volume boot on disk2s1 unmounted

通过diskutil list来确认设备:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
JiaWeiGedeMBP:book gejw$ diskutil list
/dev/disk0
#: TYPE NAME SIZE IDENTIFIER
0: GUID_partition_scheme *121.3 GB disk0
1: EFI EFI 209.7 MB disk0s1
2: Apple_CoreStorage 120.5 GB disk0s2
3: Apple_Boot Recovery HD 650.0 MB disk0s3
/dev/disk1
#: TYPE NAME SIZE IDENTIFIER
0: Apple_HFS Macintosh HD *120.1 GB disk1
Logical Volume on disk0s2
90141AB8-C189-4966-AC2F-D97481F904DD
Unlocked Encrypted
/dev/disk2
#: TYPE NAME SIZE IDENTIFIER
0: FDisk_partition_scheme *7.9 GB disk2
1: Windows_FAT_32 boot 58.7 MB disk2s1
2: Linux 7.9 GB disk2s2

使用dd命令将系统镜像写入,需要特别特别注意disk后的数字,不能搞错!

(说明:/dev/disk2s1是分区,/dev/disk2是块设备)

1
JiaWeiGedeMBP:Downloads gejw$ sudo dd bs=4m if=2015-05-05-raspbian-wheezy.img of=/dev/disk2

经过几分钟的等待,出现下面的提示,说明SD卡刷好了:

1
2
3
462+1 records in
462+1 records out
1939865600 bytes transferred in 163.133220 secs (11891297 bytes/sec)

用diskutil unmountDisk卸载设备:

1
2
JiaWeiGedeMBP:Downloads gejw$ diskutil unmountDisk /dev/disk2
Unmount of all volumes on disk1 was successful

现在就可以拔下SD卡,插到树莓派上启动系统了。