banner
Yuzhen

Yuzhen's Blog

🇨🇳 13 y.o. / Student & Developer & OIer / HAM & BGP Player
telegram
tg_channel
github
mastodon
email
zhihu

[Legacy] How to Elegantly Migrate to Arch Linux

Preface#

This article is only applicable to UEFI boot.
This article is intended for migrating from Windows to Archlinux.
The author does not guarantee that the methods in this article will work on your computer.
This article is shared under the Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International (CC BY-NC-SA 4.0) license.
If there are any errors in the content of the article, please point them out, thank you.

Table of Contents#

0x00 Background

0x01 Backup Data

0x02 Create Installation Media

  • Download Image
  • Write to USB Drive

0x03 Install System

  • Boot from USB Drive
  • Connect to Wi-Fi (wired users can skip this)
  • Sync pacman
  • Disk Partitioning
  • Formatting
  • Mounting Partitions
  • Install System
  • Configure Boot
  • Exit New System and Unmount

0x04 Configure System

0x05 KDE Configuration

  • Fcitx5+Rime

0x06 Software Related

  • Quick Software Reference
  • Using AUR (Arch User Repository)
    • Install yay
    • Use yay to install packages
  • Run Windows applications using wine
  • Run Windows applications using winapps
  • Create Windows Virtual Machine

0x07 System Beautification

  • GRUB Beautification
  • SDDM Beautification
  • KDE Beautification
    • Plugins

0x08 Appendix

  • How to use yay

0x09 References


0x00 Background#

The author's computer has a 512GB NVMe SSD and a 2TB Western Digital Black external (mechanical) hard drive, so the author needs to clone the Windows partition to the external hard drive first, then format everything for Archlinux installation.

0x01 Backup Data#

Use WeiPE and DiskGenius tools for data backup and partition cloning.
Since you may not be able to attend online classes or do exercises in the PE environment, we can first use DiskGenius's partition imaging feature to save the partition image to the external hard drive, and then return to the Windows system to restore the partition image to the external hard drive using DiskGenius (this is because partition imaging is a 4K/sequential read and write operation, while partition restoration is a sequential read 4K/sequential write operation, and the small file read and write speed of SSDs is significantly greater than that of mechanical hard drives).

  1. Create WeiPE Environment
    WeiPE Download Link
    The author wrote this under Arch and cannot demonstrate it, so it is recommended to find a tutorial yourself.
  2. Enter the WeiPE environment and use DiskGenius for disk imaging operations.
    The author wrote this under Arch and cannot demonstrate it, so it is recommended to find a tutorial yourself.
  3. Return to the Windows environment to restore the hard drive.
    The author wrote this under Arch and cannot demonstrate it, so it is recommended to find a tutorial yourself.
    Note here that after the restoration is complete, the hard drive will be offline. You need to open Computer -> Management -> Disk Management, right-click the external hard drive and click Online, and Disk Management will reassign the serial number to the partition.

0x02 Create Installation Media#

Download Image#

First, download the ISO image: Official Download Link, it is recommended to scroll down to find mirrors in China for download.

Write to USB Drive#

Then write to the USB drive, it is recommended to use Rufus tool, select GPT for partition type instead of the default MBR, and use DD for the write method instead of ISO.

0x03 Install System#

Connect to Wi-Fi (wired users can skip this)#

  1. Enter iwctl to access the iwd command line.
  2. Enter device list to view wireless network card devices.
  3. Assuming the wireless network card is wlan0, enter station wlan0 scan to scan for networks.
  4. Enter station wlan0 get-networks to view the scanned networks.
  5. Assuming the SSID of the network to connect to is 114514, enter station wlan0 connect 114514, and if there is a password, enter it.
  6. Enter exit to exit the iwd command line.

Sync pacman#

Enter the following command, which will automatically select the fastest mirror source and replace it:

reflector -c China --sort rate --save /etc/pacman.d/mirrorlist

After completion, enter pacman -Syyy to sync the pacman source (as shown in the image).
Image 1

Partition Formatting#

Assuming the partition is nvme0n1p2, enter the following command:

