[detailed explanation] ArchLinux installation

BIOS installation of Arch Linux really bothers me QAQ

The following article will introduce the installation process in detail based on the Wiki of Arch Linux

I strongly don't recommend novices to toss around with Arch Linux. If you are a novice, I still recommend you to install a Linux based on Arch Linux Manjaro system

1. Verify startup mode

Verify whether it is started in UEFI mode, otherwise it is started in BIOS mode

ls /sys/firmware/efi/efivars

2. Check the network connection

ping www.baidu.com -c3 # Ping Baidu automatically exits after 3 times

You can also press Ctrl+C to exit Ping

Attachment: wireless network connection

iwctl # Enter iwctl

After entering:

device list # Look at the name of your network card
station wlan0 scan # wlan0 is the name of the wireless network card
station wlan0 get-networks # View scanned wireless networks
station wlan0 connect CMCC # wlan0 is the name of the wireless network card and CMCC is the network name

Next, after entering the password, the connection is successful. Enter exit to exit

If you can't connect to the Internet, enter the following command to try:

systemctl start dhcpcd # Enter this and try ping again

3. Update system time

Synchronization system time:

timedatectl set-ntp true

You can use timedatectl status to check the service status

4. Replace the image source

Disable Reflector service: systemctl stop Reflector Service (this service will automatically modify the software source and delete other software sources)

Edit with Vim:

vim /etc/pacman.d/mirrorlist
  1. Press /, Enter China, press Enter, navigate to the CN source, and navigate to the line of your favorite source
  2. Press the D key twice to cut the mirror source
  3. Press G twice to return to the top of the file
  4. Select a position at the top and press P to paste
  5. Press Esc and enter: wq exit Vim

5. Set disk type

You can use lsblk to view the current disk status first

Use the parted command to operate on the disk:

parted /dev/sda # /dev/sda is the disk to operate on

After entering, enter:

mktable

It asks what type of disk do you want? Input gpt

After the operation is completed, enter quit to exit

6. Disk partition

Enter the partition operation interface:

cfdisk /dev/sda

Press Enter to Enter the partition operation interface

  • This is an example of a partition started by UEFI:

    DeviceSizeSize Type
    /dev/sda1300MEFI System
    /dev/sda22GLinux swap
    /dev/sda325GLinux filesystem
    /dev/sda460GLinux filesystem
  • This is an example of a BIOS boot partition:

    It is not recommended to partition the / boot directory, because ArchLinux adopts the rolling update policy, so the / boot directory will become larger and larger. In case of overcrowding, the kernel cannot be installed, causing problems. The EFI System partition above and the BIOS boot partition below are not / boot partitions! Don't mix it up!

    DeviceSizeSize Type
    /dev/sda11MBIOS boot
    /dev/sda22GLinux swap
    /dev/sda325GLinux filesystem
    /dev/sda460GLinux filesystem

After setting, move the cursor under Write, press Enter, and then Enter yes

Move the cursor under quit to exit

You can enter fdisk -l to view the disk partition

7. Format disk

To UEFI

Format root partition:

mkfs.ext4 /dev/sda3 # Format sda3 (that is, the root directory) into ext4 type

Format home directory partition:

mkfs.ext4 /dev/sda4 # Format sda4 (that is, home directory) into ext4 type

Format EFI partition:

mkfs.vfat /dev/sda1 # Format sda1 (that is, EFI partition) into vfat type

Format swap partition:

mkswap -f /dev/sda2 # Format sda2 (that is, swap partition) into swap type
swapon /dev/sda2 # Start swap

Give BIOS

Format the root directory as ext4:

mkfs.ext4 /dev/sda3 # Format sda3 (that is, the root directory) into ext4 type

Format home directory partition:

mkfs.ext4 /dev/sda4 # Format sda4 (that is, home directory) into ext4 type

Format swap partition:

