以下簡單敘述自己安裝arch的過程,以及踩到的一些坑~ 希望對於新手安裝有幫助
1.首先可以到交大下載iso映像檔
應該要先去確認主機板是用什麼開機的BIOS 還是UEFI
會關係到之後的pation
2.先要透過 lsblk 或 blkid 先找到磁碟,再用 parted /dev/xxx print 來找出內部的分割表類型,之後才用 gdisk 或 fdisk 來操作系統先看disk事那一種分割,可以看到我的電腦事用gpt分割
root@node:~# parted /dev/sda print
型號:ATA CT500MX500SSD1 (scsi)
磁碟 /dev/sda:500GB
磁區大小 (邏輯/物理):512B/4096B
分割區:gpt
磁碟旗標:
編號 起始點 結束點 大小 檔案系統 名稱 旗標
1 1049kB 99.6MB 98.6MB fat32 啟動, esp
4 99.6MB 200MB 101MB bios_grub
2 200MB 32.2GB 32.0GB linux-swap(v1)
3 32.2GB 500GB 468GB ext4
root@node:~# parted /dev/sdb print
型號:ATA TOSHIBA DT01ACA2 (scsi)
磁碟 /dev/sdb:2000GB
磁區大小 (邏輯/物理):512B/4096B
分割區:gpt
磁碟旗標:
編號 起始點 結束點 大小 檔案系統 名稱 旗標
1 1049kB 2000GB 2000GB ext4
或是直接用cfdisk /dev/sdX 圖形化來分割硬碟,按n來選partition的大小,type則可以選擇類型/home, /, swap, or EFI system
$ mkfs.vfat /dev/sda1 <-EFI partion
$ mkswap /dev/sda2 <-swap
$ mkfs.ext4 /dev/sda3 <-root
$ mkfs.ext4 /dev/sda4 <-home
要先將root partion掛載到/mnt 之後再創建/home /boot 並掛載其他磁區
mount /dev/sda3 /mnt <-root
mkdir /mnt/boot
mount /dev/sda1 /mnt/boot
mkdir /mnt/home
mount /dev/sda4 /mnt/home
透過blkid來看每個分割磁區的filesystem type
可以用df來看有沒有掛載成功
用vim /etc/pacman.conf編輯conf文件將,找到[core] [extra] [community]將交大的arch mirrorlist加入
[core]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist
[extra]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist
[community]
Server = http://archlinux.cs.nctu.edu.tw/$repo/os/$arch
Include = /etc/pacman.d/mirrorlist
使用pacstrap來運行安裝系統基本組件
pacstrap /mnt base base-devel
正常安裝畫面,如果有出先erro install pacakages to new root要重新mout or 重新格式化硬碟比較好,
pacman -Syy
pacman -Su
產生fstab file建立好後可以看一下檔案有沒有存在
# genfstab -U /mnt >> /mnt/etc/fstab
接下來我們要change root to new system
# arch-chroot /mnt
ln -sf /usr/share/zoneinfo/Asia/Taipei /etc/localtime
用 hwclock 來產生 /etc/adjtime:
# hwclock --systohc
echo "en_US.UTF-8 UTF-8" > /etc/locale.gen;
echo "zh_TW.UTF-8 UTF-8" >> /etc/locale.gen;
echo "LANG=en_US.UTF-8" > /etc/locale.conf;
記得要執行locale-gen不然進入桌面會沒有英文字,連打字都無法,會很冏
$locale-gen
echo "your-pc-name" > /etc/hostname
先安裝vim
pacman -Sy vim
vim /etc/hosts
把以下加入/etc/hosts
127.0.0.1 localhost.localdomain localhost
::1 localhost.localdomain localhost
127.0.1.1 myhostname.localdomain myhostname
mkinitcpio 是一個script可以幫忙建立Initial ramdisk
mkinitcpio -p linux
passwd
先安裝grub
pacman -Sy grub os-prober efibootmgr
os-prober 可以用以偵測目前已安裝的其他系統,並在之後加入 grub 選單中
os-prober
因為之前把efi partion掛在/efi資料夾,所以要改成 –efi-direction=/efi
BIOS:
grub-install /dev/sda
UEFI:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=grub
grub-mkconfig -o /boot/grub/grub.cfg
設定成功畫面
pacman -S net-tools;
pacman -S dhclient;
pacman -S dhcp
pacman -S wpa_supplicant;
pacman -S wireless_tools;
pacman -S 套件名
pacman -Sy 同步列表
pacman -Su 更新套件版本
pacman -Syu 同步更新
sudo pacman -Syy //類似sudo apt-get update
pacman -S 套件
安裝套件:
vim
pkgfile //套件 & 軟體名字不match
bash-completion //自動補齊 for pacman…等
sudo
離開chroot以前記得把dhcp服務加入systemd 的起動選項中
如果出現dhcp.service does not exit記得先裝dhcp package
or 先systemctl enable dhcpcd
systemctl enable dhcpcd.service
exit
umount -R /mnt
reboot
如果開機後進入GRUB 2 雖然正常啟動並載入了 normal.mod 模組 (以及放在 /boot/grub/[arch]/ 底下的其他模組),卻找不到你的 grub.cfg 檔案。如果你看到的是 grub rescue>,這表示它找不到 normal.mod,因此可能也找不到你所有的開機檔案
再次進入系統後
手動設定DNS
vim /etc/resolv.conf
將所有設定前方加上 # 作註解,添加以下 DNS (最少1種,看個人選擇)
nameserver 168.95.192.1 #中華電信
nameserver 168.95.1.1 #中華電信
nameserver 8.8.8.8 #Google
nameserver 8.8.4.4 #Google
gnome:
pacman -Sy gnome gnome-extra
KDE:
pacman -S xorg-server plasma kde-application
裝plasma kde-applications-meta要 4G
pacman -S plasma kde-applications-meta
LXQT:
pacman -S xorg-server xorg-init lxqt sddm
cp /etc/X11/xinit/xinitrc ~/.xinitrc
把 exec startlxqt 加入到 ~/.xinitrc
enable sddm service
systemctl enable sddm.service
安裝顯卡driver
Intel:
xf86-video-intel
設定sudo 群組 打開sudoer file並將%wheel ALL=(ALL)前面註解拿掉
vim /etc/sudoers
# Uncomment to allow members
# %wheel ALL=(ALL) ALL
建立新使用者,並加入 sudo 群組
useradd -m -u 1001"your-user-name"
passwd "your-user-name"
usermod "your-user-name" -G wheel
重新開機
reboot
除了設定中文 locale,還要安裝中文字體,才可正確顯示中文
不然你會看到環境界面以及瀏覽器都是會有奇怪的口口出現
這裡建議安裝noto-fonts-cjk 思源黑體,或是文泉驛正黑體(windows用的中文字體),文泉驛微米黑(Android)
sudo pacman -Su noto-fonts-cjk adobe-source-code-pro-font
安裝完後記得要將字形改為Noto Sans CJK TC,不然字體會有鋸齒感~
Noto Sans CJK TC(Traditional Chinese)
後來發現chrome有些頁面的字體會有鋸齒感~ 尤其是看github的code都會發現糊糊的
找了很久發現是Font rasterization的問題
需要在子像素繪製改成RGB, 提示改為slight
Sub-pixel rendering type" to "RGB" and "Hinting style" to "Slight"
更新:
後來覺的DejaVu Sans 10的字體也不錯,感覺比Noto Sans CJK好看
再來就是中文輸入法了,沒有這個會很難過, 有遇過chrome裝好後無法切換使用新酷音,但在其他編輯器及瀏覽器都可以使用情形,這時候可以用fcitx-diagnose看一下是哪邊沒裝好~
fcitx-chewing:新酷音
fcitx-googlepinyin:google拼音
sudo pacman -S fcitx-configtool fcitx-chewing fcitx-googlepinyin kcm-fcitx
安裝好後記得在~/.xprofile 新增以下變數, 如果沒有此檔案請要自行建立,
export XIM=fcitx
export XIM_PROGRAM=fcitx
export GTK_IM_MODULE=fcitx
export QT_IM_MODULE=fcitx
export XMODIFIERS=@im=fcitx
登入登出後應該就可以啟動,如果沒有
透過以下的套件我們可以安裝第三方軟體, ex: google-chrome
1.AUR
git clone https://aur.archlinux.org/aurman.git
cd aurman
makepkg -si
2.yay
git clone https://aur.archlinux.org/yay.git
cd yay
makepkg -si
Searching an application through Yay in AUR
yay -Ss <package-name>
Installing an application
yay -S <package-name>
sudo pacman -S libreoffice-fresh-zh-tw
copy原有的arch linux的config
zcat /proc/config.gz > .config
之後開始編譯
sudo make -j12
sudo make -j12 modules_install
這時候可以看到bzImage 把它copy到/boot/ 資料夾
sudo cp -v arch/x86_64/boot/bzImage /boot/vmlinuz-linux-5.3
sudo cp /etc/mkinitcpio.d/linux.preset /etc/mkinitcpio.d/linux-5.3.preset
修改preset檔,以下幾個地方要改成對應的版號
sudo vim /etc/mkinitcpio.d/linux-5.3.preset
..
ALL_kver="/boot/vmlinuz-linux-5.3"
...
default_image="/boot/initramfs-linux-5.3.img"
...
fallback_image="/boot/initramfs-linux-fallback-5.3.img"
..
產生initramfs image
$ sudo mkinitcpio -p linux-5.3
==> Building image from preset: /etc/mkinitcpio.d/linux-5.3.preset: 'default'
-> -k /boot/vmlinuz-linux-5.3 -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-5.3.img
==> Starting build: 5.3.0-rc2
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [autodetect]
-> Running build hook: [modconf]
-> Running build hook: [block]
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-5.3.img
==> Image generation successful
==> Building image from preset: /etc/mkinitcpio.d/linux-5.3.preset: 'fallback'
-> -k /boot/vmlinuz-linux-5.3 -c /etc/mkinitcpio.conf -g /boot/initramfs-linux-fallback-5.3img -S autodetect
==> Starting build: 5.3.0-rc2
-> Running build hook: [base]
-> Running build hook: [udev]
-> Running build hook: [modconf]
-> Running build hook: [block]
==> WARNING: Possibly missing firmware for module: wd719x
==> WARNING: Possibly missing firmware for module: aic94xx
-> Running build hook: [filesystems]
-> Running build hook: [keyboard]
-> Running build hook: [fsck]
==> Generating module dependencies
==> Creating gzip-compressed initcpio image: /boot/initramfs-linux-fallback-5.3.img
==> Image generation successful
sudo cp System.map /boot/System.map-linux-5.3
最後就可以看到我們做好的initramfs, vmlinuz-linux-5.3
$ ls -l /boot/
總計 103768
drwxr-xr-x 3 root root 4096 4月 29 07:38 EFI
drwxr-xr-x 6 root root 4096 4月 29 07:39 grub
-rwxr-xr-x 1 root root 9114131 8月 10 16:13 initramfs-linux-5.3.img
-rwxr-xr-x 1 root root 30909505 8月 10 16:13 initramfs-linux-fallback-5.3.img
-rwxr-xr-x 1 root root 30597644 5月 1 17:20 initramfs-linux-fallback.img
-rwxr-xr-x 1 root root 9126281 5月 1 17:20 initramfs-linux.img
-rwxr-xr-x 1 root root 4087676 8月 10 15:25 System.map
-rwxr-xr-x 1 root root 4087676 8月 10 16:14 System.map-linux-5.3
-rwxr-xr-x 1 root root 6187392 8月 10 15:25 vmlinuz
-rwxr-xr-x 1 root root 5932928 4月 28 04:05 vmlinuz-linux
-rwxr-xr-x 1 root root 6187392 8月 10 15:45 vmlinuz-linux-5.3
更新grub ,開機後就可以到grub選單去選自己的kernel
sudo grub-mkconfig -o /boot/grub/grub.cfg
更新或想要下載套件,如果出現簽章信任等級不明
無法更新
錯誤:git:來自 Levente Polyak (anthraxx) <levente@leventepolyak.net> 的簽章信任等級不明
:: /var/cache/pacman/pkg/git-2.26.1-1-x86_64.pkg.tar.zst 檔案毀損(套件不正確或損毀(PGP 簽章))。
記得更新keyring
pacman -Sy archlinux-keyring && pacman -Syyu
1. Always set your timezone and time right. Make sure your hardware clock is synchronized
*change zone based on your location
sudo timedatectl set-timezone US/Alaska
sudo timedatectl set-ntp true
sudo timedatectl status
2. Refresh your keys
sudo pacman-key --refresh-keys
//if errors are encountered here, restart your system (check system time) and then run this command again.
3. Re-initialize & populate
sudo pacman-key --init
sudo pacman-key --populate
4. Now try
sudo pacman -Syu
Ref:
https://bbs.archlinux.org/viewtopic.php?id=278478
archlinux ip
tesheng@[arch-node]~
$ hostname -i
192.168.50.76
如果遇到下面問題安裝pacakage dependency的問題:
直接 sudo pacman -Sy 後面的package. e.g., sudo pacman -Sy gst-plugins-base
error: failed to prepare transaction (could not satisfy dependencies)
:: installing gst-plugins-base-libs (1.20.1-1) breaks dependency 'gst-plugins-base-libs=1.20.0' required by gst-libav
:: installing gst-plugins-base-libs (1.20.1-1) breaks dependency 'gst-plugins-base-libs=1.20.0' required by gst-plugins-base
disable automoate suspend
gnome-settings-daemon
Ref:
Arch linux 台灣社群
Arch Linux 安裝教學 電腦故我在
鳥哥 磁碟分割: gdisk/fdisk
Arch linux wiki File_systems
成大wiki archlinux
partition_table MBR GPT
如何搶救 Linux 上不能開機的 GRUB 2
arch-linux-kde-plasma-install-and-config
開源的免費中文字型-文泉驛和思源黑體MagicLen
Manjaro字型設定折騰記(上)
Linux 字體 [3] - 中文字型
Arch Traditional_compilation