mkfs.ext4 /dev/nvme0n1p2

Mounting Partitions#

  1. Mount the partition where the system will be installed to /mnt:
mount /dev/nvme0n1p2 /mnt
  1. Create the /mnt/boot folder:
mkdir /mnt/boot
  1. Mount the EFI partition to /mnt/boot, assuming the EFI partition is nvme0n1p1:
mount /dev/nvme0n1p1 /mnt/boot

Install System#

  1. Execute the following command to install the basic system:
pacstrap /mnt base linux linux-firmware nano
  1. Generate the fstab file:
genfstab -U /mnt >> /mnt/etc/fstab
  1. Switch to the installed system:
arch-chroot /mnt
  1. Create a swapfile:
dd if=/dev/zero of=/swapfile bs=2048 count=1048576 status=progress # Create swapfile
chmod 600 /swapfile # Change permissions
mkswap /swapfile # Create swap
swapon /swapfile # Activate swap
  1. Modify fstab to support swapfile.
    Enter nano /etc/fstab, add /swapfile none swap defaults 0 0 at the end of the file, then press Ctrl+O Enter Ctrl+X in order to save and exit.
  2. Set the timezone:
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
  1. Sync hardware clock:
hwclock --systohc
  1. Set locale, enter nano /etc/locale.gen, press Ctrl+W and then input #en_US Enter, find UTF-8, delete the hash to uncomment it, then Ctrl+W search #zh_CN Enter, find UTF-8, delete the hash to uncomment it, and then press Ctrl+O Enter Ctrl+X in order to save and exit.
  2. Generate locale:
locale-gen
  1. Create and write to the /etc/locale.conf file.
    Enter nano /etc/locale.conf, fill in LANG=en_US.UTF-8, then press Ctrl+O Enter Ctrl+X in order to save and exit.
  2. Create and write to hostname.
    Enter nano /etc/hostname, fill in the hostname you want to use (e.g., jindan), then press Ctrl+O Enter Ctrl+X in order to save and exit.
  3. Write to hosts.
    Enter nano /etc/hosts, write the content as shown in the image, then press Ctrl+O Enter Ctrl+X in order to save and exit (temporarily using an image from a Zhihu expert, see the references section at the end of the article).
    image
  4. Create a password for the root user:
passwd

Then enter and confirm the password (the password in the Linux terminal does not echo, just press Enter after typing).

Configure Boot#

  1. Install GRUB package and other necessary packages:
pacman -S grub efibootmgr networkmanager network-manager-applet dialog wireless_tools wpa_supplicant os-prober mtools dosfstools ntfs-3g base-devel linux-headers reflector git sudo
  1. Install microcode.
    If it is an Intel CPU, install Intel's microcode files:
pacman -S intel-ucode

If it is an AMD CPU, install AMD's microcode files:

pacman -S amd-ucode
  1. If you have other systems to boot (especially Windows), enable OS Prober to automatically detect other systems.
    Enter nano /etc/default/grub to access nano, add GRUB_DISABLE_OS_PROBER=false at the end, then press Ctrl+O Enter Ctrl+X in order to save and exit.
  2. Install GRUB:
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=Arch
grub-mkconfig -o /boot/grub/grub.cfg

Exit New System and Unmount#

exit
umount -a
reboot

0x04 Configure System#

  1. Start network service:
systemctl enable --now NetworkManager
  1. Connect to Wi-Fi (wired users can skip this):
nmtui
  1. Create a new user and grant permissions.
    Assuming the username is jindan, enter:
useradd -m -G wheel jindan
  1. Set password for the new user:
passwd jindan

Enter and confirm the password.
5. Grant permissions.
Enter EDITOR=nano visudo to access nano, Ctrl+W input # %wheel Enter, delete the hash to uncomment it, then press Ctrl+O Enter Ctrl+X in order to save and exit.
6. Install graphics card driver.
Install AMD graphics card driver:

pacman -S xf86-video-amdgpu

Install NVIDIA graphics card driver:

pacman -S nvidia nvidia-utils
  1. Install Display Server (xorg):
