I’ve a dual GPU laptop: Lenovo Legion Y520-15IKBN; the Nvidia GeForce 1050 Ti Mobile for graphics-heavy (3D) tasks and Intel HD Graphics 630 for rendering the rest. It has an SSD and a traditional spinning disk. UEFI + GPT as opposed to the classic BIOS + MBR combo is preferable. I’m a long-time Xubuntu user but I wanted to try Arch Linux. Here I note my experience in getting this laptop up and running.

Prelims

A few things upfront — detailed later — to decide if this guide is for you

  1. Secure boot off: at least for (USB) installation. Longer term, there’re some hoops to jump through but you can enable it back on
  2. SSD vs non-SSD: Use spinning disks for volatile data
  3. SATA vs RAID: To even detect your M.2 PCIe SSD the storage controller is to be set to ACHI and not Intel RST
  4. LVM: if you want the flexibility of changing partition sizes without data loss, post installation, even while mounted

Being a Emacs junkie one of the first things I do when I start using a new environment is remap my CAPSLOCK to CONTROL.

Ctrl your CapsLk

Map CAPSLOCK to CTRL with loadkeys just for the current session

dumpkeys | head -1 > keys.map
echo 'keycode 58 = Control' >> keys.map
loadkeys keys.map
rm keys.map

Once we’ve a desktop environment setup, this can be made permanent with .Xmodmap.

Wireless Network

Without internet access modern linux installations are an exercise in pain. I didn’t have an ethernet cable so I had to get wi-fi up:

  1. If ping fails, disable dhcpcd service with systemctl stop dhcpcd@ (press TAB)
  2. Check wireless interface creation with iw dev; it should list the interface name e.g. wlp3s0
    • If absent, lspci -v to ensure the wireless network controller drivers loaded right
    • ip link show shows the networking interfaces present
  3. Check if wireless is not blocked with rfkill list
    • If hard-blocked, press hardware button to enable wireless hardware
    • If soft-blocked: rfkill unblock wifi
  4. cp /etc/netctl{/examples,}/wireless-wpa
    • Just copy an example profile and tweak
    • Arch comes with netctl (network manager) and WPA supplicant for connection to WPA secured networks
    • Can’t use iw or wireless_tools if the network uses WPA2 Personal
  5. Edit parameters in copied file as per network
    • Use wpa_passphrase to get the hex passphrase to put in netctl’s profile
    • Make sure you run wpa_passphrase with the correct SSID
    • Set custom DNS servers for netctl to write to /etc/resolv.conf
Description='A simple WPA encrypted wireless connection'
Interface=wlp3s0
Connection=wireless

Security=wpa
IP=dhcp

ESSID='InfoProbe'
Key=\72ac...
Hidden=yes
DNS=('1.1.1.1' '1.0.0.1')
  1. netctl start wireless-wpa
  2. Ping should now work if all went well

In case netctl errors out, it might be because of two things:

  1. A DHCP daemon is still running; do systemctl stop ... as in step 1
  2. The interface is already up; netctl needs it down: ip link set wlp3s0 down

Partitions

SSD

Check if the drive got detected ls /dev/nv*. If not, the SSD is probably configured to use the RST (RAID) storage controller which Linux doesn’t seem to detect. It has to be AHCI (SATA) controller.

If the default Windows installation was done with RST selection, Windows 10 will not boot if this switch is flipped. Recovering Windows without a reinstallation is possible. Minimal Safe Mode can be enabled/disabled without using bcdedit through GUI too: msconfig. Tests show that using the older AHCI doesn’t incur any significant performance hit over RAID.

Scheme

SSDs are not recommended for volatile data, so /var and swap space should be allocated on spinning disk. Rest like /boot, /, /usr, etc. can be left on the SSD: seen under /dev/nvme0nXpY not /dev/sda; X is the disk number, Y is the partition.

Note: /boot needn’t be in a separate partition while /boot/efi should be; the EFI System Partition partition is mounted in /boot/efi. /boot on its own partition, outside LVM, additionally has the advantage of GRUB environment block; useful if you use GRUB_SAVEDEFAULT for GRUB to remember last OS selection.

