一,准备工作
1,下载镜像:官网地址 :https://www.raspberrypi.org/downloads/
选择官方镜像raspbian 点击后有两个选项:
- RASPBIAN STRETCH WITH DESKTOP(带可视化桌面操作)
- RASPBIAN STRETCH LITE (轻量级系统)
这里选择下载第一个带操作界面的,下载镜像到自己的mac。
2,下载SD Card Formatter:
https://www.sdcard.org/downloads/formatter_4/
3,下载Etcher:
https://www.sdcard.org/downloads/formatter_4/https://mac.softpedia.com/get/Utilities/Etcher.shtml
二,安装系统
- 格式化sd卡,新版mac找个有sd卡接口的转换器。
- 打开Etcher 选择下载好的镜像,选择sd卡,点击开始,等待完成。
- 打开sd卡,新建一个空的名字为“ssh”的文件,复制到sd卡根目录(boot目录)
- 把sd卡插入树莓派,上电插网线。
- 打开自己的路由器管理页面,查找连接的设备,找到树莓派的ip地址。例如:192.168.1.230
- 用Iterm2 连接树莓派(mac和树莓派在同一网段)。用户名:pi 密码:raspberry
- 登录成功。
ssh pi@192.168.1.230
#这里地址换成你自己的树莓派ip
注:树莓派Raspberry系统默认开启ssh功能; 新版默认是关闭ssh的;需要一个空白文件做标识。
三,系统升级
1) 修改 /etc/apt/sources.list 文件
先下个vim你懂的:
sudo apt-get install vim
修改sources.list:
sudo vim /etc/apt/sources.list
看到原文件为:
deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
# deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
修改为:
deb http://mirrors.shu.edu.cn/raspbian/raspbian/ stretch main contrib non-free rpi
# deb http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
# deb-src http://raspbian.raspberrypi.org/raspbian/ stretch main contrib non-free rpi
2) 更新列表
sudo apt-get update&& sudo apt-get -y dist-upgrade&&sudo apt-get update
reboot (重启)
##如果遇到iptable_nat模块无法加载的情况可能是这个模块没有加载到内核。
//加载iptable模块到内核:
modinfo iptable_nat
四,使用create_ap 开启热点
1)创建WiFi热点使用的GitHub上一个开源项目:
https://github.com/oblique/create_ap
2)将代码copy到本地,安装
sudo git clone https://github.com/oblique/create_ap
cd create_ap
sudo make install
3)安装依赖的库
sudo apt-get install util-linux procps hostapd iproute2 iw haveged dnsmasq
4)此时你可以创建热点,通过以下命令:
sudo create_ap --no-virt wlan0 eth0 'pi3' 12345678
pi3:热点名
12345678:密码
此时即可用移动设备连接你创建的网络!
##如果开启热点失败:
执行:
rfkill list
#得到的结果是
soft blocked: yes
hard blocked: no
然后执行:
rfkill unblock wifi
#然后上面的两项都变成 no 了,重新使用开启热点命令:sudo create_ap --no-virt wlan0 eth0 'pi3' 12345678
5)设置开机启动:
sudo nano /usr/lib/systemd/system/create_ap.service
然后在最下方加上下面语句:
ExecStart=/usr/bin/create_ap -n wlan0 eth0 热点名 密码
保存退出,然后执行一下语句:
systemctl daemon-reload
systemctl enable create_ap.service
systemctl start create_ap.service
reboot
五,安装最新版docker-ce
1.查看Linux系统信息
nuame -a
#Linux raspberrypi 4.14.69-v7+ #1141 SMP Mon Sep 10 15:26:29 BST 2018 armv7l GNU/Linux
本机为:Debian 9 armhr
2.查看Linux 系统发行版的名称
lsb_release -cs
本机为:stretch
3.进入到下载包页面:
https://download.docker.com/linux/
4.点击进入debian>dists>stretch>pool>stable>armhf
看到适合本机的docker-ce列表选择合适的下载
wget https://download.docker.com/linux/debian/dists/stretch/pool/stable/armhf/docker-ce_18.06.1~ce~3-0~debian_armhf.deb
5.安装docker-ce
sudo dpkg -i docker-ce_18.06.1~ce~3-0~debian_armhf.deb
6.验证:
sudo docker -v
//Docker version 18.06.1-ce, build e68fc7a 安装成功