ArchLinux 問題集錦

jokerpoker發表於2024-07-26

電腦使用Android的網路

sudo pacman -S usb_modeswitch 

手機開啟網路共享

Android使用usb連線電腦網路

yay -S gnirehte
gnirehtet run

Android 投屏到電腦

sudo pacman -S scrcpy
scrcpy

Plasma KDE Screen Locking Picture of the Day 每日一圖的圖片快取位置

image

~/.cache/plasma_engine_potd

Where is Bing's Picture of the Day stored on my system?

Gwenview支援avif格式圖片

sudo pacman -S kimageformats shared-mime-info  libavif

EXT4 分割槽修復

檢查檔案系統並在發現任何錯誤時進行修復

umount /dev/sdb3
e2fsck -p /dev/sdb3

NTFS硬碟無法開啟

fdisk -l # 檢視硬碟名稱
sudo mount -t ntfs3 /dev/sdc1 /mnt 
# 報錯
mount: /mnt: wrong fs type, bad option, bad superblock on /dev/sdc1, missing codepage or helper program, or other error.
       dmesg(1) may have more information after failed mount system call.

#修復
sudo ntfsfix -d /dev/sdc1
sudo mount -t ntfs3 /dev/sdc1 /mnt  

配置DNS

建立修改配置檔案

vim /etc/NetworkManager/conf.d/01-dns.conf 

加入以下兩行,防止NetworkManager修改resolv.conf檔案

[main]
dns=none  

修改隱藏許可權,去掉只讀

lsattr /etc/resolv.conf
chattr -i /etc/resolv.conf
vim /etc/resolv.conf 

加入以下兩行

nameserver 223.5.5.5 # 阿里巴巴
nameserver 223.6.6.6 # 阿里巴巴
nameserver 8.8.8.8
nameserver 8.8.4.4
systemctl restart NetworkManager 

chattr +i /etc/resolv.conf # 加上只讀隱藏許可權
lsattr /etc/resolv.conf

使用DOH 加密DNS

pacman -S dns-over-https

修改hosts順序

vim /etc/nsswitch.conf 
hosts: myhostname mymachines resolve [!UNAVAIL=return] files dns

配置DOH客戶端

vim /etc/dns-over-https/doh-client.conf

修改

upstream_selector = "weighted_round_robin"

增加DOH地址

[[upstream.upstream_ietf]]
    url = "https://223.5.5.5/dns-query"
    weight = 50

修改 /etc/resolv.conf 檔案

nameserver ::1
nameserver 127.0.0.1
options edns0 single-request-reopen

設定開機自啟並立即啟動

sudo systemctl start doh-client.service 
sudo systemctl enable --now doh-client.service
sudo systemctl status doh-client.service # 服務的狀態
sudo systemctl restart doh-client.service
sudo systemctl is-enabled doh-client.service #是否開機時啟動
sudo systemctl list-units --type=service #檢視系統中所有正在執行的服務以及它們的狀態

檢視是否生效

pacman -S dnsutils
nslookup www.baidu.com # 顯示是本地IP則已經生效
Server:         ::1
Address:        ::1#53

在 Arch Linux 使用 DOH 來加密你的 DNS

pacman -Syu時,error: could not open file /var/lib/pacman/local/cemu-2.0.439-2/files: No such file or directory

ls檢視此目錄顯示cannot access 'desc': Structure needs cleaning。

用一下方法:

sudo rm -r /var/lib/pacman/local/cemu-2.0.439-2
sudo pacman -S --dbonly cemu

不行再嘗試以下:

$df -h
/dev/sdb3        12G  2.0G  9.2G  18% /var
## 備份sdb3
dd if=/dev/sdb3 of=/path/to/backup.img bs=1M
# 重啟系統,進入命令介面
$umount /dev/sdb3 # 解除安裝
$fsck.ext4 /dev/sdb3 -y # 修復
# 重啟檢視,若進入系統有問題,需要恢復備份
$dd if=/path/to/backup.img of=/dev/sdb3 bs=1M

Linux備份與恢復的命令和使用方式:保障資料安全和業務連續性

[問題] Wifi連線時間長,wifi連線時斷時連

由於iwd和NetworkManager連線網路產生了衝突,進行以下操作並重啟