Partition with cfdisk and verify them with lsblk or fdisk -l. Choose Linux filesystem for Partition Type for everything except swap and LVM. Mind that these partitions are the ones created outside the LVM; if you’re going to manage all your Linux partitions with LVM, just create one partition (in addition to ESP) and set its type to Linux LVM in fdisk.

My final scheme (sublist intelligible after reading the next section)

  1. /boot/dev/nvme0n1p5 (512 MiB)
  2. LVM → /dev/nvme0n1p6 (54.5 GiB)
    1. //dev/lvmg1/root (40 GiB)
    2. /home/dev/lvmg1/home (remaining)
  3. /vardev/sda5 (4 GiB)
  4. swap → dev/sda6 (4 GiB)

LVM

Using LVM2 seems to be recommended by many since it has various advantages including resizing of partitions even when they’re mounted. I’ve set aside the bulk (except 512 MiB for /boot) of SSD for LVM2. The spinning disk is used for

  • /var
  • swap space

Once you’ve all the physical volumes that make up the LVM group, do

pvcreate /dev/nvme0n1p6
vgcreate lvmg1 /dev/nvme0n1p6
lvcreate -L 40G -n root lvmg1
lvcreate -l 100%FREE -n home lvmg1

Later on, pacstrap would automatically add the root= kernal parameter to map the root partition to the right logical volume. This can be verified at /boot/grub/grub.cfg

linux /vmlinuz-linux root=/dev/mapper/lvmg1-root rw quiet

Format

Once partitioned, make sure to format each of them. For swap

mkswap /dev/sda6
swapon /dev/sda6

Likewise for ext4 do

mkfs.ext4 /dev/lvmg1/root

Mount

mount /dev/lvmg1/root /mnt
mkdir /mnt/boot
mount /dev/nvme0n1p5 /mnt/boot
mkdir /mnt/home
mount /dev/lvmg1/home /mnt/home
mkdir /mnt/var
mount /dev/sda5 /mnt/var

mkdir /mnt/boot/efi
mount /dev/nvme0n1p1 /mnt/boot/efi

genfstab is a Arch script that setups up /etc/fstab as per the current mounted file systems and swap space. Since we’re on a UEFI + GPT boot scheme, mount the EFI partition too for genfstab and GRUB2 (os-prober) to pick up Windows. This is the same partition as used by Windows for booting, mounted as /mnt/boot/efi. Same goes for other Windows partitions that needs to be listed in fstab for auto-mounting in the new OS. Otherwise it has to be done manually with Emacs and lsblk -f or blkid.

Reserved Space

I came to know that on ext4 Linux silently reserves 5% of system partitions for the root user; to be able to log in, if a regular user fills up the drive. See the reservation thus

> tune2fs -l /dev/sda5 | egrep "Reserved block count|Block size" | paste -sd\ | awk '{print ($4 * $7 / ( 1024 * 1024 ) ), "MiB"}'
204.797 MiB

You can change this with tune2fs -m <percentage> <device>; mine’s too petty to change.

Base Install

Before proceeding, it might be a good idea to fix the order of mirrors in /etc/pacman.d/mirrorlist since it’s copied to the installed system as-is. Instead of doing this manually, you might prefer using reflector; it retrieves latest mirror list based on country:

pacman -S --needed reflector
reflector --verbose --country IN -l10 --sort rate --save /etc/pacman.d/mirrorlist

Once satisfied with mirrorlist, proceed with the base installation:

pacstrap /mnt base

System Config

fstab

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

Usually /var is given additional options nodev,nosuid,noexec; while /home is marked with nodev for tighter security.

Check /mnt/etc/fstab, the table of filesystems and their mount points, the system refers for auto-mounting at every boot.

Change root

arch-chroot /mnt

Make sure to install packages that would be needed for network access in the installed system now; specifically wpa_supplicant since the new system wouldn’t have network access and will not contain this package either. This is a dependency for netctl.

