树莓派初始化指导
一、下载镜像
https://www.raspberrypi.org/downloads/
以2016-03-18-raspbian-jessie-lite.zip为例,解压后得到img镜像文件,2016-03-18-raspbian-jessie-lite.img
二、写入镜像
参考官方指导https://www.raspberrypi.org/documentation/installation/installing-images/README.md
mac下,使用磁盘工具选中tf卡,点击标题栏的卸载,不能使用磁盘旁的推出,然后点标题栏的简介,查看bsd设备信息为disk[n]
终端下执行命令sudo dd bs=1m if=path_of_your_image.img of=/dev/rdiskn
大概一分钟会提示
sudo dd bs=1m if=/Users/will/Downloads/2016-03-18-raspbian-jessie-lite.img of=/dev/rdisk2
1298+0 records in
1298+0 records out
1361051648 bytes transferred in 80.072479 secs (16997746 bytes/sec)
写入成功。
三、初始化配置
1.ssh登录树莓派
插卡开机,网线接入路由器,路由器中查看分配给树莓派的ip地址
终端ssh pi@ip 密码是raspberry
2.登录后开启root账号
sudo passwd root
输入root的密码
然后su切换到root账号下
3.使用树莓派自带配置工具raspi-config
修改pi账号密码,使用passwd会提示弱密码
扩展储存卡
Expand Filesystem
设置时区和键盘
选择Internationalisation Options
4.然后修改软件源,
nano /etc/apt/sources.list(raspbian下的vi有点问题方向键和删除键会输出其他字符,nano也挺好用)
把默认软件源替换为清华的源,http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/
5.配置网络
查看网络配置cat cat /etc/network/interfaces
输出如下
interfaces(5) file used by ifup(8) and ifdown(8)
Please note that this file is written to be used with dhcpcd
For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'
Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
auto lo
iface lo inet loopback
iface eth0 inet manual
allow-hotplug wlan0
iface wlan0 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
allow-hotplug wlan1
iface wlan1 inet manual
wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf
修改wifi配置文件
nano /etc/wpa_supplicant/wpa_supplicant.conf
添加
network={
ssid="wahaha"
psk="12345678"
}
如果wifi没有密码则是这种格式:
network={
ssid="wahaha"
key_mgmt=NONE
}
至此树莓派初始化基本完毕。