(raspios下载链接)[https://www.raspberrypi.com/software/operating-systems]
不同的os版本:
例如,我下载的是Lite版本 2022-04-04-raspios-bullseye-arm64-lite.zip
(参考链接)[https://www.raspberrypi.com/documentation/computers/getting-started.html#installing-images-on-linux]
准备好sdcard, 使用lsblk -p
查看sdcard的主设备名
例如sdcard的设置名为 /dev/sdc
注意: sdc后面没有数字,带数字的为此设备下的子分区, 设备名千万不能弄错,否则将会破坏当前系统的数据。
unzip 2022-01-28-raspios-bullseye-arm64-lite.zip sudo dd if=2022-04-04-raspios-bullseye-arm64-lite.img of=/dev/sdc bs=4M conv=fsync status=progress
当dd command完成后,SD卡中的分区情况如下:
$ sudo parted /dev/sdb GNU Parted 3.3 Using /dev/sdb Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) print Model: Mass Storage Device (scsi) Disk /dev/sdb: 15.9GB Sector size (logical/physical): 512B/512B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 4194kB 273MB 268MB primary fat32 lba 2 273MB 1854MB 1581MB primary ext4
raspberry pi 3b+ 由于默认串口被蓝牙占用,如希望连接uart, 需要修改/boot/config.txt
添加: dtoverlay=disable-bt
username: pi
passwd: raspberry
发现2022-01-28-raspios-bullseye-arm64-lite.zip 这个版本,上述密码无法登录。
原因是raspios 修改了安全策略,要求在系统启动时设置用户名密码
参考资料: https://www.raspberrypi.com/news/raspberry-pi-bullseye-update-april-2022/
设置用户名密码
在sdcard boot分区下创建userconf.txt文件,文件的内容为 username:encrypted-password
username为设置的用户名, encrypted-password的生成方式如下:
echo 'mypassword' | openssl passwd -6 -stdin
系统系统后使用userconf.txt的配置创建用户名,并设置密码,系统系统后将删除userconf.txt
sudp raspi-config
选择 System Options -> Wireless Lan
进行设置
在/etc/wpasupplicant/wpasupplicant.conf 末尾添加如下配置
如果没有密码: network={ ssid=”你的无线网络ssid” key_mgmt=NONE } 如果使用WEP加密: network={ ssid=”你的无线网络ssid” key_mgmt=NONE wep_key0=”你的无线网络密码” } 如果使用WPA/WPA2加密: network={ ssid=”你的无线网络ssid” psk=”你的无线网络密码” key_mgmt=WPA-PSK priority=1 }
priority 表示连接优先级,数字越大优先级越高
scanssid 连接隐藏网络时,需要将scanssid设置为1
重启系统或者重启wpa_supplicant.service后就可以连上WIFI
systemctl restart wpa_supplicant.service
如果未能连接上WIFI,使用ipconfig查看无线网口是否已启用
如果网口未启动,则无线网卡可能是被rfkill禁用了
pi@raspberrypi:~ $ rfkill ID TYPE DEVICE SOFT HARD 0 wlan phy0 unblocked unblocked 1 bluetooth hci0 unblocked unblocked
如果wlan是blocked的状态,则执行 rfkill unblock wlan0 启用wlan0
查看当前时区:
pi@raspberrypi:~ $ date Sun 19 Jun 04:49:04 BST 2022 pi@raspberrypi:~ $ ls -l /etc/localtime lrwxrwxrwx 1 root root 33 Apr 4 15:30 /etc/localtime -> /usr/share/zoneinfo/Europe/London
当前的时间为BST伦敦时间,下面修改时区为Asia Chongqing
pi@raspberrypi:~ $ sudo ln -sf /usr/share/zoneinfo/Asia/Chongqing /etc/localtime pi@raspberrypi:~ $ date Sun 19 Jun 11:51:00 CST 2022
在这个网站查看raspbian支持的mirror list
http://www.raspbian.org/RaspbianMirrors
本文采用清华的源,使用说明见:
https://mirrors.tuna.tsinghua.edu.cn/help/raspbian/
修改 /etc/apt/sources.list
deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian-security bullseye-security main contrib non-free deb https://mirrors.tuna.tsinghua.edu.cn/debian/ bullseye-updates main contrib non-free
修改 /etc/apt/sources.list.d/raspi.list
deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ bullseye main
sudo apt-get install openssh-server
sudo systemctl enable ssh.server
重启后,上电即可默认打开sshd服务