前几年买了个RaspberryPi 4B 8G,买了装的是32bit的Raspian OS Buster,一直没升级,因为官网说升级会丢失资料,当初花了不少时间自定义的就一直没去折腾,这几天闲着没事干想升级了
之前Buster按官网论坛置顶的不重新刷机教程,升级上去爆卡,muster进程动不动占用1整个CPU,决定还是推了从头做起重新安装整个SD卡上的操作系统
先上官网下个Raspian Imager,然后下了个64bit Bullseye的镜像烧到SD卡上,安装的时候点一下右下角设置图标,ssh先开了(建议先设置个你不常用的用户名,因为升级到Bullsye系统之后,你这里设置的用户名XRDP远程桌面是登录不进去的...)
我是插网线用的不需要设置Wi-Fi,如果你是准备用Wi-Fi+headless的话记得这里设置下Wi-Fi
SD插回去之后先sudo apt update然后sudo apt upgrade
允许不需要密码的sudo
sudo nano /etc/sudoers
#加这一行
pi ALL=(ALL:ALL) NOPASSWD:ALL #你想要的用户名不是pi的话就改一下
安装第一个必须软件XRDP
sudo apt install xrdp
#这时候你会发现进去是黑屏的连不上....因为伟大的树莓派基金会就是喜欢恶心人,现在已经shell登陆的用户是没法再GUI登陆的,最简单的解决方式是新建一个账号
sudo adduser pi #如果你本来在烧镜像那步设置的是pi就得改成别的
sudo usermod -a -G sudo pi
sudo usermod -a -G adm pi #这个要加不然远程连接会跳 "Authentication required to refresh system repositories"
安装OpenJDK(我自己软件要用,非必需)
sudo apt install default-jdk
自动装载外置硬盘
#不建议用自带的自动装载,因为有可能你插多个会自动改盘符.....或者需要输入密码才装载,太废了
#常用的盘最好还是自己写个自动装载
sudo blkid #看一下自己要挂载的盘是哪个,记录下UUID和文件系统类型
sudo mkdir -p /mnt/ssd
sudo nano /etc/fstab
#加进去这一行
UUID=[UUID] /mnt/ssd [TYPE] defaults,auto,users,rw,nofail,noatime 0 0
sudo mount -a
sudo chown -R pi:pi /mnt/ssd
sudo chmod 777 /mnt/ssd
更改DNS
sudo nano /etc/dhcpcd.conf
static domain_name_servers=DNS1 DNS2 #树莓派挂的联通线路,路由器DNS是电信的,改一下
sudo service dhcpcd restart
设置CloudFlare DDNS (ddclient)
sudo apt install ddclient
sudo nano /etc/ddclient.conf
syslog=yes
daemon=1h
use=web, web=ip.3322.org
ssl=yes
protocol=cloudflare
login=你的cloudflare注册邮箱
password=Global API key
zone=你的域名
DDNS域名
#https://github.com/ddclient/ddclient/releases
#看了下ddclient是在3.10版本加入了对cloudflare API token的支持
#但是树莓派的源还是3.9.1的所以确实完全不支持
#ddclient -help 看版本
安装WG
curl https://raw.githubusercontent.com/pi微皮恩/pi微皮恩/master/auto_install/install.sh | bash #自己改成3个英文字母 (国外回国用手下留情)
#如果卡的下载不来的话自己路由器上设置下代理这里给转发
#记得改成你路由器地址和正确端口
export https_proxy=http://192.168.2.1:3333 http_proxy=http://192.168.2.1:3333 all_proxy=socks5://192.168.2.1:23456
安装Samba+优化配置文件
Samba不优化的话至少在树莓派Buster上是超级慢的.........国内中文好像没什么优化资料
这份是按之前国外英文教程改的,去掉了几个东西,因为新版本Samba改了缓存逻辑了
目前用下来这个版本的Samba配置文件是最快的,能到50MBps,不优化各种10-30MBps...小文件甚至个位数。同样网络环境下试了下MacBook Pro自带的Samba,拷贝到Windows系统速度都差不多
sudo apt-get install samba samba-common-bin
sudo nano /etc/samba/smb.conf #看下面优化过后的例子,自己改下最下面要分享的路径
sudo smbpasswd -a pi #如果不是pi改成你要的用户名
sudo systemctl restart smbd
#
# Sample configuration file for the Samba suite for Debian GNU/Linux.
#
#
# This is the main Samba configuration file. You should read the
# smb.conf(5) manual page in order to understand the options listed
# here. Samba has a huge number of configurable options most of which
# are not shown in this example
#
# Some options that are often worth tuning have been included as
# commented-out examples in this file.
# - When such options are commented with ";", the proposed setting
# differs from the default Samba behaviour
# - When commented with "#", the proposed setting is the default
# behaviour of Samba but the option is considered important
# enough to be mentioned here
#
# NOTE: Whenever you modify this file you should run the command
# "testparm" to check that you have not made any basic syntactic
# errors.
#======================= Global Settings =======================
[global]
vfs objects = catia fruit streams_xattr
fruit:metadata = stream
fruit:model = RackMac
fruit:posix_rename = yes
fruit:veto_appledouble = no
fruit:wipe_intentionally_left_blank_rfork = yes
fruit:delete_empty_adfiles = yes
min protocol = SMB2
ea support = yes
socket options = TCP_NODELAY IPTOS_LOWDELAY
strict locking = no
server multi channel support = yes
log level = 1
disable spoolss = yes
show add printer wizard = no
disable netbios = yes
dns proxy = no
smb encrypt = off
security = user
use sendfile = yes
## Browsing/Identification ###
# Change this to the workgroup/NT-domain name your Samba server will part of
workgroup = WORKGROUP
#### Networking ####
# The specific set of interfaces / networks to bind to
# This can be either the interface name or an IP address/netmask;
# interface names are normally preferred
; interfaces = 127.0.0.0/8 eth0
# Only bind to the named interfaces and/or networks; you must use the
# 'interfaces' option above to use this.
# It is recommended that you enable this feature if your Samba machine is
# not protected by a firewall or is a firewall itself. However, this
# option cannot handle dynamic or non-broadcast interfaces correctly.
; bind interfaces only = yes
#### Debugging/Accounting ####
# This tells Samba to use a separate log file for each machine
# that connects
log file = /var/log/samba/log.%m
# Cap the size of the individual log files (in KiB).
max log size = 1000
# We want Samba to only log to /var/log/samba/log.{smbd,nmbd}.
# Append syslog@1 if you want important messages to be sent to syslog too.
logging = file
# Do something sensible when Samba crashes: mail the admin a backtrace
panic action = /usr/share/samba/panic-action %d
####### Authentication #######
# Server role. Defines in which mode Samba will operate. Possible
# values are "standalone server", "member server", "classic primary
# domain controller", "classic backup domain controller", "active
# directory domain controller".
#
# Most people will want "standalone server" or "member server".
# Running as "active directory domain controller" will require first
# running "samba-tool domain provision" to wipe databases and create a
# new domain.
server role = standalone server
obey pam restrictions = yes
# This boolean parameter controls whether Samba attempts to sync the Unix
# password with the SMB password when the encrypted SMB password in the
# passdb is changed.
unix password sync = yes
# For Unix password sync to work on a Debian GNU/Linux system, the following
# parameters must be set (thanks to Ian Kahan <<[email protected]> for
# sending the correct chat script for the passwd program in Debian Sarge).
passwd program = /usr/bin/passwd %u
passwd chat = *Enter\snew\s*\spassword:* %n\n *Retype\snew\s*\spassword:* %n\n *password\supdated\ssuccessfully* .
# This boolean controls whether PAM will be used for password changes
# when requested by an SMB client instead of the program listed in
# 'passwd program'. The default is 'no'.
pam password change = yes
# This option controls how unsuccessful authentication attempts are mapped
# to anonymous connections
map to guest = bad user
########## Domains ###########
#
# The following settings only takes effect if 'server role = primary
# classic domain controller', 'server role = backup domain controller'
# or 'domain logons' is set
#
# It specifies the location of the user's
# profile directory from the client point of view) The following
# required a [profiles] share to be setup on the samba server (see
# below)
; logon path = \\%N\profiles\%U
# Another common choice is storing the profile in the user's home directory
# (this is Samba's default)
# logon path = \\%N\%U\profile
# The following setting only takes effect if 'domain logons' is set
# It specifies the location of a user's home directory (from the client
# point of view)
; logon drive = H:
# logon home = \\%N\%U
# The following setting only takes effect if 'domain logons' is set
# It specifies the script to run during logon. The script must be stored
# in the [netlogon] share
# NOTE: Must be store in 'DOS' file format convention
; logon script = logon.cmd
# This allows Unix users to be created on the domain controller via the SAMR
# RPC pipe. The example command creates a user account with a disabled Unix
# password; please adapt to your needs
; add user script = /usr/sbin/adduser --quiet --disabled-password --gecos "" %u
# This allows machine accounts to be created on the domain controller via the
# SAMR RPC pipe.
# The following assumes a "machines" group exists on the system
; add machine script = /usr/sbin/useradd -g machines -c "%u machine account" -d /var/lib/samba -s /bin/false %u
# This allows Unix groups to be created on the domain controller via the SAMR
# RPC pipe.
; add group script = /usr/sbin/addgroup --force-badname %g
############ Misc ############
# Using the following line enables you to customise your configuration
# on a per machine basis. The %m gets replaced with the netbios name
# of the machine that is connecting
; include = /home/samba/etc/smb.conf.%m
# Some defaults for winbind (make sure you're not using the ranges
# for something else.)
; idmap config * : backend = tdb
; idmap config * : range = 3000-7999
; idmap config YOURDOMAINHERE : backend = tdb
; idmap config YOURDOMAINHERE : range = 100000-999999
; template shell = /bin/bash
# Setup usershare options to enable non-root users to share folders
# with the net usershare command.
# Maximum number of usershare. 0 means that usershare is disabled.
# usershare max shares = 100
# Allow users who've been granted usershare privileges to create
# public shares, not just authenticated ones
usershare allow guests = yes
#======================= Share Definitions =======================
[homes]
comment = Home Directories
browseable = no
# By default, the home directories are exported read-only. Change the
# next parameter to 'no' if you want to be able to write to them.
read only = yes
# File creation mask is set to 0700 for security reasons. If you want to
# create files with group=rw permissions, set next parameter to 0775.
create mask = 0700
# Directory creation mask is set to 0700 for security reasons. If you want to
# create dirs. with group=rw permissions, set next parameter to 0775.
directory mask = 0700
# By default, \\server\username shares can be connected to by anyone
# with access to the samba server.
# The following parameter makes sure that only "username" can connect
# to \\server\username
# This might need tweaking when using external authentication schemes
valid users = %S
# Un-comment the following and create the netlogon directory for Domain Logons
# (you need to configure Samba to act as a domain controller too.)
;[netlogon]
; comment = Network Logon Service
; path = /home/samba/netlogon
; guest ok = yes
; read only = yes
# Un-comment the following and create the profiles directory to store
# users profiles (see the "logon path" option above)
# (you need to configure Samba to act as a domain controller too.)
# The path below should be writable by all users so that their
# profile directory may be created the first time they log on
;[profiles]
; comment = Users profiles
; path = /home/samba/profiles
; guest ok = no
; browseable = no
; create mask = 0600
; directory mask = 0700
[printers]
comment = All Printers
browseable = no
path = /var/spool/samba
printable = yes
guest ok = no
read only = yes
create mask = 0700
# Windows clients look for this share name as a source of downloadable
# printer drivers
[print$]
comment = Printer Drivers
path = /var/lib/samba/printers
browseable = yes
read only = yes
guest ok = no
# Uncomment to allow remote administration of Windows print drivers.
# You may need to replace 'lpadmin' with the name of the group your
# admin users are members of.
# Please note that you also need to set appropriate Unix permissions
# to the drivers directory for these users to have write rights in it
; write list = root, @lpadmin
[ssd] #这个也可以改成你喜欢的名字
path = /mnt/ssd #改成你自己要分享的
writeable = yes
create mask = 0777
directory mask = 0777
public = no
启用BBR
sudo bash -c 'echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf'
sudo bash -c 'echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf'
安装BestTrace
wget https://cdn.ipip.net/17mon/besttrace4linux.zip
unzip besttrace4linux.zip
chmod +x besttracearm
./besttracearm -q 1 TestIP
#别的都可以删了,只需要arm那个
rm besttracebsd32
rm besttrace4linux.txt
rm besttracebsd
rm besttrace32
rm besttracemac
rm bestrace
大概就先这样了,超频什么就不折腾了,现在Bullseye自带1800了(Buster是1500),我的本来设置是2000
也还好没想象中那么恶心,至少本来我试出来的设置还能用,最恶心最花时间的是那个莫名其妙给你自动登录默认账号(headless的话你完全看不见这个账户的)然后你远程XRDP就连不上这个神秘设置
这么重要的东西你论坛不pin一下还得让人自己去找真的有点恶心..............安全归安全你至少说一声啊
从Buster升级上来时候有的Mutter占用一大堆CPU造成的卡顿也没了,应该是我之前魔改的时候设置了什么东西导致升级上来不兼容各种卡爆,最后还是得这样推了重新装系统
文章评论