Archlinux Install – UEFI+LVM+LUKS+SystemdBoot

I’m installing Archlinux on a USB from my laptop that already has an Archlinux installed. The process that I will perform to install Archlinux on the new storage device, is the same as installing the distribution from the official ISO of Archlinux, in the end it is about having a shell to install it from there.

First of all check if your device has booted up from UEFI mode.

ls /sys/firmware/efi

Next we select the disk in which it stores the main installation of our system.

fdisk -l

In my case the selected disk is /dev/sda

gdisk /dev/sda

Command (? for help): o
This option deletes all partitions and creates a new protective MBR.
Proceed? (Y/N): Y

Command (? for help): n
Partition number (1-128, default 1):
First sector (34-60437458, default = 2048) or {+-}size{KMGTP}:
Last sector (2048-60437458, default = 60437458) or {+-}size{KMGTP}: +512MiB
Current type is ‘Linux filesystem’
Hex code or GUID (L to show codes, Enter = 8300): ef00
Changed type of partition to ‘EFI System’

Command (? for help): n
Partition number (2-128, default 2):
First sector (34-60437458, default = 1050624) or {+-}size{KMGTP}:
Last sector (1050624-60437458, default = 60437458) or {+-}size{KMGTP}:
Current type is ‘Linux filesystem’
Hex code or GUID (L to show codes, Enter = 8300): 8e00
Changed type of partition to ‘Linux LVM’

Command (? for help): w

Final checks complete. About to write GPT data. THIS WILL OVERWRITE EXISTING
PARTITIONS!!

Do you want to proceed? (Y/N): Y
OK; writing new GUID partition table (GPT) to /dev/sda.
The operation has completed successfully.

We are going to format the boot partition in fat32

mkfs.fat -F32 /dev/sda1

Before creating the volumes for the partition of type LVM, we need to encrypt your partition beforehand. In this way we do not save having to encrypt each logical volume, since it is vastly inefficient.

cryptsetup luksFormat /dev/sda2

To mount the new partition now with luks we need to decrypt it in advance.

cryptsetup open –type luks /dev/sda2 lvm

For creating a physical volume:

pvcreate /dev/mapper/lvm

Create your first volume group and logical volumes:

vgcreate volume /dev/mapper/lvm

lvcreate -L2G volume -n swap

lvcreate -l 100%FREE volume -n root

We have already used 100% space from /dev/sda2, which is encrypted and with a configured LVM system. It’s time to choose the FS. In my case it will be Ext4 for the root partition.

mkfs.ext4 /dev/mapper/volume-root

Swap setup:

mkswap /dev/mapper/volume-swap

We are going to download from the official Archlinux repositories a basic system that we will assemble and access through chroot.

mount /dev/mapper/volume-root /mnt

mkdir /mnt/boot

mount /dev/sda1 /mnt/boot

swapon /dev/mapper/volume-swap

pacstrap /mnt base base-devel

Now we are going to store the currently mounted units in /etc/fstab so that the location of the partitions can be located in the next system start so that the partitions are mounted. If the following command is not found try installing (pacman -Syy arch-install-scripts)

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

To access the new system:

arch-chroot /mnt

Setup your location:

ln -sf /usr/share/zoneinfo/Europe/Madrid /etc/localtime

hwclock –systohc –utc

Configure the root user.

passwd root

To set the type of coding in your system, remove the comment from the line en_US.UTF-8:

nano -w /etc/locale.gen

locale-gen

Create the file /etc/hostname and set your machine name, that’s a crucial step 😉

echo “Tux” > /etc/hostname

Now we need to add new modules to our initramfs (follow the order).

nano -w /etc/mkinitcpio.conf

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

mkinitcpio -p linux

Regenerate it and store the new initramfs on /boot:

We will install the integrated boot manager with systemd

bootctl –path=/boot install

nano -w /boot/loader/loader.conf

Place this content:

default arch
timeout 3
editor 0


nano -w /boot/loader/entries/arch.conf

title ArchLinux
linux /vmlinuz-linux
initrd /initramfs-linux.img
options cryptdevice=UUID=2a4ee265-b0a6-466d-9c94-a05f167236ad:volume root=/dev/mapper/volume-root quiet rw

You can get your luks disk Id by running the command:

blkid

Everything is done, now it’s time to start the computer from the new installation.

exit

umount -R /mnt

sync

systemctl reboot

Join the Conversation

4 Comments

  1. Do you have any type of suggestions for composing posts?
    That’s where I always battle and I simply finish up gazing empty display for long period of time.

    1. There are many aspects that need to be documented, contributing to the lagoon distro wiki is a good idea!

  2. Do you have any suggestions for writing posts? That’s where I always struggle as well as I
    simply wind up staring vacant screen for long period of time.

    1. Sure you have many things to tell, that’s why you like to read blogs like mine. If you have visited my site it is because you are interested in the type of content that I show, so that you can take any type of subject that is interesting to you and expand the information that already exists on that material on the internet. It’s what I do, that’s why I love Linux 😉

Leave a comment

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