Time

Once done, know your time zone using tzselect and do

ln -sf /usr/share/zoneinfo/Asia/Kolkata /etc/localtime
hwclock --systohc

Locale

nano /etc/locale.gen
locale-gen
localectl set-locale LANG=en_IN.UTF-8

The last line sets LANG.

Network

Set /etc/hostname and /etc/hosts for easy network identification. Ping and check if the network configuration works fine.

Update initramfs

Since we’ve used lvm2 for / itself, it has to be added to the HOOKS section of mkinitcpio.conf:

# /etc/mkinitcpio.conf
HOOKS="(base udev ... block lvm2 filesystems...)"

Regenerate initramfs image

mkinitcpio -p linux

Root Password

Use passwd to set root’s password.

Boot

Since Windows 8, Microsoft forces the UEFI + GPT combo, make sure this is followed by Arch for a successful coexistence with Windows. Pre-installed Windows machines have a EFI partition already made from which Windows boots; verify this using fdisk. This means we don’t have to create an EFI partition but simply mount it for GRUB to use. We’re using GRUB as the bootloader. The mounting part should’ve already been done as part of §3.5 Mount:

pacman -S --needed grub efibootmgr
mkdir /boot/efi
mount /dev/nvme0n1p1 /boot/efi
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
nano /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg

The suggested os-prober package, which makes GRUB look for other OSs, didn’t find Windows. Apparently, the EFI partition should be mounted to /mnt/boot before pacstrapping as this is where the kernel and bootloader are installed to. If you get lvmetad errors, you may safely ignore them. Probing should work inside the new Arch.

Reboot

umount -R /mnt
exit
umount -R /mnt
reboot

Secure boot doesn’t work since it needs a signed boot loader; see the forums for details. A few other errors

mmc0: Unknown controller version (3). You may experience problems.
mmc0: SDHCI controller on PCI [0000:03:00.0] using ADMA

However, this is a false alarm, and SD cards should read fine.

kvm disabled by bios

Intel’s virtualization hardware (VT-x) is disabled in BIOS and hence this error.

Failed unmounting /var

This also seems to be a non-issue.

Processor Microcodes

Processor security patches are released by CPU manufacturers, to be released as motherboard firmware updates; these come in slowly (or don’t 😉). Linux solves this by loading the microcode update as early as possible during boot.

Check boot log (journalctl -b0) for CPU bugs messages

MDS CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/mds.html for more d>
MMIO Stale Data CPU bug present and SMT on, data leak possible. See https://www.kernel.org/doc/html/latest/admin-guide/hw-vuln/process>

Refer Microcode - ArchWiki to check if your processor has patches and perform necessary steps to install and load at boot.

pacman -S --needed intel-ucode
grub-mkconfig -o /boot/grub/grub.cfg

Hibernation

Hibernation needs a resume parameter in kernel with the disk to retrieve data from. Check swap partition UUID:

swaplabel /dev/sda6

Edit /etc/default/grub and append the parameter

GRUB_CMDLINE_LINUX_DEFAULT="... resume=UUID=YOUR-SWAP-PARTITION-UUID"

You also need the resume hook (a script run on the initial ramdisk) in /etc/mkinitcpio.conf; ensure it’s added after udev and lvm2; I added it almost the last:

HOOKS=(base udev .. lvm2 .. resume fsck)

Generate the ramdisk image and GRUB’s configuration file:

mkinitcpio -P

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

Hibernate (from Xfce4 panel’s Action Button) and resume should work now. I’d like systemctl’s suspend-then-hibernate but Xfce4 Power Manager inhibits systemd’s ACPI settings. I’ll live with this for now than fiddle more 😅

Up next…

This completes my Arch Linux installation process. The newly installed Arch now has be configured and maintained 😊. The Arch Linux Configuration article covers

  • Xfce4 desktop environment
  • Dual GPU set up
  • Enlisting Windows in boot menu
  • Auto mounting USB sticks
  • Pulseaudio
  • Bluetooth
  • Laptop Mode Tools

and more.