Arch Linux install on XP3 13 9300 (Dual boot with Windows 10)

 In this article I will detail the steps I followed to install Arch Linux in my XPS 13 9300. It came with windows 10 preinstalled. 



My main references during the process was,


Prerequisites

The first step is to change the SATA mode from "RAID" to "AHCI". Without doing this the linux installation can't identify the nvme drive on the laptop. This involves going through a few steps. 
  • Boot into windows and run the following commands
    • Open a command promt with admin rights
    • bcdedit /set {current} safeboot minimal
    • Restart into bios and change the SATA mode to AHCI
    • Boot back to windows and open an admin command prompt
    • bcdedit /deletevalue {current} safeboot
    • When I run bcdedit /enum it doesn't show "safeboot" any more. 


Next I disabled fast startup on windows. I'm doing this as I may choose to mount windows partitions when I'm on linux, and fast startup setting is known to cause issues. I only use windows to play games which I rarely do these days. So windows taking a few more seconds to load is not of a concern to me. So I disabled fast startup via "Power and sleep settings" -> "Additional power settings"

Installation media

Next I prepared an Arch installation media. I did this on my old laptop which was running Ubuntu. I used Etcher to write the downloaded iso to a USB. I also used the following commands to verify the integrity of the downloaded iso file. 
  • sha1sum archlinux-2020.08.01-x86_64.iso 
  • md5sum archlinux-2020.08.01-x86_64.iso 

Partitioning

After that I booted into the Arch install usb media. At this point I have a custom windows installation with an already shrinked C drive. If not I would have booted into an Ubuntu installation media and used "gparted" to resize the partitions. 

I used lsblk command to identify my current partition structure. 
   

The "nvme0n1p5" is the windows recovery partition and "nvme0n1p6" is my windows data partition. I'm going to delete both these partitions to gain space for the Arch installation. This is done with fdisk

  • fdisk nvme0n1 - This took me into the fdisk mode for the nvme drive
  • d and press "Enter" to accept to delete the last partition
  • d and press "Enter" again to delete one more partition from the bottom
  • n and press "Enter" to create a new partition
  • "+512M" to specify the new partition size. I'm going to use this as my efi boot partition
  • t to change partition type
  • 1 to choose "EFI" as the partition type
  • n again to create the Arch installation partition
  • "+50G" to specify size
  • n again to create the home partition followed by two "Enter" keys to accept the remaining space for the home partition
  • p to view what will be created followed by w to write the changes to disk
Now when I use lsblk it shows the newly changed partition structure. 


Now that I have the partition structure next step was to format them. The UFI boot partition needs to be fat32 and for the rest I used ext4
  • mkfs.fat -F32 /dev/nvme0n1p5
  • mkfs.ext4 /dev/nvme0n1p6
  • mkfs.ext4 /dev/nvme0n1p7
Then I continued to mount the partitions. The main Arch installation partition is mounted to /mnt. Boot and home partitions are mounted to /mnt/boot and /mnt/home respectively
  • mount /dev/nvme0n1p6 /mnt
  • mkdir /mnt/home
  • mount /dev/nvme0n1p7 /mnt/home
  • mkdir /mnt/boot
  • mount /dev/nvme0n1p5 /mnt/boot
Then I created the fstab file. This is needed to mount these during boot. the -U flag was used to identify the partitions using UUID instead of labels etc. 
  • mkdir mnt/etc/
  • genfstab -U /mnt >> /mnt/etc/fstab

Instalation

I have everything ready to start the installation. First step is to establish an internet connection. Arch installation media  comes with the iNet wireless daemon. I used it to establish a wifi connection. 
  • iwctl
  • station wlan0 connect [SSID]
Then I used pacstrap to install the essentials to the previously created new linux root /mnt
  • pacstrap /mnt base linux linux-firmware linux-headers linux-lts linux-lts-headers
The latest rolling and the long term kernels were installed using the above command. The header files were installed to support additional module builds in the future. I plan to use the latest rolling kernel for the most part but the LTS kernel may come in handy to recover from kernel panics. Now is the time to switch to the newly installed linux instalation from the usb.
  • arch-chroot /mnt
First things first. Install my favorite editors
  • pacman -Sy vim nano
Next is the boring task of configuration. I followed the Arch wiki for this. 
  • Set timezone
    • ln -sf /usr/share/zoneinfo/America/Los_Angeles /etc/localtime
    • hwclock --systohc
  • Local config
    • vim /etc/locale.gen
    • Uncomment en_US.UTF-8 UTF-8
    • locale-gen
    • vim /etc.locale-conf
    • Enter LANG=en_US.UTF-8
  • Network config
    • vim /etc/hostname
    • Enter name
    • vim /etc/hosts
    • Enter
      • 127.0.0.1 localhost
      • ::1 localhost
      • 127.0.1.1 [name].localdomain [name]

Create users and set passwords

I used passwd command to set the root password then created an everyday user for myself and set a new password to that user
  • useradd -g users -G power,storage,wheel -m [name]
  • passwd [name]

Bootloader

Next I setup grub as the boot-loader. This is the time to get the dual boot with windows setup. 
  • Install intel processor microcode
    • pacman -S intel-ucode
  • Install grub and util packages
    • pacman -S grub efibootmgr mtools
  • Install os-prober and identify Windows
    • pacman -S os-prober
    • os-prober
  • Install grub
    • grub-install --target=x86_64-efi --efi-directory=/boot/ --bootloader-id=GRUB
  • Mount the windows efi boot partition to a temporary location
    • mkdir /mntwin
    • mount /dev/nvme0n1p2 /mntwin
    • grub-mkconfig -o /boot/grub/grub.cfg
The output confirms that the windows installation was identified. 

Setup continues...

  • Install network tools and enable network related systemd services
    • pacman -S base-devel networkmanager dialog
    • systemctl enable NetworkManager
    • systemctl enable systemd-networkd.service
    • systemctl enable systemd-resolved.service
  • Create initial ramdisk for the kernels
    • mkinitcpio -p linux
    • mkinitcpio -p linux-lts
  • Install and configure sudo
    • Install sudo and configure so that any user in the wheel group can elevate themselves after confirming the password
    • pacman -S sudo
    • visudo
    • Uncomment and change wheel access line to %wheel ALL=(ALL) ALL
  • Create swap file
    • dd if=/dev/zero of=/swapfile bs=1M count=8192 status=progress
    • chmod 600 /swapfile
    • mkswap /swapfile
    • echo '/swapfile none swap 0 0' | tee -a /etc/fstab
  • Reboot into the new system
    • exit
    • umount -a
    • reboot

Gnome Install

Amazeballs! Now that I have a working arch system I'm gonna install my favorite desktop environment. First I need to connect and setup wifi
  • nmcli device wifi connect GasGembi password [password]
Then install Gnome
  • pacman -S xorg-server
  • sudo pacman -S gnome gnome-extra
  • sudo systemctl enable gdm
After rebooting I was greeted with the Gnome login screen. :)

One last thing. Setting up bluetooth
  • lsmod | grep btusb
  • sudo pacman -S bluez bluez-utils
  • systemctl enable bluetooth.service
The XPS 13 9300 also comes with a fingerprint sensor and windows hello capabilities. I will address the linux setup for these in a future post. 









Comments

Popular posts from this blog

Setting up KDiff3 to work with TortoiseGIT

Nextcloud and PHP8

Nextcloud on Arch Linux (Encrypted System) [Part 01 - Preparation]