Before

  1. Check the hardware, three disks on my Lenovo ThinkPad P50

    • Samsung SSD 970 EVO Plus 250GB for installing windows

    • Samsung SSD 960 EVO 250GB for installling archlinux

    • WDC WD5000LPLX-0 HHD 500GB for data storage

  2. Disable Windows Fast Startup if start from windows

  3. Disable UEFI Secure Boot. (Arch Linux install media does not support Secure Boot.)

  4. Windows UEFI vs BIOS limitations. (In case where Windows and Linux dual boot from the same disk, it is advisable to follow the method used by Windows, ie. either go for UEFI/GPT boot or BIOS/MBR boot. )

  5. Bootloader UEFI vs BIOS limitations. (Most of the linux bootloaders installed for one firmware type cannot launch or chainload bootloaders of the other firmware type. If Arch and Windows are dual-booting from same disk, then Arch should follow the same firmware boot mode and partitioning combination used by the installed Windows in the disk.)

Windows 10 Installation

create an windows Installer USB drive using rufus

  • In GNU/Linux

    make a bootable USB on windows in VirtualBox

  • In Windows

    Using Rufus directly

Boot the live environment, F12

install in windows 10 install Samsung SSD 970 EVO Plus 250GB

Arch Linux Installation

Download the last iso of Arch Linux

Create an Arch Linux live USB using rufus

Boot the live environment

Pointing the current boot device to a drive containing the Arch installation media is typically achieved by pressing a key during the POST phase.

When the Arch menu appears, select Boot Arch Linux and press Enter to enter the installation environment.

Set the keyboard layout and Console fonts

If you have the 4K display, console fonts will be extremely small.

1
# setfont sun12x22

Verify the boot mode

1
# ls /sys/firmware/efi/efivars

Connect to the internet

1
2
# wifi-menu
# ping archlinux.org

Update the system clock

1
# timedatectl set-ntp true

Partition the disks

When recognized by the live system, disks are assigned to a block device such as /dev/sda or /dev/nvme1n1.

1
# fdisk -l

Results ending in rom, loop or airoot may be ignored.

1
2
3
4
5
6
7
8
Disk /dev/nvme1n1: 232.91 GiB
Disk model: Samsung SSD 960 EVO 250GB

Disk /dev/nvme0n1: 232.91 GiB
Disk model: Samsung SSD 970 EVO Plus 250GB

Disk /dev/sda: 465.78 GiB
Disk model: WDC WD5000LPLX-0
UEFI with GPT
Mount point Partition Suggested size
/mnt/boot or /mnt/efi /dev/sdX1 EFI system partition 260–512 MiB
/mnt /dev/sdX2 Linux x86-64 root (/) Remainder of the device
[SWAP] /dev/sdX3 Linux swap More than 512 MiB
Swap

On average desktop machines with up to 512 MiB RAM, the 2× rule is usually adequate; if a sufficient amount of RAM (more than 1024 MiB) is available, it may be possible to have a smaller swap partition.

To use hibernation (a.k.a suspend to disk) it is advised to create the swap partition at the size of RAM.

Create a partition table and partitions

1
# gdisk /dev/nvme1n1
Create new table

To create a new GUID Partition Table and clear all current partition data, type o at the prompt. Skip this step if the table you require has already been created.

Create partitions

Create a new partition with the n command. You must enter the partition number, first sector, last sector and the partition type.

Partition number

A partition number is the number assigned to a partition, e.g. a partition with number 1 on a disk /dev/sda would be /dev/sda1.

First and last sector

relative terms by preceding the size with +size or -size. E.g. +2G to specify a point 2 GiB after the default start sector, or -200M to specify a point 200 MiB before the last available sector.

Partition type

The default, Linux filesystem (GUID 0FC63DAF-8483-4772-8E79-3D69D8477DE4, gdisk’s internal code 8300), should be fine for most use cases.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
o (new partition table)
y (confirm)

Command (? for help): n
Partition number (1-128, default 1): 
First sector:
Last sector or {+-}size{KMGTP}: +512M
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to 'EFI System'

Command (? for help): n
Partition number (2-128, default 2): 
First sector:
Last sector or {+-}size{KMGTP}: +8G
Hex code or GUID (L to show codes, Enter = 8300): 8200
Changed type of partition to 'Linux swap'

Command (? for help): n
Partition number (3-128, default 3): 
First sector:
Last sector:
Hex code or GUID (L to show codes, Enter = 8300): 8300
Changed type of partition to 'Linux filesystem'

Command (? for help): w
Do you want to proceed? (Y/N): y
1
2
3
4
Device            Start       End   Sectors   Size Type
/dev/nvme1n1p1     2048   1050623   1048576   512M EFI System
/dev/nvme1n1p2  1050624  17827839  16777216     8G Linux swap
/dev/nvme1n1p3 17827840 488397134 470569295 224.4G Linux filesystem

