From 7939805687e75f8a46cd6c43a80e9fb3db88da81 Mon Sep 17 00:00:00 2001 From: "David T. Sadler" Date: Mon, 7 Mar 2022 21:18:44 +0000 Subject: Add Installing Docker on Arch Linux --- .../index.html | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) (limited to 'www/posts/arch/2020-05-25/installing-arch-linux-on-a-thinkpad-x220/index.html') diff --git a/www/posts/arch/2020-05-25/installing-arch-linux-on-a-thinkpad-x220/index.html b/www/posts/arch/2020-05-25/installing-arch-linux-on-a-thinkpad-x220/index.html index d0ee2b3..2139e52 100644 --- a/www/posts/arch/2020-05-25/installing-arch-linux-on-a-thinkpad-x220/index.html +++ b/www/posts/arch/2020-05-25/installing-arch-linux-on-a-thinkpad-x220/index.html @@ -18,7 +18,7 @@ -

Installing Arch Linux on a Thinkpad X220

Mon 25th May 2020 By David T. Sadler.

Introduction

So I purchased a used Thinkpad X220 for about £90 on eBay and decided to install Arch Linux onto it. This guide is the steps that I took to achieve this.

Now when it comes to Linux there is always more than one way of doing things and this guide is just my preferred way. Feel free to follow it for your own installation, just keep in mind that you may have to change some of the steps to suit your own circumstances. Also there is every chance that the information presented here will be out of date so I recommend that you at least read the through the official installation guide for the most up-to-date information.

Download the Arch Linux ISO Image

The Arch Linux download page provides direct download and torrent links. You should also download the PGP signature to the same location and use the gpg command to verify that the ISO has not been compromised.

$ gpg --keyserver-options auto-key-retrieve --verify archlinux-2020.05.01-x86_64.iso.sig

Create a Live USB of Arch Linux

Flash the image to a USB drive using Etcher. Alternatively you can use the dd command. Just ensure that /path/to/archlinux.iso is to where you have downloaded the image and that /dev/sdx is your USB drive.

dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync

Boot the Live Environment

I wanted to make sure that the Thinkpad was using UEFI as I would be using EFISTUB to load the Linux kernel as an EFI executable. This is done through the BIOS which can be gotten to by pressing the ThinkVantage button as the machine is booting before pressing F1 to get to the BIOS settings. From there navigate to Startup and changed the UEFI/Legacy Boot option to be UEFI Only. Press F10 to save and exit the BIOS and then power down the machine.

With the USB drive plugged in power the machine back on, all the while pressing F12 until the boot menu appears and select USB HDD: Mass Storage Device and wait for the installation image to boot. When prompted select Arch Linux archiso X86_64 UEFI CD where you will be take to the live environment's terminal.

Set the Keyboard Layout

The default console map is US which meant that for me pressing Shift+3 was displaying the hash symbol (#) instead of the pound symbol (£). So the UK keyboard layout needed to be loaded.

$ loadkeys uk

You can get a list of supported keyboard layouts if you need to load a different one.

ls /usr/share/kbd/keymaps/**/*.map.gz

Verify the Boot Mode

To verify that the Thinkpad has UEFI enabled check that the efivars directory exists.

$ ls /sys/firmware/efi/efivars

Connect to the Internet

Verify that the machine can connect to the internet with the ping command.

$ ping -c3 davidtsadler.com

Before booting the machine I plugged in an Ethernet cable that was connected directly to my home network's router. The installation environment detected the network connection and obtained an IP address via DHCP.

Update the System Clock

Ensure the system clock is correct.

$ timedatectl set-ntp true

Partition the Disks

Use the lsblk command to determine which disks and partitions exist on the system.

$ lsblk
+        

Installing Arch Linux on a Thinkpad X220

Mon 25th May 2020 By David T. Sadler.

Introduction

So I purchased a used Thinkpad X220 for about £90 on eBay and decided to install Arch Linux onto it. This guide is the steps that I took to achieve this.

Now when it comes to Linux there is always more than one way of doing things and this guide is just my preferred way. Feel free to follow it for your own installation, just keep in mind that you may have to change some of the steps to suit your own circumstances. Also there is every chance that the information presented here will be out of date so I recommend that you at least read the through the official installation guide for the most up-to-date information.

Download the Arch Linux ISO Image

The Arch Linux download page provides direct download and torrent links. You should also download the PGP signature to the same location and use the gpg command to verify that the ISO has not been compromised.

$ gpg --keyserver-options auto-key-retrieve --verify archlinux-2020.05.01-x86_64.iso.sig

Create a Live USB of Arch Linux

Flash the image to a USB drive using Etcher. Alternatively you can use the dd command. Just ensure that /path/to/archlinux.iso is to where you have downloaded the image and that /dev/sdx is your USB drive.

dd bs=4M if=/path/to/archlinux.iso of=/dev/sdx status=progress && sync

Boot the Live Environment

I wanted to make sure that the Thinkpad was using UEFI as I would be using EFISTUB to load the Linux kernel as an EFI executable. This is done through the BIOS which can be gotten to by pressing the ThinkVantage button as the machine is booting before pressing F1 to get to the BIOS settings. From there navigate to Startup and changed the UEFI/Legacy Boot option to be UEFI Only. Press F10 to save and exit the BIOS and then power down the machine.

With the USB drive plugged in power the machine back on, all the while pressing F12 until the boot menu appears and select USB HDD: Mass Storage Device and wait for the installation image to boot. When prompted select Arch Linux archiso X86_64 UEFI CD where you will be take to the live environment's terminal.

Set the Keyboard Layout

The default console map is US which meant that for me pressing Shift+3 was displaying the hash symbol (#) instead of the pound symbol (£). So the UK keyboard layout needed to be loaded.

$ loadkeys uk

You can get a list of supported keyboard layouts if you need to load a different one.

ls /usr/share/kbd/keymaps/**/*.map.gz

Verify the Boot Mode

To verify that the Thinkpad has UEFI enabled check that the efivars directory exists.

$ ls /sys/firmware/efi/efivars

Connect to the Internet

Verify that the machine can connect to the internet with the ping command.

$ ping -c3 davidtsadler.com

Before booting the machine I plugged in an Ethernet cable that was connected directly to my home network's router. The installation environment detected the network connection and obtained an IP address via DHCP.

Update the System Clock

Ensure the system clock is correct.

$ timedatectl set-ntp true

Partition the Disks

Use the lsblk command to determine which disks and partitions exist on the system.

$ lsblk
 
 NAME   MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
 loop0    7:0    0   535M  1 loop /run/archiso/sfs/airootfs
@@ -43,15 +43,15 @@ Partition number (1-128, default 1): 1
 First sector (2048-625142414, default 2048): 
 Last sector, +/-sectors or +/-size{K,M,G,T,P} (2048-625142414, default 625142414): +512M
 
-Created a new partition 1 of type 'Linux filesystem' and of size 512 MiB.

Enter t to change the partition type and enter 1 to make it an EFI System. You can also get a list of partition types by pressing L.

Command (m for help): t
+Created a new partition 1 of type 'Linux filesystem' and of size 512 MiB.

Enter t to change the partition type and enter 1 to make it an EFI System. You can also get a list of partition types by pressing L.

Command (m for help): t
 Selected partition 1
 Partition type (type L to list all types): 1
-Changed type of partition 'Linux filesystem' to 'EFI System'.

To create the second partition enter n again to add another partition, and then enter 2 to assign it as the second partition. Use the default values for both first and last sectors to allocate the remainder of the drive.

Command (m for help): n
+Changed type of partition 'Linux filesystem' to 'EFI System'.

To create the second partition enter n again to add another partition, and then enter 2 to assign it as the second partition. Use the default values for both first and last sectors to allocate the remainder of the drive.

Command (m for help): n
 Partition number (2-128, default 2): 2
 First sector (1050624-625142414, default 1050624): 
 Last sector, +/-sectors or +/-size{K,M,G,T,P} (1050624-625142414, default 625142414): 
 
-Created a new partition 2 of type 'Linux filesystem' and of size 297.6 GiB.

Enter w to write the changes and quit.

Command (m for help): w
+Created a new partition 2 of type 'Linux filesystem' and of size 297.6 GiB.

Enter w to write the changes and quit.

Command (m for help): w
 The partition table has been altered.
 Calling ioctl() to re-read partition table.
 Syncing disks.

Use lsblk to confirm that two partitions have been created.

$ lsblk /dev/sda
@@ -63,7 +63,7 @@ sda      8:0    0 298.1G  0 disk
 ========
 This will overwrite data on /dev/sda2 irrevocably.
 
-Are you sure? (Type 'yes' in capital letters): YES

Enter and verify a passphrase. Whenever the machine is now booted you will be prompted to enter this passphrase in order for the partition to be decrypted.

Enter passphrase for /dev/sda2: 
+Are you sure? (Type 'yes' in capital letters): YES

Enter and verify a passphrase. Whenever the machine is now booted you will be prompted to enter this passphrase in order for the partition to be decrypted.

Enter passphrase for /dev/sda2: 
 Verify passphrase: 
 cryptsetup luksFormat /dev/sda2  17.01s user 1.05s system 105% cpu 17.106 total

LVM on LUKS

Before setting up LVM decrypt the partition.

$ cryptsetup open /dev/sda2 cryptlvm

You will be prompted to enter the passphrase that you set up earlier.

Enter passphrase for /dev/sda2: 
 cryptsetup open /dev/sda2 cryptlvm  6.48s user 0.36s system 92% cpu 7.436 total

Create a physical volume.

$ pvcreate /dev/mapper/cryptlvm

Create a volume group called vg0.

$ vgcreate vg0 /dev/mapper/cryptlvm

Create three logical volumes for the root, swap and home partitions.

$ lvcreate -L 50G vg0 -n root
@@ -81,7 +81,7 @@ sda              8:0    0 298.1G  0 disk
 $ mkfs.ext4 /dev/vg0/home

Initialise the swap partition.

$ mkswap /dev/vg0/swap
 $ swapon /dev/vg0/swap

Mount the File Systems

Mount the root partition into /mnt.

$ mount /dev/vg0/root /mnt

Mount the boot partition into /mnt/boot.

$ mkdir /mnt/boot
 $ mount /dev/sda1 /mnt/boot

Finally mount the home partition into /mnt/home.

$ mkdir /mnt/home
-$ mount /dev/vg0/home /mnt/home

Select the Mirrors

All mirror servers defined in /etc/pacman.d/mirrorlist where done at the time the installation image was built. Since it's ideal to try and use servers that are close to your location you can rebuild the list using the rankmirrors utility. This is not included by default on the live environment so you will need to download it.

First sync the pacman repository.

pacman -Syy

Then download the pacmain-contrib package which contains the rankmirrors utility.

$ pacman -S pacman-contrib

The official Pacman Mirrorlist Generator can be used to get an up-to-date list of servers for your country. The below command obtains a list of UK servers that support https and pass it to rankmirrors to obtain the 5 fastest.

$ curl -s "https://www.archlinux.org/mirrorlist/?country=GB&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 - > /etc/pacman.d/mirrorlist

Install Essential Packages

The pacstrap script is used to install the base package, Linux kernel and firmware.

$ pacstrap /mnt base linux linux-firmware neovim wpa_supplicant dhcpcd cryptsetup lvm2 efibootmgr intel-ucode

I also installed a few other packages that I knew I was going to need.

  • neovim. Allows you to edit files instead of using nano.
  • wpa_supplicant. Provides tools for connecting to a WPA2 protected wireless network.
  • dhcpcd. Needed so that you machine can obtain an IP address from your home router via dhcp.
  • cryptsetup. Since the partition is encrypted this package is required in order for it to be decrypted during booting.
  • lvm2. Provides the LVM tools to manage the LVM partition.
  • efibootmgr. Needed to configure the system to boot via UEFI.
  • intel-ucode. Enables microcode updates during boot.

Fstab

Create a fstab file on the new system.

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

Chroot

Use arch-chroot to enter the new system as the root user. From now on you will be configuring the new system.

$ arch-chroot /mnt

Time Zone

Setup the timezone. Replace Europe/London with your timezone.

$ ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

Update the hardware clock.

$ hwclock --systohc

Localization

Use nvim to edit /etc/locale.gen.

$ nvim /etc/locale.gen

Uncomment your preferred language. For me this meant en_GB.UTF-8 UTF-8. Save the file and exit before generating the locales.

$ locale-gen

Edit /etc/locale.conf.

$ nvim /etc/locale.conf

Add the below line. Replace en_GB.UTF-8 with the language that you chose earlier.

LANG=en_GB.UTF-8

If you used loadkeys earlier you will need to edit /etc/vconsole.conf and add your chosen keymap.

$ nvim /etc/vconsole.conf

For me this meant adding the UK keymap.

KEYMAP=uk

Network Configuration

Create the file /etc/hostname and add an entry to it. This hostname will be the name of the machine on your network. I tend to name by devices after characters from the book Howl's Moving Castle https://en.wikipedia.org/wiki/Howl%27s_Moving_Castle).

$ echo suliman > /etc/hostname

You then need to edit the /etc/hosts file.

$ nvim /etc/hosts

Add the following lines to this file. Replace suliman with the hostname you set up earlier.

127.0.0.1	localhost
+$ mount /dev/vg0/home /mnt/home

Select the Mirrors

All mirror servers defined in /etc/pacman.d/mirrorlist where done at the time the installation image was built. Since it's ideal to try and use servers that are close to your location you can rebuild the list using the rankmirrors utility. This is not included by default on the live environment so you will need to download it.

First sync the pacman repository.

pacman -Syy

Then download the pacmain-contrib package which contains the rankmirrors utility.

$ pacman -S pacman-contrib

The official Pacman Mirrorlist Generator can be used to get an up-to-date list of servers for your country. The below command obtains a list of UK servers that support https and pass it to rankmirrors to obtain the 5 fastest.

$ curl -s "https://www.archlinux.org/mirrorlist/?country=GB&protocol=https&use_mirror_status=on" | sed -e 's/^#Server/Server/' -e '/^#/d' | rankmirrors -n 5 - > /etc/pacman.d/mirrorlist

Install Essential Packages

The pacstrap script is used to install the base package, Linux kernel and firmware.

$ pacstrap /mnt base linux linux-firmware neovim wpa_supplicant dhcpcd cryptsetup lvm2 efibootmgr intel-ucode

I also installed a few other packages that I knew I was going to need.

  • neovim. Allows you to edit files instead of using nano.
  • wpa_supplicant. Provides tools for connecting to a WPA2 protected wireless network.
  • dhcpcd. Needed so that you machine can obtain an IP address from your home router via dhcp.
  • cryptsetup. Since the partition is encrypted this package is required in order for it to be decrypted during booting.
  • lvm2. Provides the LVM tools to manage the LVM partition.
  • efibootmgr. Needed to configure the system to boot via UEFI.
  • intel-ucode. Enables microcode updates during boot.

Fstab

Create a fstab file on the new system.

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

Chroot

Use arch-chroot to enter the new system as the root user. From now on you will be configuring the new system.

$ arch-chroot /mnt

Time Zone

Setup the timezone. Replace Europe/London with your timezone.

$ ln -sf /usr/share/zoneinfo/Europe/London /etc/localtime

Update the hardware clock.

$ hwclock --systohc

Localization

Use nvim to edit /etc/locale.gen.

$ nvim /etc/locale.gen

Uncomment your preferred language. For me this meant en_GB.UTF-8 UTF-8. Save the file and exit before generating the locales.

$ locale-gen

Edit /etc/locale.conf.

$ nvim /etc/locale.conf

Add the below line. Replace en_GB.UTF-8 with the language that you chose earlier.

LANG=en_GB.UTF-8

If you used loadkeys earlier you will need to edit /etc/vconsole.conf and add your chosen keymap.

$ nvim /etc/vconsole.conf

For me this meant adding the UK keymap.

KEYMAP=uk

Network Configuration

Create the file /etc/hostname and add an entry to it. This hostname will be the name of the machine on your network. I tend to name by devices after characters from the book Howl's Moving Castle https://en.wikipedia.org/wiki/Howl%27s_Moving_Castle).

$ echo suliman > /etc/hostname

You then need to edit the /etc/hosts file.

$ nvim /etc/hosts

Add the following lines to this file. Replace suliman with the hostname you set up earlier.

127.0.0.1	localhost
 ::1		    localhost
 127.0.0.1	suliman.localdomain suliman

Wireless

Use the ip command to determine the name of the wireless network interface.

$ip link
 
@@ -98,7 +98,7 @@ Load module index
 Parsed configuration file /usr/lib/systemd/network/99-default.link
 Parsed configuration file /usr/lib/systemd/network/80-iwd.link
 Created link configuration context.
-Using default interface naming scheme 'v245'.
+Using default interface naming scheme 'v245'.
 ID_NET_NAMING_SCHEME=v245
 ID_NET_NAME_MAC=wlx0811960210ac
 ID_OUI_FROM_DATABASE=Intel Corporate
@@ -113,8 +113,8 @@ efibootmgr \
   --disk /dev/sda --part 1 \
   --create --label "Arch Linux" \
   --loader /vmlinuz-linux \
-  --unicode 'cryptdevice=PARTUUID='$PARTUUID':cryptlvm root=/dev/vg0/root rw initrd=\intel-ucode.img initrd=\initramfs-linux.img' \
-  --verbose 

The --unicode argument is where the kernel parameters are specified. This tells the system that the partition identified by PARTUUID is encrypted and that the root filesystem to mount is the logical volume called root that is part of the volume group vg0. The microcode is also loaded with initrd=\intel-ucode.img.

Make this script executable.

chmod u+x /usr/local/sbin/mkefibootentry

Run the script to add to the motherboard boot entries.

$ mkefibootentry

Root Password

Create a secure password for the root user.

$ passwd

Reboot

Return to the Arch live installation environment.

$ exit

Unmount the partitions.

$ umount -R /mnt

Restart the machine with reboot. Remember to remove any installation media such as a USB drive.

$ reboot

Provided nothing has gone wrong your machine will boot into a fresh installation of Arch Linux. Don't forget that during the boot you will be prompted to enter the passphrase to decrypt the system partition.

Following this guide will leave you with a very minimal system where you can login as the root user. From this point how you configure the system is up to you as it will be very different to how I configure my own. If you interested in seeing how I do it then see my other posts on the subject.

Links

Offical Arch Installation Guide.Arch Linux Download Page.Etcher.Pacman Mirrorlist Generator.Wikipedia Entry for Howl's Moving Castle.Arch - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
+ --unicode 'cryptdevice=PARTUUID='$PARTUUID':cryptlvm root=/dev/vg0/root rw initrd=\intel-ucode.img initrd=\initramfs-linux.img' \ + --verbose 

The --unicode argument is where the kernel parameters are specified. This tells the system that the partition identified by PARTUUID is encrypted and that the root filesystem to mount is the logical volume called root that is part of the volume group vg0. The microcode is also loaded with initrd=\intel-ucode.img.

Make this script executable.

chmod u+x /usr/local/sbin/mkefibootentry

Run the script to add to the motherboard boot entries.

$ mkefibootentry

Root Password

Create a secure password for the root user.

$ passwd

Reboot

Return to the Arch live installation environment.

$ exit

Unmount the partitions.

$ umount -R /mnt

Restart the machine with reboot. Remember to remove any installation media such as a USB drive.

$ reboot

Provided nothing has gone wrong your machine will boot into a fresh installation of Arch Linux. Don't forget that during the boot you will be prompted to enter the passphrase to decrypt the system partition.

Following this guide will leave you with a very minimal system where you can login as the root user. From this point how you configure the system is up to you as it will be very different to how I configure my own. If you interested in seeing how I do it then see my other posts on the subject.

Links

Offical Arch Installation Guide.Arch Linux Download Page.Etcher.Pacman Mirrorlist Generator.Wikipedia Entry for Howl's Moving Castle.Arch - Read More Posts.

I don't have comments as I don't want to manage them. You can however contact me at the below address if you want to.

Email david@davidtsadler.com

License

The contents of this site is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.

Copyright © 2021 David T. Sadler.

Return to Homepage.
-- cgit v1.2.3-13-gbd6f