I've installed GNU/Linux on a brand new laptop few months ago. It was not a nightmare, but it wasn't funny either. Installing an OS became one of those things, I was doing finger in the nose. But this time, all my knowledge on BIOS, MBR, fdisk, partitions, Grub, boot process, etc, ..., all my knowledge was useless. All this knowledge is now obsolete, or at least should be updated.

So, this article is a little compilation, of all the things I've (re)learned, installing and using Void Linux on a brand new Dell XPS 13.


The Grub's prompt

After my first, and obviously failed, install, I was not able to go further than the Grub command line. The Grub command line gives you complete access to all filesystems on the local machine. The shape of the prompt will give informations that may save us some time:

  • grub> Grub started normally, but it didn't find your grub.cfg file.
  • grub rescue> grub folder not found or its contents are missing/corrupted.
  • GRUB Grub can't find the MBR (or equivalent) information.

From this point, let's see how to boot our OS.



How do I list available partitions?

A good way to find out the available partitions, is to use the ls command. In fact, by ls-ing everything around, we'll be able to find where is the OS installed:

available partitions

All the modern kernels see drives, or not, as sdx, the x representing the drive number. Normally, sda1, sda2, sda3, sda5, would be Linux partitions for the the first drive, which is sda.

However, we need to keep in mind that Grub does not use normal linux hard drive identifiers. In our case (hd0, gpt5), hd0 means the first hard drive, gpt5 means the 5th GPT partition.



How do I boot?

Now that we know our OS is in the 5th partition. Booting is as simple as:

  • set the root partition
grub> set root=(hd0, gpt5)
  • load vmlinuz, the Linux kernel executable
grub> linux /boot/vmlinuz-4.10.0-32-generic root=/dev/nvme0n1p5
  • load a temporary root file system into memory
grub> initrd /boot/initrd.img-4.10.0-32-generic
  • launch the boot sequence
grub> boot

boot



How do I launch the Grub and show the menu entries?

You may have noticed, I've done a cat /etc/fstab for being able to find the kernel name of the / partition: /dev/nmve0n1p50 and pass it to the linux command. Typing all this commands is a little bit boring, and we can easily make a mistake. If we have a working Grub config somewhere, which is our case, it simpler to just call it, and from there, boot your OS.

grub> configfile (boot device)/path/to/grub.cfg

grub menu entries



How to correctly install Grub?

I failed my first, and many of the following installs because I've done what I'm used to: install Grub in the first sector of the hard disk.

The UEFI can function as bootloader, allowing systems to boot without the need for any other bootloader. UEFI will load files stored on the Extensible Firmware Interface System Partition, or EFI System Partition, or ESP. This partition will contain the EFI application .efi, that will be executed by UEFI to launch our Grub.

So yes, we'll need at least:

  • an ESP, FAT32 formatted, that will contain the .efi file. Here, nvme0n1p7.
  • another partition, XFS formatted, that will contain our Grub. Here, nvme0n1p8.

grub-install

When calling the command:

 # grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=void_grub --boot-directory=/boot --recheck --debug

We're basically asking grub-install to:

  • install all the Grub files in the /boot directory.
  • generate an .efi file and store it in the /boot/efi directory.

grub-install

The .efi file can be analysed using ghex editor.

For the most courageous. Instead of installing Grub. Instead of asking to UEFI to launch your Grub, then asking Grub to launch your OS, UEFI can directly boot your OS using what's called efi-stub. Sounds amazing.

After a successful Grub install, you need to go inside UEFI and configure the correct path to your .efi file.

grub-install



A gpt partition?

If using UEFI, all your disk should be partionned following the GPT standard. GPT: Glogally Unique IDentifier Partition Table, or GUID Partition Table or GPT. TL;DR, you can now have:

  • up to 128 primary partitions per disk
  • maximum size of 8 ZiB per disk or partitions
  • modern logical block addressing (LBA) in place of the cylinder-head-sector (CHS)
  • a backup of the partition table, kept at the end of the disk.
  • partitions with a randomly generated, 36-character Unicode unique* name

For those who want to check what standard they're using, gdisk to the rescue:

 $ sudo gdisk -l /dev/sda
GPT fdisk (gdisk) version 1.0.1

Partition table scan:
  MBR: MBR only
  BSD: not present
  APM: not present
  GPT: not present


***************************************************************
Found invalid GPT and valid MBR; converting MBR to GPT format
in memory.
***************************************************************

Disk /dev/sda: 976773168 sectors, 465.8 GiB
Logical sector size: 512 bytes
Disk identifier (GUID): 5D57E148-29BA-4924-A955-C9D684DAEF25
Partition table holds up to 128 entries
First usable sector is 34, last usable sector is 976773134
Partitions will be aligned on 2048-sector boundaries
Total free space is 237459439 sectors (113.2 GiB)

Number  Start (sector)    End (sector)  Size       Code  Name
   1            2048        97851391   46.7 GiB    8300  Linux filesystem
   3       613490688       739319807   60.0 GiB    8300  Linux filesystem
   4        97851392        97853437   1023.0 KiB  8300  Linux filesystem
   5        97853440       488476671   186.3 GiB   8300  Linux filesystem
   6       488478720       496289791   3.7 GiB     8200  Linux swap
   7       496291840       613490687   55.9 GiB    8300  Linux filesystem

I'm obviously writing about the new school, using an old school computer.



Disk nmve9n1p50?

This is how to read it: 10th NVMe drive, 50th partition. It turns out, it's just the proper way for your kernel to talk about Solid State Drives. Said correctly, NVM Express (NVMe) is a specification for accessing SSDs attached through the PCI Express bus.



Naming network interface enp0s30f5?

This is how to read it: Ethernet, PCI port 0, slot 0x30F5. Strange right? The truth is, the ethX naming scheme works fine as long as the system has only one Ethernet port. However, if we have two Ethernet devices, eth0 and eth1, after the next system boot, it cannot be ensured that eth0 will remain as eth0 and eth1 will remain as eth1. Names are allocated arbitrarily. The new naming scheme keeps your hardware chain from randomly assigning names to different cards at boot.



Connectivity?

After a succesful install, the only network interface available for me was the wlan, PCI port 58, slot 0x0 or wlp58s0. Not being able to plug in an ethernet cable was a really strange feeling. Anyway, wpa_supplicant to the rescue, assuming it is already installed:

# wpa_supplicant -i wlp58s0 -c /path/to/wpa_supplicant/config/file

wpa_supplicant

Where the configuration file is something like:

wpa_supplicant



I've just described here how to get out of some troubles. If you find something wrong in this post, please let me know. Finally, I strongly recommend the following links: