Arch Linu安裝配置

設置UEFI啟動
timedatectl status 設置時間
磁盤分區(qū)
lsblk 查看硬盤
fdisk /dev/sda # 輸入 fdisk 設備名,進入 fdisk 操作環(huán)境
Command (m for help): g # 輸入 g 創(chuàng)建新的 GPT 分區(qū)表
Command (m for help): n # 輸入 n 創(chuàng)建新的分區(qū),這個分區(qū)將是 EFI 分區(qū)
Partition number (1-128, default 1): # 分區(qū)編號保持默認,直接按 Enter
First sector (2048-125829086, default 2048): # 第一個扇區(qū),保持默認
Last sector:+512M # 創(chuàng)建 512MiB 大小的分區(qū)
Do you want to remove the signature? [Y]es/[N]o: Y # 清除已有的簽名
Command (m for help): t
Partition type or alias (type L to list all): 1 # 輸入 1 代表 EFI 類型
接下來用n創(chuàng)建其他分區(qū)
Partition type or alias (type L to list all): 23 # 輸入 23 代表 Linux root (x86-64) 類型
Partition type or alias (type L to list all): 41 # 輸入 41 代表 Linux home 類型
Command (m for help): p # 輸入 p 打印分區(qū)表
完成所有分區(qū)
Command (m for help): w # 輸入 w 寫入分區(qū)表,該操作不可恢復
設置分區(qū)格式
mkfs.ext4 /dev/sda2
mkfs.ext4 /dev/sdb1 根目錄和home
mkfs.fat -F 32 /dev/sda1 設置boot
掛載分區(qū)
mount /dev/sda2 /mnt 掛載根分區(qū)
mount --mkdir /dev/sda1 /mnt/boot/efi 掛載boot
mount --mkdir /dev/sdb1 /mnt/home 掛載home
創(chuàng)建交換分區(qū)
dd if=/dev/zero of=/mnt/swapfile bs=1M count=8192 status=progress
chmod 0600 /mnt/swapfile 提權
mkswap -U clear /mnt/swapfile 格式化
swapon /mnt/swapfile 啟用交換分區(qū)
swapon --show 查看交換空間
設置軟件源
vim /etc/pacman.d/mirrorlist
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch 寫在最上面
保存退出
安裝系統(tǒng)
pacman-key --init # 初始化密鑰環(huán)
pacman-key --populate
pacman -Sy archlinux-keyring
pacstrap /mnt base linux-lts linux-lts-headers linux-firmware base-devel
寫入分區(qū)表
genfstab -U /mnt >> /mnt/etc/fstab
查看分區(qū)表
cat /mnt/etc/fstab
切換到系統(tǒng)root
arch-chroot /mnt
設置系統(tǒng)時間
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
設置硬件時間
hwclock --systohc
查看分區(qū)表
cat /etc/fstab
設置系統(tǒng)字體
pacman -S vim ttf-dejavu wqy-zenhei
vim /etc/locale.gen
輸入“/”,進入搜索功能,輸入“en_US.UTF-8”
#en_US.UTF-8 UTF-8 在“e”的位置。按方向左鍵,再輸入“x”,將這一行開頭的“#”刪除
#zh_CN.UTF-8 UTF-8 也一樣
保存退出
locale-gen 執(zhí)行載入UTF8編碼
vim /etc/locale.conf 添加 LANG=zh_CN.UTF-8
安裝中文
vim /etc/profile.d/utf8.sh 新建一個字體環(huán)境變量
內(nèi)容
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN:en_US
設置主機名
vim /etc/hostname 設置好之后保存退出
網(wǎng)絡管理器
pacman -S networkmanager
systemctl enable NetworkManager.service 設置自啟
設置root密碼
passwd
查看 CPU 型號
cat /proc/cpuinfo | grep "model name"
pacman -S intel-ucode Intel CPU安裝 intel-ucode
pacman -S amd-ucode AMD CPU,安裝 amd-ucode
安裝顯卡
pacman -S xf86-video-intel(Intel核心顯卡驅(qū)動,用Intel核顯就裝,否則不用裝)
pacman -S mesa nvidia nvidia-settings nvidia-dkms nvidia-utils nvidia-prime(nvidia顯卡驅(qū)動,用nvidia顯卡就裝,否則不用裝)
pacman -S xf86-video-amdgpu (AMD顯卡驅(qū)動,用amd顯卡的就裝)
安裝聲卡驅(qū)動(沒有聲音再加)
pacman -S pipewire (alsa-utils) pipewire-pulse pipewire-jack pipewire-alsa
安裝grub
pacman -S grub efibootmgr
安裝GRUB
grub-install /dev/sda 安裝在整個磁盤,不是某個分區(qū)
grub-mkconfig -o /boot/grub/grub.cfg
安裝程序完成
exit 退出 chroot 環(huán)境
swapoff /mnt/swapfile 關閉交換文件
umount -R /mnt 取消掛載
reboot 重啟
開啟ssh
pacman -S openssh vim
vim /etc/ssh/sshd_config 取消PermitRootLogin yes注釋并修改
systemctl enable sshd.service
systemctl start sshd.service
創(chuàng)建普通用戶
useradd -m -G wheel 用戶名
passwd 用戶名 設置密碼
pacman -S sudo
EDITOR=vim visudo
#%wheel ALL=(ALL:ALL) ALL 找到此行并取消注釋
用戶名 ALL=(ALL:ALL) ALL 添加此行
su - 用戶名 切換到用戶
安裝軟件包
sudo pacman -S man-pages man-db texinfo 下載3個包
info vim 可以用來查看軟件命令解釋,按“q”鍵離開
pacman 的配置
sudo vim /etc/pacman.conf
取消下面4行的注釋
Color
ParallelDownloads
[multilib]
Include = /etc/pacman.d/mirrorlist
在后面添加
[archlinuxcn]
SigLevel = Optional TrustAll
Server = https://mirrors.tuna.tsinghua.edu.cn/archlinuxcn/$arch
更新軟件
pacman -Syyu
sudo pacman -S archlinuxcn-keyring
安裝軟件包
pacman -S pacman-contrib
systemctl enable paccache.timer
安裝kde桌面
pacman -S xorg plasma plasma-wayland-session kde-applications
systemctl enable sddm.service
安裝中文輸入法
pacman -S fcitx5 fcitx5-chinese-addons fcitx5-gtk fcitx5-qt fcitx5-configtool
添加環(huán)境變量
vim /etc/profile.d/fcitx5.sh
GTK_IM_MODULE=fcitx
QT_IM_MODULE=fcitx
XMODIFIERS=@im=fcitx
INPUT_METHOD=fcitx
SDL_IM_MODULE=fcitx
GLFW_IM_MODULE=ibus
配置zsh(可以不裝,有點費勁)
sudo pacman -S zsh-autosuggestions zsh-syntax-highlighting zsh-theme-powerlevel10k zsh-completions
chsh -s /usr/bin/zsh 修改為默認解釋器
vim ~/.zshrc
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh-theme-powerlevel10k/powerlevel10k.zsh-theme
pacman -S neofetch
重啟
reboot