Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 6 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save howyay/d9db9c0549eae51fbe97deb382a42933 to your computer and use it in GitHub Desktop.
Save howyay/d9db9c0549eae51fbe97deb382a42933 to your computer and use it in GitHub Desktop.

1. Arch Linux Setup Guide for OPTIMUS Laptops
双显卡笔记本Arch安装指南

1.1. 目录

2. 前期安装指南

这是在archiso内进行的一些安装前准备和正式安装的指南

2.1. 连接到无线网络

2.1.1. 启用无线网络接口

列出可用无线网络接口

 iw dev

启用接口

 ip link set 设备名 up

2.1.2. 连接到无线网络

扫描附近wifi

 iwlist 设备名 scan | grep ESSID

连接到wifi

 wpa_supplicant -B -i 设备名 -c <(wpa_passphrase SSID 密码)

启动dhcpcd服务

 systemctl start dhcpcd

2.2. 分区

列出所有硬盘设备及分区

 fdisk -l

2.2.1. 清除分区并创建分区表

 dd if=/dev/zero of=/dev/sdb  bs=512  count=1
 parted 设备路径 mklabel gpt yes 

2.2.2. EFI分区

创建512MiB(0.5GiB,536.870912)的efi分区

 parted -a optimal 设备路径 mkpart primary 0% 537.870912mb

设置为boot分区

 parted 设备路径 set 1 boot on

2.2.3. SWAP分区

创建4096MiB(4GiB,4294.9673mb)的swap分区

 parted -a optimal 设备路径 mkpart primary 537.870912mb 4832.838212mb

2.2.4. 主分区

使用所有剩余空间创建一个主分区

 parted -a optimal 设备路径 mkpart primart 4832.838212mb 100%

2.3. 格式化并挂载分区

2.3.1. 格式化并挂载主分区

 mkfs.btrfs -f -L ROOT 主分区路径
 mount 主分区路径 /mnt

2.3.2. 格式化并启用swap分区

 mkswap swap分区路径
 swapon swap分区路径

2.3.3. 格式化并挂载EFI分区

 mkfs.fat -F32 EFI分区路径
 mkdir /mnt/boot
 mkdir /mnt/boot/efi
 mount EFI分区路径 /mnt/boot/efi

2.4. 安装

 pacstrap /mnt base

2.4.1. 生成Fstab

 genfstab -U /mnt > /mnt/etc/fstab

修改生成的fstab文件,把 / 分区的UUID=*替换为LABEL=ROOT

/mnt/etc/fstab

LABEL=ROOT      /       btrfs         rw,relatime,ssd   0 0

3. 安装后配置

在新系统内安装基本工具和驱动,并进行一些配置

3.1. 进入新系统

 arch-chroot /mnt

3.2. 修改root密码

 passwd

3.3. 安装基本工具和一些驱动

 pacman -S nano vim networkmanager fish libinput git base-devel unzip p7zip unrar wget alsa-utils xf86-video-intel bluez htop pulseaudio-bluetooth

 systemctl enable NetworkManager  
 systemctl enable bluetooth //开机启动蓝牙服务,可选

 chsh
 > /usr/bin/fish //更改默认shell为fish

3.4. 安装linux-zen内核(可选)

 pacman -S linux-zen
 pacman -R linux //卸载原内核(可选)

3.5. 安装rEFInd引导器

安装refind-efi包

 pacman -S refind-efi

安装引导器

 refind-install

完成后编辑 /boot/refind_linux.conf 把每一行改为类似以下格式的内容

"Boot with standard options"	"rw root=LABEL=主分区标签 modprobe.blacklist=pcspkr initrd=/boot/initramfs-linux-zen.img" //modprobe项关闭了tty的bb声,initrd项强制使用linux-zen内核initramfs

3.6. 配置内核日志

/etc/sysctl.d/99-sysctl.conf 中添加设置

 echo "kernel.printk = 3 4 1 3" > /etc/sysctl.d/99-sysctl.conf

3.7. 创建新用户

 useradd -m -g users -G wheel -s /usr/bin/fish 用户名
 passwd 用户名

给予sudo权限

/etc/sudoers

#%wheel ALL=(ALL) ALL
#反注释以上行

退出chroot并重启进入arch

3.8. 连接到wifi

 nmtui

选择 Activate a connection 然后连接wifi

3.9. 更改主机名

 echo "主机名" > /etc/hostname

3.10. 修改hosts

/etc/hosts

127.0.0.1	localhost
::1		localhost

3.11. 校时

 timedatectl set-ntp true
 timedatectl set-timezone 地区/城市 //America/New_York

3.12. 本地化

/etc/locale.gen 中反注释以下两项

#en_US.UTF-8 UTF-8
#zh_CN.UTF-8 UTF-8

运行 locale-gen

 locale-gen

配置locale.conf

 echo LANG=en_US.UTF-8 > /etc/locale.conf

3.13. 添加常用源

编辑/etc/pacman.conf,反注释以下两行启用multilib

[multilib]
Include = /etc/pacman.d/mirrorlist

然后在末尾添加以下内容添加archlinuxcn源

[archlinuxcn]
Server = https://cdn.repo.archlinuxcn.org/$arch

安装archlinuxcn GPG key包

 pacman -Sy archlinuxcn-keyring

更新所有库

 pacman -Syu

3.14. 双显卡驱动

3.14.1. bbswitch

在arch内完全关闭独显,省电,建议双系统使用

安装nvidia驱动,内核头文件以及bbswitch

 pacman -S nvidia-dkms linux-zen-headers bbswitch-dkms //自定义内核需安装配套头文件
 pacman -S nvidia linux-headers bbswitch //原厂内核

添加bbswitch启动参数,加载模块时时关闭独显,卸载模块时启用独显

/etc/modprobe.d/bbswitch.conf

options bbswitch load_state=0 unload_state=1

开机启动bbswitch模块

/etc/modules-load.d/bbswitch.conf

bbswitch

禁止独显驱动开机启动

/etc/modprobe.d/blacklist.conf

blacklist nvidia_drm
blacklist nvidia_modeset
blacklist nvidia

3.14.1.1. 手动操作

卸载独显驱动模块

 rmmod nvidia-drm nvidia-modeset nvidia

加载bbswitch模块

 modprobe bbswitch

关闭独显

 tee /proc/acpi/bbswitch <<<OFF

3.15. 安装yay

 su 用户名
 cd ~
 git clone https://aur.archlinux.org/yay.git
 cd yay
 makepkg -si

3.16. CPU降频工具

3.16.1. 安装

 yay -S throttled
 systemctl enable --now lenovo_fix

3.16.2. 更改配置

配置文件位于 /etc/lenovo_fix.conf

3.16.3. 安装CPU压测及监测工具

 yay -S s-tui

4. 配置图形环境

4.1. 安装桌面环境

安装桌面环境相关组件

 pacman -S plasma ark dolphin dolphin-plugins kate konsole kdeplasma-addons libdbusmenu-glib libdbusmenu-gtk3 libdbusmenu-qt5 appmenu-gtk-module xorg wqy-microhei noto-fonts-cjk ttf-sarasa-gothic noto-fonts-emoji
 yay -S ksuperkey

~/.xprofile 内添加以下内容为gtk软件添加全局菜单

export SAL_USE_VCLPLUGIN=gtk
export GTK_MODULES=appmenu-gtk-module

4.3. 图形环境本地化

.xprofile添加语言设置

 echo "export LANG=zh_CN.UTF-8" >> ~/.xprofile

4.4. 安装中文输入法

 pacman -S fcitx5-git kcm-fcitx5-git fcitx5-rime-git fcitx5-qt5-git fcitx5-gtk-git

编辑~/.xprofile,添加以下内容

export GTK_IM_MODULE=fcitx5
export QT_IM_MODULE=fcitx5
export XMODIFIERS=@im=fcitx

4.6. 终端美化

安装neofetch

 pacman -S neofetch

安装nerd fonts

 cd ~
 git clone https://github.com/ryanoasis/nerd-fonts.git
 cd nerd-fonts
 ./install.sh

安装fisher

 curl https://git.io/fisher --create-dirs -sLo ~/.config/fish/functions/fisher.fish

安装bobthefish主题

 fisher add oh-my-fish/theme-bobthefish

重启终端

~/.config/fish/config.fish 里添加以下内容

echo
neofetch

function fish_greeting
  //此处为空以关闭欢迎信息
end

4.7. rEFInd美化

安装rEVIsed主题

 cd ~
 git clone https://github.com/haoyet/refind-theme-revised.git
 cp -r refind-theme-revised /boot/efi/EFI/refind/

编辑 /boot/efi/EFI/refind/refind.conf

添加 include refind-theme-revised/theme.conf

4.8. 安装常用软件

由于最近官方仓库fish有点问题,在这里还同时安装fish-git

electron-ssr

 yay -S flameshot deepin-wine-tim smartgit bcompare stacer-bin mailspring motrix fsearch-git tor-browser-zh-cn firefox-kde-opensuse

 pacman -S google-chrome telegram-desktop visual-studio-code-bin wps-office ttf-wps-fonts nmap filezilla vlc hmcl discord android-tools lximage-qt

 git clone https://aur.archlinux.org/fish-git.git
 cd fish-git
 makepkg -si

4.9. 安装win10字体

 git clone https://github.com/haoyet/ttf-ms-win10-git.git
 cd ttf-ms-win10-git
 makepkg -si
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment