Context

HP Zbook workstations are one of my favorites battle ready laptops out there (besides Dell XPS developer edition). I’m yet to put my hands on a future ready ultrabook like the SLIMBOOKs. Now, if I want to tackle some serious business with this beast (like ricing i3, edit YAML files or develop some funny golang pointless app) I will need to install my favorite OS of all time!

The situation at hand is:

  • I just got an HP Zbook Power G8 workstation laptop.
  • It has Windows 10 preinstalled.
  • I want to keep the Windows installation, meaning, I need a dualboot setup.

The main issue of having Windows 10 preinstalled in the machine is that, by default, Windows installer creates an absurdly small EFI partition of 100MB. This partition holds the different OS bootloaders while booting in UEFI mode. Of course, you can try, but most probably you will fail while setting up a dualboot when executing the mkinitcpio script used to create the initial ramdisk to the EFI (/boot) partition because it has not enough space left to store the files.

Extend EFI partition

In my case, I had no other choice than extending the EFI partition. And, yet another issue we find in our way! GParted (which uses libparted) is not able to resize FAT32 (format of EFI) partitions that are less than 256MB in size. As suggested in the bug comments, I followed these steps:

  1. Backup the data in the FAT16/FAT32 partition; you can use a USB stick and a live Arch ISO, and execute, for example:
λ mount /dev/sdx1 /mnt # Mount your EFI partition, replace sdx1 with ESP/EFI partition
λ mkdir usb
λ mount /dev/sdx1 usb  # Mount your USB stick (you might need flags like -t exfat for mounting)
λ rsync -av /mnt/ usb/ # Copy EFI partition files to the USB
λ ls usb/              # Check USB contents
λ umount /mnt          # Umount the EFI partition
  1. Reformat the partition to EXT4; for this, you can use GParted live or gdisk commands.
  2. Resize EXT4 partition to desired partition size; again, you can use GParted for this.
  3. Reformat the partition back to FAT16/FAT32; important bit here is to set the partition type (flags) accordingly (boot and esp)
  4. Restore the FAT16/FAT32 files from backup:
λ mount /dev/sdx1 /mnt # Mount your EFI partition, replace sdx1 with ESP/EFI partition
λ mkdir usb
λ mount /dev/sdx1 usb  # Mount your USB stick (you might need flags like -t exfat for mounting)
λ rsync -av /mnt/ usb/ # Copy EFI partition files to the USB
λ ls usb/              # Check USB contents
λ umount /mnt          # Umount the EFI partition

In my case, after doing a backup of the EFI partition files with Arch Linux Live installation media to a USB, I booted into GParted live and performed the following actions (using the GUI):

  1. Resized Windows main partition (half disk)
  2. Moved Windows main partition to the right by 2GB (this takes about 10 minutes to complete)
  3. Formatted EFI partition to ext4
  4. Extended EFI partition 2GB to the right (the free space made available by moving Windows main partition to the right)
  5. Formatted EFI partition back to FAT32 and set boot and esp flags to the partition.

Finally, I booted Arch Linux live installation media and restored EFI/ESP backup files to the new resized EFI partition. Afterwards, I proceeded to install Arch Linux.

Arch Linux Installation

Basically I followed the Arch Linux installation guide.

Boot Loader

In terms of boot manager, I chose GRUB (the one I’m most familiar with) and followed these steps to also detect the Windows installation:

λ pacman -S grub efibootmgr os-prober
λ grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=GRUB
λ os-prober # To check that Windows was in fact detected
λ vim /boot/grub/grub.cfg # Edit GRUB config 
# Uncomment GRUB_DISABLE_OS_PROBER=false so grub adds an entry for Windows installation
λ grub-mkconfig -o /boot/grub/grub.cfg

At this point, I was able to boot into the new Archlinux installation and perform post-installation activities.

Enabling AUR

This is a standard step I always run to be able to access the AUR (Arch User Repository)

λ sudo git clone https://aur.archlinux.org/yay.git
λ cd yay/
λ sudo makepkg -si
λ yay -Syu

Graphics Driver

