Introduction: Arch Linux is a lightweight, flexible, 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 world; however, the Chinese version of this Wiki is relatively outdated and the installation instructions are not very clear, so we will use the installation of Arch on a virtual machine as an example to demonstrate the actual operation.
Preparation: You will need a virtual machine environment (we recommend using VMware Workstation Pro) and an ISO image.
VM Learning Edition: https://www.ahhhhfs.com/33472/
Official image: https://geo.mirror.pkgbuild.com/iso/2023.08.01/
I. Creating a virtual machine
- Open VM, go to File - New Virtual Machine - Typical - Next. It is recommended to allocate at least 20GB of disk space for subsequent partitioning; CPU and memory should be allocated based on actual needs, usually half.
Note: After completion, you need to go to Edit Virtual Machine Settings - Options and set the boot mode to UEFI, otherwise it may cause strange boot problems.
- Start the virtual machine and then enter the interface. Press Enter and run the code to enter tty1.
II. Networking and partitioning
- Use the dhcpcd command to obtain an IP address, as networking is easy with NAT in a virtual machine.
- Use the ping www.baidu.com command to check if you are connected to the internet. If you see ttl,time=xx ms and other data, it means you are connected. Then press Ctrl+C to stop the command from running to avoid overloading Baidu.
- Use the timedatectl set-ntp true command to update the system time. This command does not have any output, as they say, no news is good news.
- Use the fdisk -l command to view the system partitions. Due to the existence of the virtual machine, only one disk will be displayed.
- The next step is the more difficult part of the Arch installation. Taking a 20GB disk space as an example, we need to create 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.
Press Enter to select the gpt type, and you will see the following interface:
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, follow the same steps 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, select quit to return to the command line.
- 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. - 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
After completing these steps, you can start downloading the components.
III. Installing basic components
- Use the famous vim editor to change the download mirror to a domestic one to improve download speed: vim /etc/pacman.d/mirrorlist
It is recommended to use the Tsinghua mirror. Change the first line to the following command:
Server = http://mirrors.tuna.tsinghua.edu.cn/archlinux/$repo/os/$arch, then press ESC and type to save and exit.
- Install the base packages using the command pacstrap /mnt base base-devel linux linux-firmware dhcpcd and press Enter to download.
- 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 check the partition status.
- Switch to the system environment using the command arch-chroot /mnt. You can now 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: Use the command 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 en_US.UTF-8 UTF-8 and zh_CN.UTF-8 UTF-8, and then generate the new locale using the command locale-gen. Confirm the output using the command echo 'LANG=en_US.UTF-8' > /etc/locale.conf.
- Set the root password using the command passwd and set and confirm the password.
- Install microcode: Choose the command based on your hardware:
pacman -S intel-ucode # Intel
pacman -S amd-ucode # AMD - 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. - Exit and restart the virtual machine:
exit # Return to the installation environment
umount -R /mnt # Unmount the new partitions
reboot # Restart
If you successfully enter the login interface, it means the installation was successful. You can use the neofetch command to print system information.
IV. Installing a graphical interface
To facilitate operation in the virtual machine, you can install desktop environments such as KDE Plasma and Xfce.
- Use the dhcpcd command to obtain an IP address.
- Create a regular user using the command useradd -m -G wheel username (replace username with your username) and set a password using the command passwd username.
- Configure Sudo: Install it using the command pacman -S sudo and remove the comment symbol in front of %wheel ALL=(ALL)ALL in visudo by running ln -s /usr/bin/vim /usr/bin/vi.
- After rebooting, start installing the drivers. Due to well-known reasons (NVIDIA fuck you), it is relatively difficult to install the discrete graphics card driver, so it is recommended to only use the integrated graphics card for now.
For example, if you have an AMD integrated graphics card, use the command sudo pacman -S xf86-video-amdgpu to install it, and install 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
5. Use the command pacman -S plasma-meta konsole dolphin to install KDE components.
6. Start the sddm daemon:
systemctl enable sddm
systemctl start sddm
7. After rebooting, you will enter the desktop environment, and the installation is complete.
PS: Due to the variety of devices, there may be some strange problems during the installation process. You need to search and learn on your own to continuously improve your technical skills.