樹莓派(一)鏡像燒寫及基礎(chǔ)配置
? ? ?大家好我是一個樹莓派愛好者,我在網(wǎng)上搜集和整理了樹莓派比較實(shí)用的玩法并錄制了視頻教程分享給大家,本文是視頻中所用到的命令方便大家跟著操作。如果你喜歡我的視頻歡迎幫忙推薦給其他小伙伴,如果你也有好玩的玩法也歡迎分享給我學(xué)習(xí)。本期是基礎(chǔ)下一期將結(jié)合docker分享更加實(shí)用的玩法(擁有docker你就擁有了世界^*^),包括homeassistant,openwrt等等。
1.?下載鏡像:https://www.raspberrypi.org/software/operating-systems/#raspberry-pi-os-32-bit
2.?燒寫工具--balenaEtcher
3.?設(shè)置分辨率:
sudo raspi-config
? ?Advanced Options -> Resolution”?>1280*720
4.?開啟ssh,VNC及camera??#方便無顯示器操作
5. 更換國內(nèi)鏡像源--清華源(https://mirror.tuna.tsinghua.edu.cn/help/raspbian/)
sudo nano /etc/apt/sources.list
? ? deb http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
? ? deb-src http://mirrors.tuna.tsinghua.edu.cn/raspbian/raspbian/ buster main non-free contrib rpi
sudo nano /etc/apt/sources.list.d/raspi.list
? ??deb http://mirrors.tuna.tsinghua.edu.cn/raspberrypi/ buster main ui
6.?安裝smaba??#方便給樹莓派上傳和下載文件
sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf???#編輯配置文件
[home]
???comment = public storage
???path = /home/pi
???valid users = pi
???read only = no
???create mask = 0777
???directory mask = 0777
???guest ok = no
???browseable = yes
?
[media]
???comment = public storage
???path = /media
???valid users = pi
???read only = no
???create mask = 0777
???directory mask = 0777
???guest ok = no
???browseable = yes
sudo smbpasswd -a pi ?#設(shè)置用戶名為pi的賬戶及密碼
sudo samba restart
sudo chmod -R 777 /home/pi ?#賦予讀寫權(quán)限
7.?安裝conky ?
sudo apt-get install conky ?#自定義(.conkyrc)文件放到文件目錄下,需要的(.conkycr)配置文件(可自行網(wǎng)上下載),下面的是我的配置分享給大家

#####################
# - Conky settings - #
######################
update_interval 1
total_run_times 0
net_avg_samples 1
cpu_avg_samples 1
if_up_strictness link
imlib_cache_size 0
double_buffer yes
no_buffers yes
uppercase no
use_spacer yes
format_human_readable
background = false
#####################
# - Text settings - #
#####################
use_xft yes
xftfont WenQuanYi Micro Hei:size=8
override_utf8_locale yes
text_buffer_size 2048
xftalpha 0.1
#############################
# - Window specifications - #
#############################
own_window_class Conky
own_window yes
own_window_type normal
own_window_transparent yes
own_window_argb_visual yes
own_window_argb_value 0
own_window_colour 000000
own_window_hints undecorated,below,sticky,skip_taskbar,skip_pager
alignment top_right
gap_x 5
gap_y 40
draw_shades no
draw_outline no
draw_borders no
draw_graph_borders no
default_color white
default_shade_color red
default_outline_color green
minimum_size 0 0
TEXT
${color yellow} ${font LCD:style=Bold:pixelsize=80}${time %H:%M}${font LCD:pixelsize=24} ${time %S}${font WenQuanYi Zen Hei:style=Bold:pixelsize=18}
${color white} ${alignc}${time %Y-%m-%d 星期%a}
${hr 2}
${font WenQuanYi Zen Hei:style=Bold:pixelsize=20}${color #FCFCFC}主機(jī): ${color}$alignr$nodename
${color #FFFFFF}開機(jī):${color}$alignr$uptime
${color #FFFFFF}CPU:${color blue} $cpu% $alignr${color red}$acpitemp°C
${color green}${cpubar 4 /}
${color #FFFFFF}內(nèi)存:${color}${alignr}$mem/$memmax
${membar 4 /}
${color #FFFFFF}磁盤: ${color}${alignr}${fs_used /}/${fs_size /}
${fs_bar 4 /}
${color #FFFFFF}硬盤: ${color}${alignr}${fs_used /media/zhb/0e0482d4-c97f-4b77-aecc-da28fa3c28c71}/${fs_size /media/zhb/0e0482d4-c97f-4b77-aecc-da28fa3c28c71}
${fs_bar 4 /media/zhb/0e0482d4-c97f-4b77-aecc-da28fa3c28c71}
# 列出排名前三的CPU消耗進(jìn)程
${font :bold:size=9}CPU占用 $alignc?
PID $alignr CPU $font
${top name 1} $alignc ${top pid 1} $alignr ${top cpu 1}%
${top name 2} $alignc ${top pid 2} $alignr ${top cpu 2}%
${top name 3} $alignc ${top pid 3} $alignr ${top cpu 3}%
#$alignc ${top pid 3} $alignr ${top cpu 3}%
${top name 4} $alignc ${top pid 4} $alignr ${top cpu 4}%
${top name 5} $alignc ${top pid 5} $alignr ${top cpu 5}%
# 列出排名前三的內(nèi)存消耗進(jìn)程
${font :bold:size=9}內(nèi)存占用 $alignc?
PID $alignr RAM $font
${top_mem name 1} $alignc ${top_mem pid 1} $alignr ${top_mem mem 1}%
${top_mem name 2} $alignc ${top_mem pid 2} $alignr ${top_mem mem 2}%
${top_mem name 3} $alignc ${top_mem pid 3} $alignr ${top_mem mem 3}%
${top_mem name 4} $alignc ${top_mem pid 4} $alignr ${top_mem mem 4}%
${top_mem name 5} $alignc ${top_mem pid 5} $alignr ${top_mem mem 5}%
#SYSTEM
${goto 120}${voffset -7}${stippled_hr}
${goto 120}${voffset 1}${font WenQuanYi Zen Hei=Bold:size=9}內(nèi)核: ${alignr}${kernel}${font}
#CPU
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}CPU1: ${cpu cpu1}% ${alignr}${cpubar cpu1 8,120}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}CPU2: ${cpu cpu2}% ${alignr}${cpubar cpu2 8,120}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}CPU3: ${cpu cpu3}% ${alignr}${cpubar cpu3 8,120}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}CPU4: ${cpu cpu4}% ${alignr}${cpubar cpu4 8,120}${font}
#DISK
${voffset 5}${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}硬盤讀取速度:${alignr}${color green}${diskio_read}${font}
${goto 120}${color white}${font WenQuanYi Micro Hei:style=Bold:size=9}硬盤寫入速度:${alignr}${color red}${diskio_write}${font}
#NETWORK
${goto 120}${voffset 7}${color white}${font WenQuanYi Zen Hei:style=Bold:size=9}網(wǎng)絡(luò)${alignr}${font}
${goto 120}${voffset -7}${stippled_hr}
${goto 120}${voffset 1}${font WenQuanYi Zen Hei:style=Bold:size=9}WiFi:${alignr}IP: ${addr wlo1}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}下載: ${color green}${downspeed wlo1}/s${color white}${alignr}SUM: ${totaldown wlo1}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}上傳: ${color red}${upspeed wlo1}/s${color white}${alignr}SUM: ${totalup wlo1}${font}
${goto 120}${voffset 5}${font WenQuanYi Zen Hei:style=Bold:size=9}LAN:${alignr}IP: ${addr macvlan}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}下載: ${downspeed eth0}/s${alignr}SUM: ${totaldown eth0}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}上傳: ${upspeed eth0}/s${alignr}SUM: ${totalup eth0}${font}
#PROCESSES
${goto 120}${voffset 7}${font WenQuanYi Zen Hei:style=Bold:size=9}進(jìn)程${alignr 55}PID${alignr 20}CPU (%)${alignr}RAM (%)${font}
${goto 120}${voffset -7}${stippled_hr}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 1}${goto 240}${top_mem pid 1}${goto 300}${top_mem cpu 1}${alignr }${top_mem mem 1}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 2}${goto 240}${top_mem pid 2}${goto 300}${top_mem cpu 2}${alignr }${top_mem mem 2}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 3}${goto 240}${top_mem pid 3}${goto 300}${top_mem cpu 3}${alignr }${top_mem mem 3}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 4}${goto 240}${top_mem pid 4}${goto 300}${top_mem cpu 4}${alignr }${top_mem mem 4}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 5}${goto 240}${top_mem pid 5}${goto 300}${top_mem cpu 5}${alignr }${top_mem mem 5}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 6}${goto 240}${top_mem pid 6}${goto 300}${top_mem cpu 6}${alignr }${top_mem mem 6}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 7}${goto 240}${top_mem pid 7}${goto 300}${top_mem cpu 7}${alignr }${top_mem mem 7}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 8}${goto 240}${top_mem pid 8}${goto 300}${top_mem cpu 8}${alignr }${top_mem mem 8}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 9}${goto 240}${top_mem pid 9}${goto 300}${top_mem cpu 9}${alignr }${top_mem mem 9}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 10}${goto 240}${top_mem pid 10}${goto 300}${top_mem cpu 10}${alignr }${top_mem mem 10}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 11}${goto 240}${top_mem pid 11}${goto 300}${top_mem cpu 11}${alignr }${top_mem mem 11}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 12}${goto 240}${top_mem pid 12}${goto 300}${top_mem cpu 12}${alignr }${top_mem mem 12}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 13}${goto 240}${top_mem pid 13}${goto 300}${top_mem cpu 13}${alignr }${top_mem mem 13}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 14}${goto 240}${top_mem pid 14}${goto 300}${top_mem cpu 14}${alignr }${top_mem mem 14}${font}
${goto 120}${font WenQuanYi Micro Hei:style=Bold:size=9}${top_mem name 15}${goto 240}${top_mem pid 15}${goto 300}${top_mem cpu 15}${alignr }${top_mem mem 15}${font}
8.?設(shè)置中文字體:
sudo apt install ttf-wqy-zenhei
9.?內(nèi)存交換空間swap 更改
sudo nano /etc/dphys-swapfile
#默認(rèn)為 ?CON_SWAPSIZE= 100 M的交換空間, ?更改為 2048 M
#重新啟動dphys-swapfile 文件服務(wù)
sudo /etc/init.d/dphys-swapfile stop
sudo /etc/init.d/dphys-swapfile start
free -m? ? ?#查看 ?交換空間大小
10.?顯示bilibili粉絲數(shù)感謝這位UP 主提供的方案(https://www.bilibili.com/video/BV1at411g7g7)
網(wǎng)址:https://dmscode.github.io/simple-tool-pages/bilibili-fans/#你的ID
把“你的ID”換成 B 站數(shù)字 ID ,用 Chrome 打開,然后從菜單里創(chuàng)建快捷方式。用快捷方式打開就行了。

怎樣把在用的樹莓派系統(tǒng)制作成鏡像文件參看以下方法:
可以使用 Raspberry Pi 上的 dd
命令來創(chuàng)建一個可燒寫的鏡像文件,步驟如下:
首先,使用以下命令來查看您正在運(yùn)行的 Raspberry Pi 上已經(jīng)安裝了哪些設(shè)備:
命令:
lsblk
找到您的 SD 卡設(shè)備。通常,它的名稱類似于
/dev/mmcblk0
。使用以下命令將 SD 卡上的內(nèi)容復(fù)制到一個鏡像文件中:
命令:
sudo dd if=/dev/mmcblk0 of=myimage.img bs=1M
其中,
if
參數(shù)指定輸入設(shè)備(即 SD 卡),of
參數(shù)指定輸出文件(即鏡像文件),bs
參數(shù)指定每個塊的大小。等待命令完成。這可能需要一些時間,具體取決于 SD 卡的大小和速度。
將生成的鏡像文件復(fù)制到另一個計算機(jī)或存儲設(shè)備中,以便之后可以使用燒寫工具將其燒寫到其他 SD 卡上。
請注意,這個過程會完全復(fù)制 SD 卡上的內(nèi)容,包括所有數(shù)據(jù)和分區(qū)。因此,如果您不希望鏡像文件包含某些數(shù)據(jù)或分區(qū),請在運(yùn)行 dd
命令之前手動刪除這些內(nèi)容。