This topic is also somehow special for this machine. The specifications for HP Zbook Power G8 shows that it has two GPUs, Intel graphics (integrated) and NVIDIA GPU (dedicated). NVIDIA Optimus allows these beast laptops that have dedicated GPUs to access both graphic cards depending on the task being run. Unfortunately, there is no support for this technology in Linux out of the box, and there are different options available (can be checked in the Arch Linux wiki). I chose to have access to both integrated & dedicated graphics and I installed Optimus Manager (available in the AUR) which is a program aimed to provide an easy way to switch GPU modes.

λ sudo pacman -S nvidia
λ sudo pacman -S xorg xorg-apps
λ yay -S optimus-manager optimus-manager-qt
# Reboot
λ optimus-manager --switch nvidia 
λ  optimus-manager --status
Optimus Manager (Client) version 1.4

Current GPU mode : nvidia
GPU mode requested for next login : no change
GPU at startup : auto
Temporary config path: no

I configured optimus (with the help of optimus-manager-qt) so when the laptop is started with battery it will use integrated graphis and the other way arround:

λ  cat /etc/optimus-manager/optimus-manager.conf
[amd]
DRI=3
driver=modesetting
tearfree=

[intel]
DRI=3
accel=
driver=modesetting
modeset=yes
tearfree=

[nvidia]
DPI=96
PAT=yes
allow_external_gpus=no
dynamic_power_management=no
ignore_abi=no
modeset=yes
options=overclocking

[optimus]
auto_logout=yes
pci_power_control=yes
pci_remove=no
pci_reset=hot_reset
startup_auto_battery_mode=integrated
startup_auto_extpower_mode=nvidia
startup_mode=auto
switching=none

At the time of this installation, nvidia may not boot on Linux 5.18 (or later) on systems with Intel CPUs. When changing to hybrid or nvidia graphics mode with envycontrol you may find a blank screen. To solve it, you can boot a live CD installation and chroot into it to execute envycontrol and change back to the integrated graphics mode.

Checking the logs from previous boot you will find something like:

λ  journalctl -b-3
...
traps: Missing ENDBR: _nv011889rm+0x0/0x10 [nvidia]
kernel: ------------[ cut here ]------------
kernel: kernel BUG at arch/x86/kernel/traps.c:253!
systemd[1]: Failed to start Load Kernel Modules.
...

Until this is fixed, a workaround is disabling the Indirect Branch Tracking CPU security feature by setting the ibt=off kernel parameter:

λ  vim /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet ibt=off"

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

An issue I faced during a system package upgrade is that I stumbled on a black screen and I were only able to login to a tty. This was caused by an upgrade to optimus-manager package that broke it (I checked by running optimus-manager --status on the tty session after login). The solution was as easy as reinstalling optimus-manager with clean build options through yay.

Customizations & Tweaks

This is more of a personal taste and involves my usual setup of basic tools (window manager, sound control, etc)

Window Manager vs. Desktop Environment

Ever since I tried a Window Manager (i3), I have not been able to go back to a proper DE (I’ve used GNOME, Cinammon and, lately, KDE Plasma). Whenever I try a DE, I feel really slow using the machine. For that reason, I find myself really comfortable using i3 WM and the usual tools that are installed with it.

λ sudo pacman -S i3

Login

I also installed ligthdm to perform the login (autologin)

# /etc/lightdm/lightdm.conf
[Seat:*]
autologin-user=username
λ groupadd -r autologin
λ gpasswd -a username autologin

Sound

The only issue I found after completing the installation was that no sound card was detected by issuing

λ cat /proc/asound/cards

Installing the Sound Open Firmware solved the issue:

λ sudo pacman -S sof-firmware
λ cat /proc/asound/cards

0 [sofhdadsp]: sof-hda-dsp - sof-hda-dsp
        HP-HPZBookPower15.6inchG8MobileWorkstationPC

I also installed pulseadio and pa-applet to be able to control the volume of the default device. Also, so that function keys work, dunst, a lightweight replacement for the notification-daemons provided by most desktop environments, is required:

λ sudo pacman -S pulseaudio dunst
λ yay -S pa-applet-git

Brightness

For controlling the display brightness, I installed brightnessctl:

λ sudo pacman -S brightnessctl
λ brightnessctl set 50%

You can then add keybindings to your i3 config file:

bindsym XF86MonBrightnessDown exec "brightnessctl set 10%-; notify-send 'brightness down'"
bindsym XF86MonBrightnessUp exec "brightnessctl set +10%; notify-send 'brightness up'"

[BONUS] Root partition encryption

This is something I always do on laptop installations that are subject to be stolen or lost in the wild. I usually do it at installation time, though sometimes I forget and I’m forced to do it afterwards using this article from our beloved Arch Wiki. I followed these steps:

  1. Perform a backup using your favorite method, I used rsync:
λ rsync -aAXHv --exclude={"/dev/*","/proc/*","/sys/*","/tmp/*","/run/*","/mnt/*","/media/*","/lost+found"} / /path/to/backup
  1. Then, boot a live Arch iso and make room for the encryption (LUKS) headers; I resized the root filesystem by 1GB, more than enough (about 16Mb) required
λ resize2fs /dev/sdXY 399G #(400 - 1)
  1. Encrypt the root partition:
λ cryptsetup root --encrypt /dev/sdXY --reduce-device-size 16M
  1. We open the just created encrypted volume:
λ cryptsetup open /dev/sdXY root
  1. Resize the filesystem again to expand to all the partition size:
λ resize2fs /dev/mapper/root 
  1. Then, without leaving the Archlinux live ISO, we mount the root partition unencrypted volume and the existing /boot partition:
λ mount /dev/mapper/root /mnt
λ mount /dev/sdaX /mnt/boot
  1. Now, we chroot into the installation:
λ arch-chroot /mnt
  1. While chrooted, perform the following actions:
  • Check the root PARTITION UUID:
λ blkid

[sudo] password for user:
/dev/sda1: UUID="this-is-the-UIID-to-keep" TYPE="crypto_LUKS" PARTUUID="xxxxxxx"
/dev/sda2: TYPE="BitLocker" PARTLABEL="Data partition" PARTUUID="xxxxxxxxx"
/dev/sda3: UUID="xxx" TYPE="vfat" PARTLABEL="EFI partition" PARTUUID="xxx"
/dev/sda4: BLOCK_SIZE="512" UUID="xXX" TYPE="ntfs" PARTUUID="xxxx"
/dev/sda5: PARTLABEL="Microsoft reserved partition" PARTUUID="xxxx"
/dev/mapper/root: UUID="xxxx" BLOCK_SIZE="4096" TYPE="ext4"
  • Update /etc/fstab root partition with the new UUID:
# Static information about the filesystems.
# See fstab(5) for details.


# /dev/nvme0n1p1
UUID=xxxxxxxxxxxxxxxxx     	/boot     	vfat      	rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=ascii,shortname=mixed,utf8,errors=remount-ro0 2

# /dev/mapper/root
UUID=this-is-the-UIID-to-keep  /         	ext4      	rw,relatime	0 1
  • Update mkinitcpio hooks so you can enter the partition password after boot:
λ sudo vim /etc/mkinitcpio.conf # Edit below line

HOOKS=(base udev autodetect modconf block filesystems keyboard consolefont fsck encrypt)

λ mkinitcpio -P 
  • Finally, move your GRUB themes to an available location during boot (outside /root partition) and edit GRUB configuration /etc/default/grub:
λ  mkdir -p /boot/themes
λ  cp -r /usr/share/grub/themes/Stylish/ /boot/themes

λ  vim /etc/default/grub
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet cryptdevice=UUID=this-is-the-UIID-to-keep:root root=/dev/mapper/root"
GRUB_ENABLE_CRYPTODISK=y
GRUB_THEME="/boot/themes/Stylish/theme.txt"

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

TRIM Support If you wish to be able to TRIM your device, change GRUB_CMDLINE_LINUX_DEFAULT to:

GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 quiet cryptdevice=UUID=f435a66e-28c4-4b78-9ebe-bf87614a6fee:root:allow-discards root=/dev/mapper/root rd.luks.options=discard

And enable fstrim timer:

λ sudo systemctl enable fstrim.timer
λ sudo systemctl start fstrim.timer
  1. That’s it, exit the chroot environment, umount everything and reboot:
λ exit
λ umount /mnt
λ cryptsetup close /dev/mapper/root
λ reboot