pacman -S xorg
  1. Install Display Manager.
    Gnome:
pacman -S gdm

KDE:

pacman -S sddm

Xfce / DDE:

pacman -S lightdm lightdm-gtk-greeter
  1. Set to start automatically on boot, assuming KDE (sddm) is installed:
systemctl enable sddm
  1. Install Desktop Environment.
    Gnome:
pacman -S gnome

KDE:

pacman -S plasma kde-applications packagekit-qt5

Xfce:

pacman -S xfce4 xfce4-goodies

DDE:

pacman -S deepin deepin-extra
  1. Add archlinuxcn source.
    Enter nano /etc/pacman.conf, write the content as shown in the code block below, and uncomment the multilib source, then press Ctrl+O Enter Ctrl+X in order to save and exit.
## Aliyun (Global CDN) (ipv4, ipv6, http, https)
## Added: 2020-07-03
[archlinuxcn]
Server = https://mirrors.aliyun.com/archlinuxcn/$arch
  1. Sync pacman source and install keyring:
pacman -Syu && pacman -S archlinuxcn-keyring
  1. Install fonts:
pacman -S ttf-sarasa-gothic noto-fonts-cjk
  1. Restart:
reboot

0x05 KDE Configuration#

Fcitx5+Rime#

Fcitx5 is the new generation input method framework following Fcitx.

Rime (Zhongzhou Yun Input Method Engine) is an input method engine that supports multiple input schemes.

Rime itself does not provide a frontend for handling user input and needs to work with an input method framework, such as Fcitx5 (Simplified Chinese) or IBus (Simplified Chinese).

  1. Enter the following command to install:
sudo su
pacman -S fcitx5-im
echo "GTK_IM_MODULE=fcitx" >> /etc/environment
echo "QT_IM_MODULE=fcitx" >> /etc/environment
echo "XMODIFIERS=@im=fcitx" >> /etc/environment
echo "INPUT_METHOD=fcitx" >> /etc/environment
echo "SDL_IM_MODULE=fcitx" >> /etc/environment
cp /usr/share/applications/org.fcitx.Fcitx5.desktop ~/.config/autostart/
pacman -S fcitx5-rime
exit

After installation, a restart may be required.
2. Add input method:
image
image
4. Set to Simplified Chinese:
image

A All functions are available
X Not available
/ Not tested
Note: The deepin-wine package in AUR is also considered as native/AUR category.

NameNative/AURWineWinApps
WeChatX//
QQA//
DingTalkCannot conduct meetings//
Microsoft OfficeX/A

Using AUR (Arch User Repository)#

The Arch User Repository (AUR) is a user-driven repository for Arch software. Packages in AUR are provided in the form of package build scripts (PKGBUILD), and users generate packages themselves using makepkg, which are then installed by pacman. The purpose of creating AUR is to facilitate users in maintaining and sharing new packages, and official packages are periodically selected from it to enter the community repository.

When you want to install any software, you can first visit the AUR official website to check if the software you need is available. If it is, you can directly use yay to install it. The installation and usage methods of yay are described below.

Install yay#

yay is a tool for quickly installing AUR packages.

  1. Install git:
sudo pacman -S git
  1. Clone the yay repository:
git clone https://aur.archlinux.org/yay.git
  1. Build and install:
cd yay
makepkg -si

Use yay to install packages#

Enter yay -S <package_name> to install. If asked whether to show differences, enter n and press Enter to ignore, otherwise enter y and press Enter to confirm.
For more information, please refer to the How to use yay section in the Appendix.

Create Windows Virtual Machine#

  1. Install KVM and Virtual Machine Manager:
pacman -S virt-manager
  1. Download Windows 10 ISO and virtio drivers.
    Windows 10 ISO: https://www.microsoft.com/en-us/software-download/windows10ISO (Windows 11 is also acceptable)
    VirtIO drivers: https://fedorapeople.org/groups/virt/virtio-win/direct-downloads/stable-virtio/virtio-win.iso
  2. Open Virtual Machine Manager:
    image
    Then click Edit -> Preferences, enable Enable XML editing (as shown).
    image
  3. Click File -> Add Connection, ensure the settings are the same as in the image, and click Connect.
    image
  4. Click to create a new virtual machine:
    image
  5. Select QEMU/KVM connection, click Forward (as shown).
    image
  6. Select the image (as shown).
    image
  7. Set memory and CPU, it is recommended to set to 4096MB, this is actually the maximum memory usage (the author is too lazy and directly used the official document's image).
    image
  8. Choose the size of your virtual disk, remember this is the maximum size the disk will grow to, but it will not occupy this space until it needs it.
    image
  9. Next, name your machine, name it RDPWindows so that WinApps can detect it, then select Customize configuration before install.
    image
  10. Click Finish, ensure that Copy host CPU configuration under CPU is selected, then Apply.
  11. Next, go to the XML tab and edit the <clock> section to include:
<clock offset='localtime'>
  <timer name='hpet' present='yes'/>
  <timer name='hypervclock' present='yes'/>
</clock>

Then Apply, this will greatly reduce idle CPU usage (from ~25% to ~3%).
Then you can start the system for a normal Windows installation.

0x07 System Beautification#

GRUB Beautification#

  1. Choose a favorite theme and download it.
    You can find GRUB themes on the Gnome-look website. Click on the theme you like to enter its homepage, click Files, and select the corresponding version to download (as shown).
    image
  2. Script installation.
    The theme I chose is Grub-theme-vimix. After unzipping, you can find that the theme comes with an install.sh script, which can be used for installation. Enter:
bash install.sh
  1. Manual installation.
    Waiting for supplement.

SDDM Beautification#

yay -S sddm-config-editor-git
yay -S archlinux-themes-sddm

Then search and open SDDM Configuration, click on the theme to change it. If you are using the plasma default theme, you can use breeze (as shown).
image

KDE Beautification#

Plugins#

  • Awesome Widget can display custom system parameters.
  • Weather Widget will display the weather in both icon and table formats.
  • Global Menu used in conjunction with Application title achieves a MacOS effect, making the interface more beautiful and operations more convenient.
  • Panon sound visualization plugin.
  • Event Calendar for quick task addition, displaying weather, dates, and holidays.

0x08 Appendix#

How to use yay#

When using the Arch User Repository, AUR tools can automate certain tasks:

  • Search for packages published in AUR.
  • Resolve dependencies between AUR packages.
  • Download AUR packages.
  • Download website content, such as user comments.
  • Submit AUR packages.

pacman only handles updates for pre-built packages in its repository. AUR packages are redistributed in the form of PKGBUILD and require an AUR helper to automate the build process. However, please note that even if the package itself has not been updated, you may still need to rebuild certain packages due to updates in some library files.
It will not check for updates for AUR packages, so some tools can also automatically check for updates from AUR and rebuild new versions of packages. Please note that even if the package itself has not been updated, you may still need to rebuild certain packages due to updates in some library files.

Basic Usage#

yay -S <package_name> # Search for package in AUR and install
yay -Ss <package_name> # Search for package in AUR and official sources
yay -Si <package_name> # Get package information in AUR
yay -U <package_path> # Install local package
yay -Pu # Check for updates
yay -Sy # Sync
yay -Syu # Update system
yay -Syua # Update system and already installed AUR packages
yay -Yc # Remove unnecessary dependencies
yay -R <package_name> # Remove package
yay -Rs <package_name> # Remove package and its dependencies
yay -Rnsc <package_name> # Remove package, dependencies, and configuration files

0x09 References#

  1. ArchWiki: Your online Arch Linux documentation library (official Wiki)
  2. 2021 Archlinux dual system installation tutorial (super detailed) (Zhihu) Author: ayamir
  3. Linux Grub boot interface (startup interface) beautification (Zhihu) Author: Kuari
  4. KDE beautification journey (Zhihu) Author: Zhihu user 9g4W9C

As a beginner in Archlinux, I sincerely thank the authors of the above reference materials.
Thanks to @Hello for reporting errors.

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