Archlinux - Installation on Thinkpad X1 Carbon 2018
Table of Contents
- Preparition
- Installation
This post aims to record the procedure that I installed ArchLinux on my new notebook, Thinkpad X1 Carbon (x1c) 2018.
Preparition
- Download the installation image from the nearest mirror, e.g., http://mirrors.163.com/archlinux/iso/latest
- Burn the image into a USB stick.
dd if=/path/to/image/ of=/dev/sdb status=progress bs=10M
- The notebook has Windows 10 installed with
快速启动
enabled. Therefore, it needs to be disabled before ArchLinux installation. Uncheck the option of控制面板 -> 硬件和声音 -> 电源选项 -> 选择电源按钮的功能 -> 更改当前不可用的设置 -> 启用快速启动(推荐)
.
Installation
Boot
- Power on the notebook.
- Press
Enter
andF1
to enter the BIOS configuration. - Disable the
Security -> Secure Boot
. - Enable
Config -> Thunderbolt BIOS Assist Mode
. This will significantly reduce the power consumption of CPU wakeups1. - Insert the prepared USB and press
F10
to save the change and reboot the notebook. - Press
Enter
andF12
to temporarily boot from the prepared USB stick.
Partition
For UEFI booting, a dedicated EFI system partition (ESP) is mandatory. EFI bootloaders, applications and drivers can be stored in an ESP and lauched by the UEFI firmware at the boot stage. It is completely independent of OS.
For my SSD, ESP can be detected by
parted /dev/nvme0n1 print
The command returns as follows.
... Number Start End Size File system Name Flags 1 1049kB 274MB 273MB fat32 EFI system partition boot, hidden, esp ...
Clearly, an ESP, i.e., /dev/nvme0n1p1
has already been created in the installation of Windows 10. Therefore, I just need to mount the existing EFI partition before the bootloader installation.
If you do not have an ESP available, you have to create a new one, e.g., creating a primary partition with partion type EFI (FAT-12/16/32)
by fdisk
, and format it as FAT32
.
mkfs.fat -F32 /dev/nvme0n1p1
If following message returns,
WARNING: Not enough clusters for a 32 bit FAT!
reduce cluster size with
mkfs.fat -s2 -F32 /dev/nvme0n1p1
or
mkfs.fat -s1 -F32 /dev/nvme0n1p1
Otherwise, the resulted ESP may be unreadable by UEFI.
Before customization, my SSD already has several partitions.
... Device Start End Sectors Size Type /dev/nvme0n1p1 2048 534527 532480 260M EFI System /dev/nvme0n1p2 534528 567295 32768 16M Microsoft reserved /dev/nvme0n1p3 567296 84453375 83886080 40G Microsoft basic data /dev/nvme0n1p4 498069504 500117503 2048000 1000M Windows recovery environment ...
In addition, I created two ext4
partitions for /
and /home
respectively, as well as a swap by cfdisk
.
cfdisk /dev/nvme0n1
Format the partitions
mkfs.ext4 /dev/nvme0n1p5 mkfs.ext4 /dev/nvme0n1p7 mkswap /dev/nvme0n1p6
Mount the partitions
mount -t ext4 /dev/nvme0n1p5 /mnt mkdir /mnt/home mount -t ext4 /dev/nvme0n1p7 /mnt/home swapon /dev/nvme0n1p6
Connect to the Internet
wifi-menu
Select the nearest mirror
Edit /etc/pacman.d/mirrorlist
as
Server = http://mirrors.163.com/archlinux/$repo/os/$arch
Install the base system
pacstrap /mnt base
Generate file system table
genfstab /mnt >> /mnt/etc/fstab
Chroot into the newly installed system
arch-chroot /mnt
Host name
Create file /etc/hostname
.
notebook
Revise file /etc/hosts
.
# Static table lookup for hostnames. # See hosts(5) for details. 172.0.0.1 localhost ::1 localhost 172.0.0.1 notebook.localdomain notebook
Time zone
ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime
Locale
Edit /etc/locale.gen
and uncomment the following lines.
... en_US.UTF-8 UTF-8 en_US ISO-8859-1 ... zh_CN.GB18030 GB18030 zh_CN.GBK GBK zh_CN.UTF-8 UTF-8 zh_CN GB2312 ...
Generate and set locales.
locale-gen echo LANG=en_US.UTF-8 > /etc/locale.conf
CPU frequency scaling
pacman -S cpupower systemctl enable cpupower
WiFi
Install following two packages. Otherwise, the utility wifi-menu
does not work.
pacman -S dialog wpa_supplicant
Bootloader
From version 3.3 on, the Linux kernel can be directly loaded by EFI firmware as an EFI executable, a.k.a., EFISTUB (EFI BOOT STUB). In other words, grub
-like intermediate bootloaders are not necessary.
Mount ESP
Create /esp
and mount the ESP to it.
mkdir /esp mount -t /dev/nvme0n1p1 /esp
Create /esp/EFI/arch
and bind it to /boot
.
mkdir /esp/EFI/arch mount --bind /esp/EFI/arch /boot
Append following entries to /etc/fstab
.
/dev/nvme0n1p1 /esp vfat rw 0 0 /esp/EFI/arch /boot none defaults,bind 0 0
Microcode
For Intel CPU, package microcode
needs to be installed.
pacman -S intel-ucode
Init ram disk
mkinitcpio -P
Boot manager
Install the boot manager.
pacman -S efibootmgr
Add a new boot entry.
efibootmgr --disk /dev/nvme0n1 --part 1 --create --gpt --label "Arch Linux" --loader /EFI/arch/vmlinuz-linux --unicode "root=/dev/nvme0n1p5 rw initrd=\EFI\arch\intel-ucode.img initrd=\EFI\arch\initramfs-linux.img"
Set the boot order.
efibootmgr --bootorder 0001,0000
Verify the configuration.
efibootmgr
Password for root
passwd
Unmount and reboot
exit umount -R /mnt reboot