systemctl list-unit-files # 檢視iw是否開啟
# 下面顯示都開啟,需要關閉iwd
iwd.service                                enable        disabled
NetworkManager.service                     enabled         disabled
# 確保iwd開機處於關閉狀態
sudo systemctl disable iwd  
# 立即關閉iwd
sudo systemctl stop iwd   
# 啟動NetworkManager
sudo systemctl enable --now NetworkManager                     

Arch配置安裝使用

[問題] wine啟動某些應用,後臺沒報錯,介面不顯示

去WineHQ檢視相關應用說明,檢視是否需要安裝元件或字型

$ winetricks mfc42
$ winetricks droid

[問題] wine報錯winediag:ntlm_check_version ntlm_auth was not found. Make sure that ntlm_auth >= 3.0.25 is in your path. Usually, you can find it in the winbind package of your distribution.

pacman -S samba

[問題]service:scmdatabase_autostart_services Auto-start service L"WineBus" failed to start: 105

How to prevent Wine from launching native mono apps?

$ xdg-mime query default application/x-ms-dos-executable 

[問題]wine執行exe時報錯誤 [VGL] ERROR: Could not open display :8

使用以下命令執行

optirun bash -c "wine [your game] && wineserver -w"

[VGL] ERROR: Could not open display :8 if a program forks and exits optirun #42

[問題] ArchLinux下開啟MagicSysRq組合鍵

用於系統完全當機時,重新啟動計算機

Alt+SysRq+REISUB,簡單記憶為「Reboot Even If System Utterly Broken」

開啟方法:

以下程式碼寫入檔案:/etc/sysctl.d/99-sysctl.conf

kernel.sysrq = 1

然後過載系統所有配置或者僅過載 /etc/sysctl.d/99-sysctl.conf 配置檔案:

sudo sysctl --system
sudo sysctl --load=/etc/sysctl.d/99-sysctl.conf

參考

[問題]pacman 設定代理

export http_proxy="..."
export https_proxy="..."

sudo -E pacman -Syu
# 或者修改 /etc/sudoers
Defaults env_keep += "ftp_proxy http_proxy https_proxy no_proxy"

參考

[問題]pacman 更新失敗後,啟動報錯

大機率是連線伺服器更新失敗

1、 sudo pacman -Syu 更新時大量報錯

==> ERROR: module not found: 'usbhid'
==> ERROR: module not found: xxxx
==> WARNING: No modules were added to the image. This is probably not what you want.

解決:不要重啟,需要重新執行命令

sudo pacman -S linux #重灌linux
sudo mkinitcpio -P linux  #重新生成映象

2、重啟後報錯