Format the partitions

an EFI system partition must contain a FAT32 file system

Note: mkfs.vfat is a symlink to mkfs.fat, they are the same utility.

1
# mkfs.fat -F32 /dev/nvme1n1p1

If you created a partition for swap, initialize it with mkswap:

1
2
# mkswap /dev/nvme1n1p2
# swapon /dev/nvme1n1p2

the root partition will contain the ext4 file system

1
# mkfs.ext4 /dev/nvme1n1p3

Mount the file systems

The simplest scenarios for mounting EFI system partition are:

  • mount ESP to /efi and use a boot loader which is capable of accessing the kernel(s) and initramfs image(s) that are stored elsewhere (typically /boot).
  • mount ESP to /boot. This is the preferred method when directly booting a EFISTUB kernel from UEFI.

Tip: /efi is a replacement for the previously popular (and possibly still used by other Linux distributions) ESP mountpoint /boot/efi.

Mount the file system on the root partition to /mnt:

1
# mount  /dev/nvme1n1p3  /mnt
1
2
# mkdir -p /mnt/efi 
# mount /dev/nvme1n1p1 /mnt/efi
1
2
# mkdir -p /mnt/data
# mount /dev/sda1 /mnt/data

Select the mirrors

1
# vim /etc/pacman.d/mirrorlist

The higher a mirror is placed in the list, the more priority it is given when downloading a package. You may want to edit the file accordingly, and move the geographically closest mirrors to the top of the list, although other criteria should be taken into account.

This file will later be copied to the new system by pacstrap, so it is worth getting right.

Install essential packages

1
# pacstrap /mnt base base-devel linux-lts linux-lts-headers linux-firmware gvim dhcpcd networkmanager man-db man-pages

Configure the Linux system

Fstab

Generate an fstab file:

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

Check the resulting /mnt/etc/fstab file, and edit it in case of errors.

1
# cat /mnt/etc/fstab

Chroot

Change root into the new system:

1
# arch-chroot /mnt

Time zone

1
2
# ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
# hwclock --systohc

Localization

Uncomment en_US.UTF-8 UTF-8 and zh_CN.UTF-8 UTF-8 locales in /etc/locale.gen, and generate them with:

1
# locale-gen

Create the locale.conf file, and set the LANG variable accordingly:

1
# vim /etc/locale.conf
1
LANG=en_US.UTF-8

If you set the keyboard layout, make the changes persistent in vconsole.conf:

1
# vim /etc/vconsole.conf
1
Font=sun12x22

Network configuration

Create the hostname file:

1
# vim /etc/hostname
1
myhostname

Add matching entries to hosts:

1
# vim /etc/hosts
1
2
3
4
5
127.0.0.1	localhost
::1		localhost
127.0.1.1	myhostname.localdomain	myhostname

104.18.57.236 free-ss.site

If the system has a permanent IP address, it should be used instead of 127.0.1.1.

1
# pacman -S vim iputils networkmanager
1
2
# systemctl enable NetworkManager
# systemctl enable dhcpcd

Root password

Set the root password:

1
# passwd

# Represents executing commands as Root users, $ Represents executing commands as ordinary users

Add a new user
1
2
# useradd -m username
# passwd username
Install sudo
1
2
# pacman -S sudo
# vim /etc/sudoers
1
username  ALL=(ALL) ALL

Boot loader for UEFI systems

Detecting other operating systems

To have grub-mkconfig search for other installed systems and automatically add them to the menu, install the os-prober and ntfs-3g package and mount the partitions that contain the other systems. Then re-run grub-mkconfig.

1
# pacman -S os-prober ntfs-3g
microcode updates

Choose and install a Linux-capable boot loader. If you have an Intel or AMD CPU, enable microcode updates in addition.

1
# pacman -S intel-ucode
install a Linux-capable boot loader
1
# pacman -S grub efibootmgr

EFI directory must be EPS mount point.

Choose a bootloader identifier, here named GRUB. A directory of that name will be created in /efi/EFI/ to store the EFI binary and this is the name that will appear in the UEFI boot menu to identify the GRUB boot entry.

Execute the following command to install the GRUB EFI application grubx64.efi to /efi/EFI/GRUB/ and install its modules to /boot/grub/x86_64-efi/.

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

Check

1
vim /boot/grub/grub.cfg

checks it for syntax errors, and entry point in menuentry menu.

Reboot

Exit the chroot environment by typing exit or pressing Ctrl+d.

1
umount -R /mnt/efi

Optionally manually unmount all the partitions with umount -R /mnt: this allows noticing any “busy” partitions, and finding the cause with fuser.

Finally, restart the machine by typing reboot: any partitions still mounted will be automatically unmounted by systemd. Remember to remove the installation media and then login into the new system with the root account.

References

  1. https://wiki.archlinux.org/index.php/EFI_system_partition
  2. https://www.viseator.com/2017/05/17/arch_install/