Dich

Dich

不专业的专业博客人,记录知识与感想

Arch from beginner to burial.

Preface: Arch Linux is a lightweight, flexible, and rolling-release Linux distribution that has spawned many excellent desktop Linux distributions. Its official Wiki is known as the "Wulin Secret Book" of the technical community. However, the Chinese version of the Wiki is relatively outdated and the installation instructions are not very clear, so we will first use the installation of Arch in a virtual machine as an example to demonstrate the actual operation.

bafkreie4fj4pavox7pt37tjabqo33fv7fnehmonw2che6mjht2y5x3jgly


Preparation: You will need a virtual machine environment (VMware Workstation Pro is recommended) and an ISO image.
VM Learning Edition: https://www.ahhhhfs.com/33472/
Official Image: https://geo.mirror.pkgbuild.com/iso/2023.08.01/


I. Create a virtual machine

  1. Open VM, go to File - New Virtual Machine - Typical - Next. It is recommended to have at least 20GB of disk space for subsequent partitioning. Allocate CPU and memory according to actual needs, usually half.
    Note: After completion, you need to set the boot to UEFI in the Edit Virtual Machine Settings - Options, otherwise it may cause strange boot problems.

Image

Image

  1. Start this virtual machine, then enter the interface, press Enter, and enter tty1.

Image

Image

II. Connect to the network and partition

  1. Use the command "dhcpcd" to obtain an IP address, as networking is easy with NAT in a virtual machine.
  2. Use the command "ping www.baidu.com" to check if the network is connected. If you see ttl, time=xx ms and other data, it means the connection is successful. Then press Ctrl+C to stop the command from running to avoid overloading Baidu.
  3. Use the command "timedatectl set-ntp true" to update the system time. This command has no output, as they say, no news is good news.
  4. Use the command "fdisk -l" to view the system partitions. Due to the existence of the virtual machine, only one hard disk will be displayed.
  5. The next step is the more difficult part of the Arch installation. Taking a 20GB hard disk space as an example, we need to partition a 512MB boot partition, a 15GB root partition, and a 5GB swap partition. Since command line partitioning is more cumbersome, we will use the "cfdisk" command to open the partitioning tool.

Image

Press Enter to select the gpt type, and you will see the following interface:

Image

Use the left and right arrow keys to move to "New" and create a new partition with a size of 512MB. Press Enter to confirm, and move to "type" to change its type to "EFI system". Then repeat the process to create the root partition (type: linux filesystem) and the swap partition (type: linux swap).
Note: After completing the above operations, you need to select "yes" in "Write" to save the partition. Then "quit" to return to the command line.

Image

  1. After partitioning, format each partition using the following commands:
    • mkfs.fat -F32 /dev/sda1
    • mkfs.ext4 /dev/sda2
    • mkswap -f /dev/sda3
      Note that different partition types require different formatting commands.
  2. After formatting, mount the partitions using the following commands:
    • swapon /dev/sda3
    • mount /dev/sda2 /mnt
    • mkdir /mnt/home
    • ls /mnt
    • mkdir /mnt/boot
    • mkdir /mnt/boot/EFI
    • mount /dev/sda1 /mnt/boot/EFI
    • ls /mnt
      Once completed, you can start downloading the components.

III. Install basic components

  1. Use the famous "vim" editor to change the download mirror source to a domestic one to improve download speed: "vim /etc/pacman.d/mirrorlist"

394c1fa62cbd585145343b3f8bbba2ad

It is recommended to use the Tsinghua source. Change the first line to the following command:
Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch
Then press ESC, type "" to save and exit.

basic-install_mirrorlist-2.d629c732

  1. Install the base packages using the command "pacstrap /mnt base base-devel linux linux-firmware dhcpcd". Press Enter to download.

basic-install_pacstrap-2.4c230553

  1. Generate the "fstab" file using the command "genfstab -U /mnt > /mnt/etc/fstab" to automatically mount the partitions. Use the command "cat /mnt/etc/fstab" to observe the partition situation.
  2. Switch to the system environment using the command "arch-chroot /mnt". At this point, you can set the time zone, language, and hostname.
    • Set Shanghai as the system time zone: "ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime"
    • Set the hostname: "vim /etc/hostname" and enter any name you want. Then in "vim /etc/hosts", enter the following content, replacing "name" with the hostname:
      127.0.0.1 localhost
      ::1 localhost
      127.0.1.1 name.localdomain name
      
    • Set the language: Use the command "vim /etc/locale.gen" to uncomment the lines with "en_US.UTF-8 UTF-8" and "zh_CN.UTF-8 UTF-8". Then use the command "locale-gen" to generate the new locale, and use the command "echo 'LANG=en_US.UTF-8' > /etc/locale.conf" to confirm the output.

basic-install_locale-1.59ffa6db

  1. Set the root password using the command "passwd" and set and repeat the password.
  2. Install microcode: Choose the command according to your hardware:
    • Intel: "pacman -S intel-ucode"
    • AMD: "pacman -S amd-ucode"
  3. Install the bootloader: "pacman -S grub efibootmgr os-prober" and install GRUB:
    • "grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ARCH"
    • Generate the configuration file: "grub-mkconfig -o /boot/grub/grub.cfg".
  4. Exit and restart the virtual machine:
    • "exit" to return to the installation environment
    • "umount -R /mnt" to unmount the new partitions
    • "reboot" to restart
      If you successfully enter the login interface, it means the installation was successful. You can use the "neofetch" command to print system information.

basic-install_neofetch.d338d5c5


IV. Install a graphical interface
To facilitate operation in the virtual machine, you can install desktop environments such as KDE Plasma and Xfce.

  1. Use "dhcpcd" to obtain an IP address.
  2. Create a regular user: "useradd -m -G wheel username" (replace "username" with your username) and set a password: "passwd username".
  3. Configure sudo: Install it using "pacman -S sudo" and remove the comment symbol before "%wheel ALL=(ALL)ALL" in "visudo" by running "ln -s /usr/bin/vim /usr/bin/vi; visudo".
  4. After rebooting, start installing the drivers. Due to well-known reasons (NVIDIA), it is relatively difficult to install dedicated graphics card drivers, so it is recommended to only use integrated graphics for now.

Image

For example, if you have an AMD integrated graphics card, use the command "sudo pacman -S xf86-video-amdgpu" to install it, and for OpenGL and Mesa:

sudo pacman -S mesa xf86-video-amdgpu vulkan-radeon libva-mesa-driver mesa-vdpau
sudo pacman -S opencl-mesa lib32-vulkan-radeon lib32-mesa
  1. Use the command "pacman -S plasma-meta konsole dolphin" to install KDE components.
  2. Start the sddm daemon:
systemctl enable sddm
systemctl start sddm
  1. After rebooting, you will enter the desktop environment and the installation will be complete.

arch-2023-08-07-17-35-13

PS: The variety of devices may cause some strange problems during installation, so you need to search and learn on your own to continuously improve your technical skills.

Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.