为了避免一般的linux发行版,版本升级带来各种的问题,我决定选择采用滚动升级策略的Arch Linux。折腾Arch Linux一段时间之后,发现Arch Linux确实是我最喜欢的Linux版本,官方的wiki是做得最好的,常见的问题上面都能找到答案。下面是我安装过程当中碰到的问题的汇总。

1 安装系统

根据arch Linux 安装指南安装系统,安装的过程中碰到的问题主要有两个,一个是uefi环境下如何安装启动器,另外一个就是无线网卡的驱动。 以下就是安装过程当中的流水账了。

#安装sudo
pacman -S sudo
#添加yaourt的支持
#最简单安装Yaourt的方式是添加Yaourt源至您的 /etc/pacman.conf
sudo pacman -Syu yaourt

在/etc/pacman.conf中添加如下内容:

[archlinuxcn]
#The Chinese Arch Linux communities packages.
#信任所有包
SigLevel = Optional TrustAll
#只信任
#SigLevel = Optional TrustedOnly
Server = https://mirrors.ustc.edu.cn/archlinuxcn/$arch

2 上网问题

如果你gui界面比较多,用networkmanager可能更加方便一些,如果你对console更加熟悉,建议使用systemd-networkd,用wifi-menu进行配置文件切换就可以了,同样也非常方便的。

2.1 有线上网

udev对网卡的命名规则发生了变化,例如我的网卡名称是ens5,如果你想换回原来的eth*的规则,可以运行如下的脚本。

sudo ip link set ens5 up
cat ]# /etc/udev/rules.d/99-rename-to-eth0.rules << EOF
SUBSYSTEM=="net", ACTION=="add", DRIVERS=="?*", ATTR{address}=="$(cat /sys/class/net/ens5/address)", ATTR{dev_id}=="0x0", ATTR{type}=="1", KERNEL=="eth*", NAME="eth0"
EOF
systemctl enable dhcpcd
sudo pacman -S networmanager networkmanager-pptp gnome-keyring
systemctl enable NetworkManager
systemctl disable dhcpcd
systemctl start NetworkManager

2.2 无线上网

我的无线网卡是b4312无法直接驱动,需要安装驱动

lspci -vnn -d 14e4:
sudo pacman -S b43-fwcutter
sudo pacman -S dialog

对于经常切换网络环境的话,使用NetworkManager管理网络会比较方便,但是启动速度比较慢,获取IP地址速度比较慢,而且需要系统必须登陆过一次才能连上网络,对于用于服务器,重启后就需要获取到ip地址,只有dhcpcd或者systemd-networkd能够实现,熟悉systemd-networkd之后,其实使用上差别并不是很大。

2.3 使用systemd-networkd替代networkmanager

systemctl stop NetworkManager
systemctl enable systemd-networkd
systemctl start systemd-networkd

2.3.1 有线连接

可以在/etc/systemd/network/建立.network文件,进行配置,具体配置项参考文章尝鲜: 新的网络连接管理工具 systemd-networkd 我自己的wired.network配置文件内容如下

[Match]
Name=en*

[Network]
DHCP=yes
#Address=192.168.0.1/24
#Gateway=192.168.1.1
#DNS=192.168.1.1

2.3.2 无线连接

可以在/etc/netctl/下建立一个配置文件,具体配置项参考文章netctl配置工具说明。 通过wifi-menu -o连接无线热点,就会在/etc/netctl/生成一个配置文件

sudo netctl enable 该配置文件名称
sudo netctl start 该配置文件名称

即可完成无线连接,不成功的时候注意包的依赖问题。

3 安装常用的软件

sudo pacman -S --needed --noconfirm sakura feh dex xdg-utils screenfetch scrot xcompmgr kdeaccessibility wmname alsa-utils gnome-alsamixer xorg-xbacklight xf86-input-synaptics cheese mpd mpc workrave xscreensaver networkmanager network-manager-applet mate-power-manager arandr xfce4-appfinder xfce4-screenshooter
pcmanfm engrampa unrar zip unzip p7zip unace ntfs-3g udisks udiskie lxsession lxappearance terminator conky gksu launchy
gvim emacs firefox putty remmina synergy fcitx-im fcitx-configtool flashplugin
yaourt -S dpkg fcitx-sogoupinyin