mount: /new_root:unknown filesystem type 'ext4'.
dmesg(1) may have more information after failed mount system call.
You are new being dropped into an emergency shell.
sh: can`t access tty; job control turned off

檢視pacman日誌

...
creating zstd-compressed initcpio image: '/boot/initramfs-linux-faillback.img'
WARNING: No modules were added to the image.This is probably not what you want.
Running build hook:[fsck]
ERROR: module not found: 'ps2mult'
ERROR: module not found: 'ps2_gpio'
...

解決:

若已經進不去系統,則用Live CD啟動linux

# 1.連線網路
iwctl                           #執行iwctl命令,進入互動式命令列
device list                     #列出裝置名,比如無線網路卡看到叫 wlan0
station wlan0 scan              #掃描網路
station wlan0 get-networks      #列出網路 比如想連線YOUR-WIRELESS-NAME這個無線
station wlan0 connect YOUR-WIRELESS-NAME #進行連線 輸入密碼即可
exit                            #成功後exit退出
# 2.根據系統情況掛在目錄
mount /dev/sdb2  /mnt
mount /dev/sda1 /mnt/efi
mount /dev/sda3 /mnt/var
mount /dev/sda4 /mnt/home

# 3.重新安裝linux
arch-chroot /mnt
pacman -S linux

若不行可以降級系統,去/var/cache/pacman/pkg 尋找舊的安裝包,命令例如:

># pacman -U linux-3.5.6-1-x86_64.pkg.tar.xz linux-headers-3.5.6-1-x86_64.pkg.tar.xz virtualbox-host-modules-4.2.0-5-x86_64.pkg.tar.xz

[問題]系統報 Failed to create sink input: sink is suspended 錯誤

應該是由於PulseAudio的問題導致,建議直接用新一代PipeWire替換掉PulseAudio和Jack即可解決。

# 1.關掉,禁用pulseaudio的服務和socket
$ systemctl --user stop pulseaudio.{service,socket}
$ systemctl --user disable pulseaudio.{service,socket}
# 2.安裝
$ pacman -S pipewire pipewire-pulse pipewire-jack #選裝 pipewire-alsa
$ pacman -S wireplumber # 會話管理器
# 3.啟動
$ systemctl --user start pipewire pipewire-pulse

使用PipeWire取代PulseAudio

[問題]密碼忘記或誤修改檔案導致無法登入系統

1,GNU GRUB version中選中Arch Linux
2,按e鍵進入修改介面
3,在linux /boot/vmlinuz-linux 一行末尾加入 init =/bin/bash
4,按ctrl+x或F10,進入單使用者模式
5,此時已經可以修改檔案,去將誤修改的檔案還原即可
6,重新以讀寫的方式掛載根檔案系統

# mount -n -o remount,rw /

7,修改root密碼

# passwd
‘password updated successfully’.

8,最後,執行下面的命令來儲存更改並啟動ArchLinux。

# exec /sbin/init

原帖

[問題]系統hibernate後喚醒時畫面卡死,有時需要等待幾分鐘後才能操作,或一直卡死

lsblk -f # 檢視根目錄/的UUID

配置GRUB_CMDLINE_LINUX_DEFAULT,加入

root=UUID=0a3407de-014b-458b-b5c1-848e92a327a3

/etc/default/grub完整如下:

GRUB_CMDLINE_LINUX_DEFAULT="loglevel=5 nowatchdog root=UUID=560a74f2-582b-45c8-99c7-5572e592e263 resume=UUID=560a74f2-582b-45c8-99c7-5572e592e263 resume_offset=745472"

Hibernate doesn't work after hibernate

Persistent block device naming

[問題]解除安裝optimus-manager後,無法進入kde

yay -Rns optimus-manager optimus-manager-qt # 解除安裝optimus-manager

將/etc/X11/xorg.conf刪除

[問題] 睡眠後喚醒時卡死,顯示以下資訊

ata6.00: supports DRM functions and may not be fully accessible
ata1.00: ATA identify device log not supported

用lspci檢視

04:00.0 Unassigned class [ff00]: Realtek Semiconductor Co., Ltd. RTL8411B PCI Express Card Reader (rev 01)
...
ModuleNotFoundError: No module named 'optimus_manager'
/usr/lib/systemd/system-sleep/optimus-manager.py failed with exit status 1.

最後發現是因為optimus-manager導致,解除安裝optimus-manager,安裝bumblebee後恢復正常

ArchLinux安裝

Trouble mounting microSD card
ArchLinux無法正常休眠或掛起
Realtech PCI Card Reader HOW TO
Card Reader RTL8411B
Startx - AddScreen/ScreenInit Faild - Asus N76V - GT 650M

[問題] 桌面崩潰,黑屏後重啟

killall plasmashell # 殺死程序

kstart5 plasmashell # 開啟程序
kquitapp5 plasmashell # 退出桌面

[問題] error while loading shared libraries: libpcap.so.0.8:cannot open shared object file: No such file or directory

issues/98

$ locate libpcap
/usr/lib64/libpcap.so <-- was one among many results for me
$ cd /usr/lib64/ # go to that directory
$ sudo ln -s libpcap.so libpcap.so.0.8 # create a symlink to libpcap.so.0.8 from libpcap.so (or whatever you actually have instead)
$ cd - # go back to your bettercap directory

[問題]系統hibernate後休眠時無法切斷電源的問題

修改/etc/systemd/sleep.conf檔案,開啟HibernateMode的註釋,值設為shutdown

[Sleep]
# A fix for unable to poweroff after hibernation
# HibernateMode= plantform shutdown
HibernateMode=shutdown

解決 systemd 休眠時無法切斷電源的問題
Arch Wiki - System does not power off when hibernating

相關文章