Arch installation notes
Archlinux 安装笔记
This post was written by me a few years ago. I decide to post it here cuase I might need it later.
安装流程
Step0: Connect to WIFF
如果有使用wifi的话,使用如下命令连接到Wifi
iwconfig #List all wireless network interface
wifi-menu [Interface] #Connect to network
OR Use Android USB Tethering
ls /sys/class/net
dhcpcd interface
Step1:检测是否uefi enabled
ls /sys/firmware/efi/efivars
Step2: 调整时间
timedatectl set-ntp true
Step3: 分区
一般而言,如果uefi启动,需要分一个100m的fat32分区作为uefi使用
所以先fdisk -l查看挂载硬盘,第一个硬盘应为/dev/sda 推荐使用lsblk命令查看硬盘情况
Lable 设置如下:
- efi: ef00
- swap: 8200
- boot: 8000
- home: 8300t
- root: 8304
使用gdisk
Gdisk 是一个命令行交互的分区工具. 以下是对于BIOS/GPT和UEFI/GPT两种不同情况的分区范例
o #create new table
n [default] [+1M] [ef02] # create a 1MiB space for grub
n [default] [+20G] [8300] # create rootfs
n [default] [+4G] [8200] # create swap
n [default] [+20G] [8300] # create home
n [default] [default] [8300] # remaining is used by other os
w
And here is a partition scheme for UEFI/GPT configuration:
/dev/sda1 100M UEFI ef00
/dev/sda2 100M Boot 8000
/dev/sda3 20G Root 8304
/dev/sda4 20G Home 8300
/dev/sda5 4G Swap 8200
Notes on Linux Installation on a BIOS/GPT configuration
A mebibyte partition needs to be located in first 2TB of the disk. For details, check arch wiki arch wiki
Step4:格式化系统
EFI分区使用mkfs.vfat -F32 [device]
生成分区,其他所有分区都用mkfs.ext4 [device]
格式化
mount /dev/sda3 /mnt
cd /mnt
mkdir boot
mkdir home
mount /dev/sda4 /mnt/home
mount /dev/sda2 /mnt/boot
mkdir /mnt/boot/efi
mount /dev/sda1 /mnt/boot/efi
然后运行mount | grep sda查看是否成功挂载 |
Step6:sysprep安装系统
先修改/etc/pacman.d/mirrorlist
pacstrap 相当于win下的sysprep,此时可以在/mnt下安装系统了
pacstrap -i /mnt base base-devel btrfs-progs linux linux-firmware
Step7: FStab Generation
这一步非常重要,如果不生成fstab将无法引导系统
genfstab -U /mnt » /mnt/etc/fstab
Step8:chroot
arch-chroot /mnt /bin/bash
Step9:Change locale
nano /etc/locale.gen,然后去掉想要使用的语言的注释,一般情况下,去掉en_US UTF8的注释 和 zh_CN.UTF-8的注释 locale-gen
Step10: change timezone,enable ntp
$ timedatectl list-timezones
$ timedatectl set-timezone Zone/SubZone
$ systemctl enable systemd-timesyncd
$ timedatectl set-ntp true
注意以上方法在chroot里无效,所以一般可以通过直接软链接相应的tz文件到/etc/localtime,方法如下:
ln -Sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
调整硬件时钟
hwclock –systohc –utc,将系统时钟选为utc
Step11: Intel Microcode and mkinitcpio
如果使用Intel的cpu,需要安装Microcode
pacman -S intel-ucode
如果不需要更新微码,直接生成initial ramdisk
mkinitcpio -p linux
Step12: config localhost and hosts
echo [HOSTNAME] > /etc/hostname
nano /etc/hosts
The file will then look something like this once you have your hostname appended to it.
127.0.0.1 localhost.localdomain localhost Arch-Linux-Test
::1 localhost.localdomain localhost Arch-Linux-Test
Step13 安装GRUB2和rEFind
$ pacman -S os-prober grub efibootmgr
$ grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=grub --recheck #UEFI/GPT
# grub-install --target=i386-pc /dev/sdx #BIOS/GPT
$ grub-mkconfig -o /boot/grub/grub.cfg
然后安装rEFind
$ pacman -S refind-efi
$ refind-install
$ efibootmgr #查看当前设置的uefi启动顺序
$ efibootmgr -o 3,7,2 #调整uefi启动顺序,这条命令意思是把顺序调整为3,7,2
Step14 Network
我一般使用networkmanager管理网络,当然你也可以使用systemd-networkd管理网络
$ pacman -S networkmanager
$ systemctl enable NetworkManager # 启用networkmanager
Step15 创建新用户,添加到sudoer
$ useradd -m -g users -G wheel -s /bin/bash [USERNAME]
$ passwd [USERNAME]
$ visudo
$ passwd # change root password
然后找到#%wheel ALL=(ALL) ALL
这条,去掉前面的注释符号,启动wheel组的sudoer权限
Step16: Shutdown
exit
umount -R /mnt
reboot
Step17 : Connect to Wifi after reboot
$ nmcli dev
$ nmcli dev wifi connect <ssid> password <password>
Step18 Rank fastest mirror
pacman -S reflector
reflector --country 'United States' --country Canada --age 12 --protocol https --sort rate --save /etc/pacman.d/mirrorlist
pacman -Syy
Step19 安装xorg和显卡驱动
sudo pacman -S xorg
安装显卡驱动:
pacman -S mesa xf86-video-intel nvidia #安装了Intel和Nvidia显卡驱动
Step20 安装桌面环境
如果在vm上安装,先安装open-vm-tools:
sudo pacman -S open-vm-tools xf86-video-vmware mesa-libgl
pacman -S gtkmm gtkmm3 # Enable drag-and-drop and clipboard share
systemctl enable vmtoolsd
如果安装XFCE:
pacman -S xfce4 xfce4-goodies #安装xfce4 DE
pacman -S lightdm lightdm-gtk-greeter # 安装 lightdm
systemctl enable lightdm.service
systemctl start lightdm.service
如果安装KDE:
pacman -S plasma-meta kde-applications
pacman -S sddm
sddm --example-config > /etc/sddm.conf
#编辑/etc/sddm.conf
找到[Theme]下的Current,然后修改成Current=breeze
找到Numlock条目并改为Numlock=on
systemctl enable sddm
如果安装GNOME:
pacman -S gnome gnome-extra
pacman -S gdm
systemctl enable gdm
Step21 中文化DE以及安装fcitx
$ pacman -S wqy-microhei #安装wqy微米黑字体
$ pacman -S fcitx-im fcitx-configtool fcitx-fbterm kcm-fcitx
$ pacman -S fcitx-cloudpinyin
然后设置~/.xprofile
,添加如下内容,为该用户启动中文并且加载fcitx:
export LANG=zh_CN.UTF-8
export LANGUAGE=zh_CN:en_US
export LC_CTYPE=en_US.UTF-8
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS="@im=fcitx"
## Step22 (Optional) 美化GNOME:
sudo pacman -S gnome-tweak-tool #安装gnome-tweak-tool yaourt -S numix-circle-icon-theme-git #图标包 yaourt -S gtk-theme-arc-git #应用程序主题 yaourt -S flat-remix-gnome-git #GNOME SHELL 主题 sudo pacman -S docky #安装底屏docky
然后在`gnome-tweak-tool`中启用以上主题,注意gnome shell theme 需要在扩展中启用 user shell并且重启
更改GDM背景:
curl -L -O http://archibold.io/sh/archibold chmod +x archibold ./archibold login-backgroung 你的背景的地址
更多美化可以参考这篇文章:
https://www.jianshu.com/p/97b2c1d621d2
## Step23 一些常用的工具
* screenfecth
* systemd-analyze #用于分析启动时间
## 字体美化
sudo pacman -S noto-fonts noto-fonts-cjk ttf-ibm-plex cd /tmp && git clone https://github.com/clive2000/dotfiles.git cd /tmp/dotfiles && cp -r fontconfig ~/.config/ fc-cache –force ```
为btrfs备份快照
https://ramsdenj.com/2016/04/05/using-btrfs-for-easy-backup-and-rollback.html