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
- Secure boot off: at least for (USB) installation. Longer term, there’re some hoops to jump through but you can enable it back on
- SSD vs non-SSD: Use spinning disks for volatile data
- SATA vs RAID: To even detect your M.2 PCIe SSD the storage controller is to be set to ACHI and not Intel RST
- 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:
- If
ping
fails, disable dhcpcd service withsystemctl stop dhcpcd@
(press TAB) - 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
- If absent,
- 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
- Configure wireless using
iwctl
device list
(check station name which is usuallywlan0
)station wlan0 connect SSID
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)
/boot
→/dev/nvme0n1p5
(512 MiB)- LVM →
/dev/nvme0n1p6
(54.5 GiB)/
→/dev/lvmg1/root
(40 GiB)/home
→/dev/lvmg1/home
(remaining)
/var
→dev/sda5
(4 GiB)- 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
mount -m /dev/nvme0n1p5 /mnt/boot
mount -m /dev/nvme0n1p1 /mnt/boot/efi
mount -m /dev/lvmg1/home /mnt/home
mount -m /dev/sda5 /mnt/var
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 check /etc/pacman.d/mirrorlist
; for me, it was already setup with the optimal mirror by a background systemd unit once network was up :) Check it’s mtime and contents. If needed, update 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
Proceed with the base installation:
pacstrap -K /mnt base base-devel linux linux-firmware linux-headers acpi lvm2 grub efibootmgr os-prober iwd sudo exfatprogs intel-ucode smartmontools lshw inxi strace rsync wget mc nano emacs rg fd fzf bfs 7zip pv git links tree
It’s important to include packages needed for the booted system to be self-sufficient. For instance, missing out wireless networking package will leave you with no internet connectivity! I usually go for a well-rounded commandline system.
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
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
The last line sets LANG
.
Network
Set /etc/hostname
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
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 an amicable 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:
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB
nano /etc/default/grub
grub-mkconfig -o /boot/grub/grub.cfg
Reboot
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. Xfce 4.20+ Power Manager supports Hybrid Sleep and rightly inhibits systemd’s ACPI settings 😁.
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.