2 min
72

Cài đặt Arch Linux

Ghi chú về cài đặt Arch Linux

  • #linux
  • #arch

Thiết lập mạng

Mở khóa bộ điều hợp wifi và bật interface, sau đó dùng `iwctl` để kết nối mạng wifi.
  • `rfkill unblock wifi` — bật phần cứng wifi nếu đang bị soft-block
  • `ip link set wlan0 up` — bật interface không dây
  • `iwctl` — mở shell tương tác của iwd
terminal
rfkill unblock wifiip link set wlan0 upiwctl[iwd] station wlan0 scan[iwd] station wlan0 get-networks[iwd] station wlan0 connect <SSID>

Thiết lập ổ đĩa

Phân vùng ổ đĩa, format các phân vùng, mount chúng, rồi cài base system.
  • `lsblk` — liệt kê tất cả block device để tìm ổ đích
  • `cfdisk` — trình phân vùng tương tác, tạo 2 phân vùng: EFI (FAT32) và root (ext4)
  • `mkfs.fat -F32` — format phân vùng đầu thành FAT32 cho EFI
  • `mkfs.ext4` — format phân vùng thứ hai thành ext4 cho root
  • Mount root vào `/mnt` và EFI vào `/mnt/boot/efi`
  • `pacstrap -K` — cài base system với pacman keyring mới
  • `genfstab` — tạo `/etc/fstab` bằng UUID
terminal
lsblkcfdisk /dev/{name_disk}mkfs.fat -F32 /dev/{name_disk}1mkfs.ext4 /dev/{name_disk}2mount /dev/{name_disk}2 /mntmount --mkdir /dev/{name_disk}1 /mnt/boot/efipacstrap -K /mnt base base-devel linux linux-firmware vim intel-ucodegenfstab -U /mnt >> /mnt/etc/fstab

Thiết lập hệ thống

Chroot vào hệ thống mới để cấu hình.
terminal
arch-chroot /mnt

Tạo swap file

Tạo swap file 3GB và thêm vào `/etc/fstab` để giữ sau khi reboot.
terminal
dd if=/dev/zero of=/swapfile bs=1G count=3 status=progresschmod 600 /swapfilemkswap /swapfileswapon /swapfilevim /etc/fstabswapon --show

Đặt múi giờ và đồng hồ

  • `ln -sf` — symlink file múi giờ tới `/etc/localtime`
  • `hwclock --systohc` — đồng bộ hardware clock với system time
terminal
ln -sf /usr/share/zoneinfo/Asia/Ho_Chi_Minh /etc/localtimels -l /etc/localtimehwclock --systohc

Đặt locale

Bỏ comment dòng `en_US.UTF-8 UTF-8` trong `/etc/locale.gen`, rồi generate locale.
terminal
vim /etc/locale.gen # uncomment: en_US.UTF-8 UTF-8locale-genvim /etc/locale.conf # add: LANG=en_US.UTF-8

Đặt hostname và hosts

terminal
vim /etc/hostname # add: archvim /etc/hosts

Đặt mật khẩu root

terminal
passwd

Cài các gói thiết yếu

Cài bootloader, network manager và các công cụ thiết yếu khác.
terminal
pacman -S grub efibootmgr neovim networkmanager network-manager-applet xdg-utils xdg-user-dirs

Bật dịch vụ NetworkManager

Arch dùng systemd, nên bật dịch vụ bằng `systemctl`.
terminal
systemctl enable NetworkManager

Cài bootloader GRUB

terminal
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=ARCHgrub-mkconfig -o /boot/grub/grub.cfg

Tạo user

  • `useradd -mG wheel` — tạo user có thư mục home và thêm vào nhóm `wheel`
  • `visudo` — bỏ comment `%wheel ALL=(ALL) ALL` để cho phép sudo
terminal
useradd -mG wheel baichupasswd baichuEDITOR=vim visudo # uncomment: %wheel ALL=(ALL) ALL

Thoát và khởi động lại

terminal
exitumount -R --lazy /mntreboot

Tài liệu tham khảo

>Newsletter

Stay Updated

Get notified when I publish new articles, tutorials, and project updates. Subscribe for insights and actionable content.