树莓派NAS(一)——系统安装

安装官方系统 Raspbian Buster Lite(无桌面版)

树莓派

目前安装系统有两个途径,可以利用官方新出的 Raspberry Pi Imager 工具烧写系统,也可以下载系统镜像后利用 Etcher 或者 win32diskimager 进行烧写。项目选择安装官方的 Raspbian Buster Lite。

Raspberry Pi Imager 下载
Raspbian 系统镜像下载

我这里选择 Raspberry Pi OS Lite 无桌面版本

图片

请根据系统版本下载对应的工具,我是 Windows 10,因此对应的为 for Windows (x86|x64)。

格式化 SD 卡

打开下载好的 SD 卡格式化工具

图片

系统烧写

使用 Etcher 烧写

  1. 从上述链接中下载 Raspberry Pi OS Lite 系统镜像(下载为 zip 压缩文件,请解压为 img 文件)以及 Etcher 烧写工具。

  2. 将 SD 卡通过读卡器连接至你的电脑中,选择系统镜像、SD 卡盘符;点击 Flash! 进行烧写。

    图片

    使用 Raspberry Pi Imager 进行烧写我这里就不进行演示了,大致步骤与上述是一致的

配置

SSH 配置

默认系统 * 不开启 ssh 服务,根目录并新建空文件 ssh,不加后缀,即可启动时开始 ssh,方便远程连接

方法:将 SD 卡使用读卡器连接到 pc 上,打开 SD 卡盘符在 boot 分区下新建 “ssh” 文本文档,并删除后缀.txt

图片

WIFI 配置

  1. 在 boot 分区下新建 wpa_supplicant.conf 文档
  2. 打开 wpa_supplicant.conf 输入以下配置:可以用 network {} 同时配置多个无线网络
country=CN
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
network={
 ssid="WiFi名,不删除引号,不能有中文" 
 psk="密码,不删除引号" 
 priority=数字,数字越大代表优先级越高
}

network={
 ssid="第二个WiFi名"
 psk="第二个密码" 
 priority=数字,数字越大代表优先级越高 
}

启动连接树莓派

  1. 硬件连接并开机:将 SD 卡插入树莓派,打开电源开关,树莓派上的绿色指示灯会闪烁,说明系统正常。
  2. 获取树莓派的动态 IP 地址:直接在路由器后台中找到树莓派 ip 地址,或者使用 Advanced IP Scanner 获取。
  3. 利用 ssh 工具远程登录树莓派:可以使用任意你熟悉的 ssh 连接工具,我这里使用 FinalShell
  • 默认用户名密码:pi/raspberry
图片

连接成功:

The programs included with the Debian GNU/Linux system are free software;
the exact distribution terms for each program are described in the
individual files in /usr/share/doc/*/copyright.

Debian GNU/Linux comes with ABSOLUTELY NO WARRANTY, to the extent
permitted by applicable law.

SSH is enabled and the default password for the 'pi' user has not been changed.
This is a security risk - please login as the 'pi' user and type 'passwd' to set a new password.

pi@raspberrypi:~ $

更换软件源

软件源的选择

默认情况下,树莓派软件源地址是 http://archive.raspbian.org/,位于欧洲,在国内访问是非常慢的,经常只有几 k 每秒的下载速率。所以我们在玩转树莓派之前,强烈推荐替换成国内的软件源。

树莓派的所有软件源地址可以从这里找到:https://www.raspbian.org/RaspbianMirrors

一般我们找个国内的就行了,比如清华大学

图片

更换

  1. 备份原有文件
   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
  1. 修改
   sudo nano /etc/apt/sources.list

如下列所示,将原内容注释,添加清华软件源

   deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib
   deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib
   #deb http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi
   # Uncomment line below then 'apt-get update' to enable 'apt-get source'
   #deb-src http://raspbian.raspberrypi.org/raspbian/ buster main contrib non-free rpi

按 ctrl-o 保存,按 ctrl-x 关闭

/etc/apt/sources.list.d/raspi.list 如法炮制

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

更新系统,就会发现速度快了很多了

   sudo apt-get update -y && sudo apt-get upgrade -y

启用 root

  1. 设置 root 密码

      sudo passwd root
    
  2. 解锁 root 用户

      sudo passwd --unlock root
    
  3. 切换用户

      su root
    
  4. 修改 ssh 配置允许 root 登录

       sudo nano /etc/ssh/sshd_config
    
  5. 找到 PermitRootLogin, 取消注释并修改

    PermitRootLogin yes
    

至此,树莓派完成了烧写系统 + 无屏幕的无线 wifi 远程连接。

原文链接:树莓派NAS(一)——系统安装 枫殇NET开发

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容