树莓派的初次使用

记录树莓派的使用问题,兼顾原理。

1. TF卡格式化

原理:上次写镜像似乎做了物理分区,windows下只能识别/boot的40M。
方法:用工具覆盖TF卡,用SD卡协会(SD Association)的SD Card Formatter工具。

2. 镜像写入工具

原理:无需编译
方法:用Win32DiskImager-0.9.5-binary工具。

3. 连接WIFI

原理:(在boot分区写入)
方法:将刷好 Raspbian 系统的 SD 卡用电脑读取。在 boot 分区,也就是树莓派的 /boot 目录下新建 wpa_supplicant.conf 文件,按照下面的参考格式填入内容并保存 wpa_supplicant.conf 文件。

country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1

network={
	ssid="SSID"
	psk="password"
	key_mgmt=WPA-PSK
	priority=2
}

后续再次编辑此文件:

$ sudo vim /etc/wpa_supplicant/wpa_supplicant.conf

4. SSH

原理:同3。
方法:同样在/boot分区,新建一个空白文件,改名为ssh。

5. 配置树莓派

$ sudo raspi-config

6. SFTP

用户名和密码同ssh,端口22。

7. 更新源

http://www.raspbian.org/RaspbianMirrors
以上地址可以查看树莓派的所有镜像站

(1) 备份apt和系统更新源

sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
sudo cp /etc/apt/sources.list.d/raspi.list /etc/apt/sources.list.d/raspi.list.bak

(2) 改变apt和系统更新源

sudo vim /etc/apt/sources.list

改为

deb http://mirrors.ustc.edu.cn/raspbian/raspbian/ stretch main contrib non-free$
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspbian.org/raspbian/ stretch main contrib non-free rpi
sudo vim /etc/apt/sources.list.d/raspi.list

改为

deb http://mirrors.ustc.edu.cn/archive.raspberrypi.org/debian/ stretch main ui
# Uncomment line below then 'apt-get update' to enable 'apt-get source'
#deb-src http://archive.raspberrypi.org/debian/ stretch main ui

8. 更新一下试试

sudo apt-get update
sudo apt-get upgrade
sudo apt-get dist-upgrade
sudo rpi-update

9. 更新pip源()

查看pip版本

pip --version

修改源

$ sudo vim /etc/pip.conf
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple #清华源
extra-index-url = https://mirrors.aliyun.com/pypi/simple/
trusted-host = 
    pypi.tuna.tsinghua          #添加清华源为可信主机,要不然可能报错
    mirrors.aliyun.com        #清华
timeout = 120

清华:https://pypi.tuna.tsinghua.edu.cn/simple
阿里云:https://mirrors.aliyun.com/pypi/simple/
中国科技大学 https://pypi.mirrors.ustc.edu.cn/simple/
华中理工大学:http://pypi.hustunique.com/
豆瓣:http://pypi.douban.com/simple/

10. 安装和运行Docker(转自知乎)

由 Docker 项目维护的自动脚本将创建一个 systemd 服务文件,并将相关的 Docker 二进制文件复制到 /usr/bin/ 中。

$ sudo curl -sSL https://get.docker.com | sh

配置Docker:

(1) 配置镜像加速器

针对Docker客户端版本大于 1.10.0 的用户
通过修改daemon配置文件/etc/docker/daemon.json来使用加速器

sudo mkdir -p /etc/docker
sudo tee /etc/docker/daemon.json <<-'EOF'
{
  "registry-mirrors": ["https://xxxxxx.mirror.aliyuncs.com"]    #地址通过阿里云控制台查看
}
EOF
sudo systemctl daemon-reload
sudo systemctl restart docker

(2) 将 Docker 设置为自动启动。

$ sudo systemctl enable docker

您现在可以重新启动 Pi,或者通过以下方式启动 Docker 守护程序:

$ sudo systemctl start docker

(3) 启用 Docker 客户端

Docker 客户端只能由 root 或 docker 组的成员使用。将 pi 或您的等效用户添加到 docker 组:

$ sudo usermod -aG docker pi

进行此更改后,注销并重新连接到 ssh。

(4) 使用 Docker

支持 ARM 和 Raspberry Pi 是一项正在进行的项目,这意味着你应该知道几件事情。
如果从 Docker 集线器下拉 busybox 镜像,它将无法正常工作。这是因为内容是为常规 PC 或 x86_64 架构设计的。在将来版本的 Docker 中,正在为此修复此问题。

我们应该只尝试使用我们知道设计为在 ARM 上工作的镜像。目前没有严格的官方镜像,但 Docker 团队在前缀 arm32v6 下维护了一些实验镜像。

11. 安装Python(strech版本树莓派已安装python3.5,转自阿里云)

12. 路由器DHCP,树莓派设置确保不会冲突的静态IP接入

查询要修改的网卡

$ ifconfig

编辑如下文件:

$ sudo vim /etc/dhcpcd.conf

文件末尾写入

interface eth0(网卡,或wlan0)
static ip_address=192.168.1.66/24
static routers=192.168.1.1
static domain_name_servers=192.168.1.1 8.8.8.8
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值