树莓派新系统无头初始化(bookworm)

发布于 2023-11-02  198 次阅读


10月10号,发布了树莓派新的更新,基于Debian 12 (bookworm),在此再次写一下其初始化教程。

下载树莓派镜像烧录器

在:www.raspberrypi.com/software/下载树莓派镜像烧录器,并进行安装。之前下载过可以更新一下,上一次写时候为1.7.1,更新后为1.8.1,支持了选择设备来选择镜像,对于无头操作的显示更加突出。

烧录树莓派镜像

打开镜像烧录器,可以发现比之前多了个选项,选择相应的树莓派开发板

之后选择操作系统,不管是否具有桌面,都建议下载64位版本的。之后选择相应的存储设备

请注意选择正确的存储设备,否则可能造成数据遗失!

在点击NEXT后发现直接弹出一个弹窗,在此我们可以编辑自己想要的无头配置,之后点击是。

静等完成即可。

连接树莓派

这次我直接将网线由树莓派直接接上电脑后无法直接使用raspberrypi.local来连接树莓派了,不知道是什么毛病,但是如果在无头设置里设置连接的无线网络就可正常连接。

在配置的同一网络的设备下使用

ssh 在无头设置里配置的主机名.local

来连接树莓派。

换源

先备份软件源

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

替换发现是Debian的软件源

sudo nano /etc/apt/sources.list

改为

# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-updates main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian/ bookworm-backports main contrib non-free non-free-firmware

deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware
# deb-src https://mirrors.tuna.tsinghua.edu.cn/debian-security bookworm-security main contrib non-free non-free-firmware

由于感觉官方软件源太慢,树莓派也不是严格的生产环境,所以替换了安全更新源,如果介意可以选择不替换。

Ctrl+X Y 回车 保存

修改系统源

sudo nano /etc/apt/sources.list.d/raspi.list

替换为:

deb https://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bookworm main

保存

sudo apt update && sudo apt upgrade

发现都是清华源,老快快,开心坏

桌面版可用VNC连接

  vncserver-virtual

用VNC Viewer 连接在 无头设置里配置的主机名.local:1 ,即可连接

换壁纸了,还挺好看

到此基本的初始化结束,可以继续搞事了!可以在Raspberry Pi Configuration里进一步设置

Authentication required. System policy prevents WiFi scans解决方法

进入后发现扫描网络时候一直要验证,解决方案是:

sudo nano /etc/polkit-1/localauthority/50-local.d/wifi.scan.pkl
[Allow Wifi Scan]
Identity=unix-user:*
Action=org.freedesktop.NetworkManager.wifi.scan;org.freedesktop.NetworkManager.enable-disable-wifi;org.freedesktop.NetworkManager.settings.modify.own;org.freedesktop.NetworkManager.settings.modify.system;org.freedesktop.NetworkManager.network-control
ResultAny=yes
ResultInactive=yes
ResultActive=yes

保存后即可,解决方案来自https://askubuntu.com/questions/1291512/authentication-required-system-policy-prevents-wifi-scans-in-focalfossa