Installing arch linux on my ThinkPad

After having worked almost 2 years with fedora, I decided to switch to arch linux. In this post I’ve written down the steps I took to install arch linux on my ThinkPad W510.
I’ve just been too annoyed by almost reinstalling the system at least once a year with every release. And there have been kernel panics and gnome shell hangs coming and going and I couldn’t really find out why. I didn’t want to spend much time on that either. I don’t want to say fedora is bad, I just have the feeling that archlinux is better for me. So after trying it in a virtual box I’m going to give it a try on my laptop. This writeup is not intented to be a arch linux install tutorial (there are many) or replace the wonderful arch linux wiki. It’s just a note for me what I did but I hope it might me helpful for somebody else as well.

This is a post from my old blog http://tech.cbjck.de. It has been moved here and slightly edited for better readability. It's also been adjusted to the new layout.
The content however is old and might be outdated.


 

Prepare boot medium

Download the dual-iso (for i386 and x64 archictectures) and put the iso to a usb drive

dd bs=4M if=Downloads/archlinux-20xx.xx.xx-dual.iso of=/dev/sdx && sync

Of course you can also burn it to a CD.

Prepare installation

Boot into the live system and prepare the installation ie: partition disk, format partitions and so on.

Language settings for the live system

Set keyboard layout and change terminal font to an international one:

loadkeys de-latin1
setfont Lat2-Terminus16

I also like changing the language now, but that’s not necessary. In /etc/locale.gen uncomment all locales you want to use (plus en_US). Use the UTF-8 variants.

nano /etc/locale.gen
en_US.UTF-8 UTF-8
de_DE.UTF-8 UTF-8

Generate the locales:

locale-gen
export LANG=de_DE.UTF-8

Establish an internet connection

In my case the (wired) internet connection just worked out of the box. Check it

ping -c 3 heise.de

Prepare storage

Now things are getting a bit complicated as I want to use encryption and a SSD. There will be

  • a partition for /boot (500MB)
  • en encrypted partition for LVM (the rest of the disk)

I’ve decided not to use a swap partition. It would only be useful for hibartantion which I did only rarely use in past two years. If the need should arise, it can easily be added later as a swapfile.
Use

gdisk /dev/sda

to create a new GPT partition table (command o) und the create the following partitions:

  1. sda1 – Size 1007KB, Partition Type EF02 for grub (Sectors 34- 2047, adjust alignment first to 1 sector by x for experts menu, then l, exit to main menu by m)
  2. sda2 – Size 500MB, Partition Type 8300 for /boot (don’t forget to reset aligment to 2048)
  3. sda3 – remaining space, Partition Type 8E00 (LVM)
      Review the partition layout (p) and save to disk (w).

Format the first partition with ext2 for /boot:

mkfs.ext2 /dev/sda1

Now it’s time for cryptsetup.

cryptsetup -c aes-xts-plain -s 512 luksFormat /dev/sda3

enter your password twice. Then open the container:

cryptsetup luksOpen /dev/sda3 lvm

The decrypted disk is now available at /dev/mapper/lvm. So now we can create the LVM.

pvcreate /dev/mapper/lvm
vgcreate vg_sys /dev/mapper/lvm
lvcreate -L 15G MyStorage -n lv_root
lvcreate -l 100%FREE vg_sys -n lv_home

Then create filesystems

mkfs.ext4 /dev/mapper/vg_sys-lv_root
mkfs.ext4 /dev/mapper/vg_sys-lv_root

and mount to the appropiate locations:

mount /dev/mapper/vg_sys-lv_root /mnt
mkdir /mnt/home
mount /dev/mapper/vg_sys-lv_home /mnt/home
mkdir /mnt/boot
mount /dev/sda2 /mnt/boot

Install the basesystem

First edit the mirrorlist in /etc/pacmand.d/mirrorlist and put your preferred mirror on top. You can use the Mirrorlist Generator to generate an updated mirrorlist for your country. As the edited list will be moved to the new system it does make sense to edit it.
Then install the base system by

pacstrap -i /mnt base

Now create a fstab and have a close look if everything is alright.

genfstab -U -p /mnt >> /mnt/etc/fstab
nano /mnt/etc/fstab

It might be a good idea to adjust the options tab to fit the SSD used (according to https://wiki.archlinux.org/index.php/SSD#TRIM)

Configure the newly installed system

Now changeroot to the new sytem and do some configuration work there.

arch-chroot /mnt /bin/bash

Now again set locale, keymap and make it stick after a reboot. Just as above uncomment the needed locales in /etc/locale.gen and run

locale-gen

then make it reboot proof

echo LANG=de_DE.UTF-8 > /etc/locale.conf
export LANG=de_DE.UTF-8

Same with font and keymap

loadkeys de-latin1
setfont Lat2-Terminus16

In /etc/vconsole.conf add

KEYMAP=de-latin1
FONT=Lat2-Terminus16

Set timezone

Just link your timezone from /usr/share/zoneinfo to /etc/localtime

ln -s /usr/share/zoneinfo/Europe/Berlin /etc/locatime

Set the hardwareclock to UTC

hwclock --systohc --utc

Later I will setup ntpd to automatically set the clock according to network time.

Setup networking

Checking with

ping -c 3 heise.de

prooved that wired network works out of the box on my desk, about wifi I will have to think later. For the moment I’ll just leave it to this.
Enable the dhcpcd service

systemctl enable dhcpcd.service

and set the hostname

echo arch > /etc/hostname

Create initial ramdisk

This is the next big thing. Because of encryption there is some work to do.
Edit /etc/mkinitcpio.conf and make HOOKS contain the following

 ....... keymap encrypt lvm2 filesystems...

Save and create the initital ramdisk

mkinitcpio -p linux

Root password

Don’t forget to set a root password

passwd

Install bootloader

I’m going for grub. First install the package

pacman -S grub

Then edit /etc/default/grub and make the following line look like

GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda3:vg_sys:allow-discards"

Install grub to the disk and generate the config:

grub-install --target=i386-pc --recheck /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg

Reboot

Exit the changeroot and reboot.

exit
umount /mnt/{boot,home,}

Make sure the computer doesn’t boot the install media and cross fingers that there are no mistakes and everything is working fine. After Grub2 loads, you should be asked for the encryption key to unlock /dev/sda3, the the system should boot.

The install is now done, time to setup the system to your liking.

References

1 Comment

  1. Pingback: Installing arch linux on my new desktop

Leave a Reply

Your email address will not be published. Required fields are marked *