4 文件管理器

pacman -S pcmanfm engrampa unrar zip unzip p7zip unace

unrar: for RAR uncompression zip: for ZIP archives unzip: for ZIP archives p7zip: 7zip compression utility arj: for ARJ archives unace: extraction tool for the proprietary ace archive format

4.1 添加挂载ntfs分区的权限

参考Polkit说明文档

sudo vim /etc/polkit-1/rules.d/10-enable-mount.rules
sudo usermod XXX -aG storage
polkit.addRule(function(action, subject) {
if (action.id == "org.freedesktop.udisks2.filesystem-mount-system" && subject.isInGroup("storage")) {
return polkit.Result.YES;
}
});

5 字体

#安装常用中英文字体
sudo pacman -S noto-fonts noto-fonts-cjk noto-fonts-emoji wqy-microhei ttf-ms-fonts ttf-dejavu ttf-droid ttf-ubuntu-font-family
#查看安装过的字体
fc-list
#字体渲染
#改善字体渲染相关的包有fontconfig-ubuntu,cario-ubuntu,freetype2-config,我使用的是cario-ubuntu
yaourt -S cario-ubuntu

6 双系统时间问题

添加/etc/adjtime

0.0 0 0.0
0
LOCAL

7 配置窗口管理器

一直想把自己的另外一个上网本也用上,想了各种办法,最终的解决方案就是xdmx,试过多个awesome、i3、twm、fvwm等,只有后两者是支持xdmx的,其他wm连接上了,只是黑屏而已,一段时间体验之后,实际上,并没有必要用xdmx,在命令行中加入DISPALY=上网本IP地址:0,然后就能将程序运行在上网的系统中,实在感叹Linux实在的是太牛逼的。综合各个窗口管理器的特性,fvwm基本上实现了,我想要的多数功能,就是配置文件稍微比较麻烦。

7.1 awesome

安装awesome wm config及其依赖 https://github.com/pw4ever/awesome-wm-config

sudo pacman -S awesome

Arch Linux下的urxvt也是一个比较大的坑,aur里有多个版本,我不小心安装了其他版本,中文字体超宽的,偶尔看到一篇《有好多好多 urxvt,怎麼選呢?》才找到解决方案。

7.1.1 解决emacs在awesome的最大化时底部有空隙

消除空隙的方法是在rc.lua添加RULE

{ rule = { class = "Emacs" },
properties = { size_hints_honor = false } },

7.2 fvwm

fvwm已经是非常古老的技术了,目前已经是很小众的窗口管理器。不是为了配置xdmx的话,我也不会接触到这个技术。多数提到xdmx的文章都是使用twm作为窗口管理器的,但是twm是在太难看了。在Window Managers for X试遍了所有常见的窗口管理器,只有fvwm比较符合我的要求的。原因主要有两个,一个是支持xdmx,另外一个是支持平铺式窗口管理。fvwm的功能十分丰富,几乎能实现任何关于窗口管理方面你想要的功能,但是默认的配置文件下,看起来极其丑陋的,需要自己动手慢慢去调教,但是Robert Ulbricht做的fvwm配置文件满足了我的这两个基本要求。他的配置文件公开在github上,地址如下:A tiling window manager configuration for fvwm,我下载下来之后,发现平铺模式下的窗口位置计算有误差,我自己的配置文件已经修正了这个问题。

cd ~
git clone https://github.com/wing-ho/fvwm-tiling.git
sudo pacman -S stalonetray screen dmenu mate-power-manager fcitx-im fcitx-configtool
#aur/fvwm+是打好了各种补丁的包
#aur/rxvt-unicode-fontspacing-noinc-vteclear-secondarywheel打好了各种补丁的包
yaourt -S fvwm+ aur/rxvt-unicode-fontspacing-noinc-vteclear-secondarywheel fcitx-sogoupinyin

7.3 xfce4

多数人用得比较多的就是笔记本的显示器,一般就只有1366x768的分辨率,工作的时候,一般都会将当前的程序最大化,而不是以平铺的方式管理窗口。这时候同样比较轻量的xfce4是我比较推荐的选择。 默认的xfce4主题比较不符合我的审美要求,我比较喜欢的Numix的黑色主题和图标。

yaourt -S numix-themes numix-circle-icon-theme-git
sudo pacman -S xfce4 xfce4-goodies
vim .xinitrc
exec startxfce4

8 配置蓝牙键盘和蓝牙鼠标

英文好的朋友可以直接参考arch linux的wiki,配置方法主要参考以下两篇文章。

  1. Bluetooth keyboard
  2. Bluetooth mouse

8.1 手动连接蓝牙键盘鼠标

sudo pacman -S rfkill
sudo rfkill list
sudo rfkill unblock bluetooth
#配置蓝牙键盘
bluetoothctl
[bluetooth]# power on
[bluetooth]# agent KeyboardOnly
[bluetooth]# default-agent
[bluetooth]# pairable on
[bluetooth]# scan on
[bluetooth]# pair <keyboard mac>
[bluetooth]# trust <keyboard mac>
[bluetooth]# connect <keyboard mac>
[bluetooth]# quit

#配置蓝牙鼠标
[bluetooth]# list
Controller <controller mac> BlueZ 5.5 [default]
[bluetooth]# select <controller mac>
[bluetooth]# power on
[bluetooth]# scan on
[bluetooth]# agent on
[bluetooth]# devices
Device <mouse mac> Name: Bluetooth Mouse
[bluetooth]# pair <mouse mac>
[bluetooth]# trust <mouse mac>
[bluetooth]# connect <mouse mac>

如果不想每次都手动连接蓝牙,可以添加systemd service

8.2 自动连接蓝牙键盘鼠标

wiki上面说是udev rule或者systemd服务任选其一就能实现自动连接,但是前提是已经通过bluetoothctl手动配对连接过并且信任的蓝牙设备。

8.2.1 使用systemd服务连接蓝牙设备

首先创建一个配置文件/etc/btkbd.conf

# Config file for btkbd.service
# change when required (e.g. keyboard hardware changes, more hci devices are connected)
BTKBDMAC=<mac_address_of_your_device>
HCIDEVICE=<hci_device_identifier>

#mac_address_of_your_device can be found with the scan on command of the bluetoothctl utility.
#hci_device_identifier can be found with:

#hcitool dev
#Devices:
# hci0 E0:2A:82:34:0D:42

在/etc/systemd/system/btkbd.service创建一个服务

[Unit]
Description=systemd Unit to automatically start a Bluetooth keyboard
Documentation=https://wiki.archlinux.org/index.php/Bluetooth_Keyboard
Requires=dbus-org.bluez.service
After=dbus-bluez.org.service
ConditionPathExists=/etc/btkbd.conf
ConditionPathExists=/usr/bin/hcitool
ConditionPathExists=/usr/bin/hciconfig

[Service]
Type=oneshot
EnvironmentFile=/etc/btkbd.conf
ExecStart=/usr/bin/hciconfig ${HCIDEVICE} up
# ignore errors on connect, spurious problems with bt? so start next command with -
ExecStart=-/usr/bin/hcitool cc ${BTKBDMAC}

[Install]
WantedBy=multi-user.target

然后用systemctl管理工具开启这个服务。

systemctl enable btkbd.service

8.2.2 使用udev rule启动蓝牙连接服务

创建一个文件/etc/udev/rules.d/10-local.rules

# Set bluetooth power up
ACTION=="add", KERNEL=="hci0", RUN+="/usr/bin/hciconfig hci0 up"

9 零碎问题汇总

9.1 使用一段时间之后开机出现如下提示:

Arch Linux – Failed to start Verify integrity of password and group files systemctl status shadow.service 提示Failed to start Verify integrity of password and group files

sudo userdel -r gdm
systemctl start shadow.service

9.2 Archlinux 安装 yaourt 软件包管理器

有时候没有及时跟进升级系统,yaourt软件包管理器掉链了,无法升级了,以下方法可以安装到最新版本的yaourt。

git clone https://aur.archlinux.org/package-query.git
cd package-query
makepkg -si
cd ..
git clone https://aur.archlinux.org/yaourt.git
cd yaourt
makepkg -si
cd ..
Last Updated 2018-10-14 日 23:38.
Created by Emacs 25.1.1 (Org mode 9.1.14)