raspberry pi 3B安装linux

1、下载http://mirrors.ustc.edu.cn/ubuntu-cdimage/releases/bionic/release/ubuntu-18.04.2-preinstalled-server-arm64+raspi3.img.xz,用dd写到sd卡。

2、网络配置。创建/etc/wpa_supplicant/wpa_supplicant-wlan0.conf ,设置内容:
ctrl_interface=/var/run/wpa_supplicant
update_config=1
eapol_version=1
ap_scan=1
fast_reauth=1
然后wpa_passphase “your essid” “your password” >> /etc/wpa_supplicant/wpa_supplicant-wlan0.conf
在/etc/systemd/network下增加30-wireless.network,内容:
[Match]
name=wlan0
[Network]
DHCP=yes
systemctl enable wpa_supplicant@wlan0
systemctl restart systemd-networkd
systemctl restart wpa_supplicant@wlan0

3、使用ssh.socket代替ssh服务,无ssh连接时,不需要起动sshd
systemctl disable ssh
systemctl enable ssh.socket

4、起动后,ssh无法连接,报reset by xxx, 用/usr/sbin/sshd -D -p 7755测试,发现输出读配置文件出错。
原因:/etc/ssh下
ssh_host_ecdsa_key
ssh_host_ecdsa_key.pub
ssh_host_ed25519_key
ssh_host_ed25519_key.pub
ssh_host_rsa_key
ssh_host_rsa_key.pub
文件大小都为0。
解决方法:用dpkd-reconfigure openssh-server重新配置。

5、安装配置minidla, 无法访问video, /var/log/minidlna.log出现: upnphttp.c:1366: error: Rejecting wide link /var/lib/minidlna/Videos/xxx.mp4。
原因:用了软连接。
解决方法:在/etc/minidlna.conf中加上:wide_links=yes

6、server版linux,不能自动挂载。
安装usbmount, 也无法自动挂载,可能与namespace相关[未测试]:
This link https://github.com/rbrito/usbmount/issues/2 has the solution.
Edit /lib/systemd/system/systemd-udevd.service and change the line
MountFlags=slave
to
MountFlags=shared
then reboot

解决方法:写脚本用pmount:
创建 /etc/udev/rules.d/usbstick.rules:
ACTION==“add”, KERNEL==“sd[a-z][0-9]”, TAG+=“systemd”, ENV{SYSTEMD_WANTS}=“usbstick-handler@%k”
创建/lib/systemd/system/[email protected]:
[Unit]
Description=Mount USB sticks
BindsTo=dev-%i.device
After=dev-%i.device
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/local/bin/cpmount /dev/%I
ExecStop=/usr/bin/pumount /dev/%I
创建/usr/local/bin/cpmount:
#!/bin/bash
PART=echo $1|cut -b 6-
FS_LABEL=lsblk -o name,label | grep ${PART} | awk '{print $2}'
if [ -z F S L A B E L ] t h e n / u s r / b i n / p m o u n t − − u m a s k 000 − − n o a t i m e − w − − s y n c / d e v / {FS_LABEL} ] then /usr/bin/pmount --umask 000 --noatime -w --sync /dev/ FSLABEL]then/usr/bin/pmountumask000noatimewsync/dev/{PART} /media/ P A R T e l s e / u s r / b i n / p m o u n t − − u m a s k 000 − − n o a t i m e − w − − s y n c / d e v / {PART} else /usr/bin/pmount --umask 000 --noatime -w --sync /dev/ PARTelse/usr/bin/pmountumask000noatimewsync/dev/{PART} /media/KaTeX parse error: Expected group after '_' at position 7: {PART}_̲{FS_LABEL}
fi
执行systemctl restart udev
来源:https://raspberrypi.stackexchange.com/questions/66169/auto-mount-usb-stick-on-plug-in-without-uuid

你可能感兴趣的:(Linux)