mkswap -f /dev/sda2 # Format sda2 (that is, swap partition) into swap type
swapon /dev/sda2 # Start swap

8. Mount disk

To UEFI

Mount root directory:

mount /dev/sda3 /mnt

Mount home directory:

mkdir /mnt/home # Create home directory
mount /dev/sda4 /mnt/home # Mount home directory

Mount EFI partition:

mkdir /mnt/boot # Create boot directory
mkdir /mnt/boot/EFI # Create EFI directory
mount /dev/sda1 /mnt/boot/EFI # Mount EFI directory

Give BIOS

Mount root directory:

mount /dev/sda3 /mnt

Mount home directory:

mkdir /mnt/home # Create home directory
mount /dev/sda4 /mnt/home # Mount home directory

9. Install ArchLinux

Install the necessary packages:

pacstrap /mnt base linux linux-firmware

Install functional software:

pacstrap /mnt dhcpcd iwd vim sudo

10. Configure ArchLinux

Generate fstab file:

genfstab -U /mnt >> /mnt/etc/fstab

It is strongly recommended to use cat /mnt/etc/fstab to check whether the file is correct

Enter the new system:

arch-chroot /mnt

Set time zone:

ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime

Synchronous hardware clock:

hwclock --systohc

Edit / etc / locale Gen set local address:

vim /etc/locale.gen

Setting steps:

  1. Press / enter en_US enter, and then press N to find the next target until it is found

    #en_ US. UTF-8, UTF-8, move the cursor to # below and press the x key to remove the comment

  2. After the operation, press Esc and enter: wq save and exit Vim

Then execute the following command to generate Locale information:

locale-gen

Then go to locale Conf enter something:

echo 'LANG=en_US.UTF-8' > /etc/locale.conf

Cat / etc / locale. Is highly recommended Conf check whether the file is correct

Set host name:

echo yuxiang-PC > /etc/hostname

Then add the following to the / etc/hosts file:

vim /etc/hosts
127.0.0.1    localhost
::1		localhost
127.0.1.1	yuxiang-PC.localdomain	yuxiang-PC # Host name Local domain name host name

If the system has a permanent IP address, please use this permanent IP address instead of 127.0.1.1

The empty part is Tab!!

Set Root user password:

passwd root

Install microcode:

pacman -S intel-ucode # Intel CPU
pacman -S amd-ucode # AMD CPU

11. Install the boot program

Warning: This is the last but crucial step of installation. Please install the boot loader correctly according to the above instructions before restarting. Otherwise, you will not be able to enter the system normally

To UEFI

Install the necessary packages:

pacman -S grub efibootmgr

Install Grub for UEFI system:

grub-install --target=x86_64-efi --efi-directory=/boot/EFI --bootloader-id=GRUB

Generate profile:

grub-mkconfig -o /boot/grub/grub.cfg

Give BIOS

Install prerequisites:

pacman -S grub

Install Grub for BIOS system:

grub-install --target=i386-pc --recheck /dev/sda # /dev/sda is the disk to be installed

Where / dev/sda is the disk on which GRUB is to be installed, not partition / dev/sda1

Generate profile:

grub-mkconfig -o /boot/grub/grub.cfg

After that, enter exit to return to the installation environment

Unmount partition using umount -R /mnt

Enter reboot to restart! Unplug the USB flash disk after restart!

12. Set up network for the new system

After logging into the Root account and entering the system, enter:

systemctl enable dhcpcd # Set startup and self startup

Start dhcpcd now:

systemctl shart dhcpcd # Start now!

After a few seconds, use ping to detect the network:

ping www.baidu.com -c3 # Ping Baidu automatically exits after 3 times

You can also press Ctrl+C to exit Ping

Attachment: viewing system information from the command line

You can install neofetch to view system information from the command line:

pacman -S neofetch
neofetch # View system information

Keywords: Linux ArchLinux

Added by n14charlie on Mon, 31 Jan 2022 01:58:25 +0200