Install Arch Linux with encrypted file-system and UEFI. Instructions are for a Dell Precision 5530 (laptop) using a wired/ethernet connection during the installation and initial configuration of the system. WiFi access is not enabled until the Post Install phase.
This is based on:
- https://gist.github.com/mattiaslundberg/8620837
- https://gist.github.com/mjnaderi/28264ce68f87f52f2cabb823a503e673
- https://wiki.archlinux.org/index.php/Installation_guide
- https://wiki.archlinux.org/index.php/Dm-crypt/Encrypting_an_entire_system#LVM_on_LUKS
- https://wiki.archlinux.org/index.php/Dm-crypt/Swap_encryption#LVM_on_LUKS
The Dell laptop comes with Ubuntu pre-installed. Use it to download the installation ISO from Arch Linux. Verify the signature of the downloaded ISO. Copy to a usb-drive with:
dd if=archlinux.img of=/dev/sdb bs=16M && sync
The disk drive needs to be securely wiped before install. The main reason is to prevent disclosure of usage patterns on the encrypted drive. This also has the added benefit of deleting and reclaiming the space of the multiple useless partitions created by Dell.
The steps for preparing the disk are:
- Boot from USB
- Securely wipe the drive
- Reboot from USB
- Insert the USB and reboot the machine.
- When the Dell is shown, press
F12(multiple times) to bring up the boot select screen. - Select
UEFI BOOTon the boot select screen. - When the Arch menu appears, select
Arch Linux archiso x86_64 UEFI CD(first option) and presse. - Press
CTRL eand appendvideo=1600x900then pressEnter.
This is a simple, effective and fast method for securely wiping the existing drive. More details on this method can be found here on the Arch Linux wiki.
root@archiso ~ # cryptsetup open --type plain -d /dev/urandom /dev/nvme0n1 to_be_wiped
root@archiso ~ # dd if=/dev/zero of=/dev/mapper/to_be_wiped status=progress bs=32M
512 GB copied, 396.428 s, 1.3 GB/s
root@archiso ~ # cryptsetup close to_be_wipedThis took about ~7 mins for a 512 GB drive.
Run the following then follow the steps from Boot from USB:
root@archiso ~ # reboot nowroot@archiso ~ # timedatectl set-ntp trueTo check the service status, use timedatectl status.
We are going to create 3 partitions using cgdisk.
root@archiso ~ # cgdisk /dev/nvme0n1Create the partitions using these values:
- 550 MiB EFI partition - /dev/nvme0n1p1
- start: +1M
- size: +550M
- hex: ef00
- label: EFI
- 550 MiB Boot partition - /dev/nvme0n1p2
- start: +1M
- size: +550M
- hex: 8300
- label: Boot
- 100% size Encrypted partition - /dev/nvme0n1p3
- start: +1M
- size: (select default)
- hex: 8e00 (LVM)
- label: Encrypted
root@archiso ~ # mkfs.vfat -F32 /dev/nvme0n1p1
root@archiso ~ # mkfs.ext4 /dev/nvme0n1p2root@archiso ~ # cryptsetup luksFormat --type luks2 /dev/nvme0n1p3
root@archiso ~ # cryptsetup open /dev/nvme0n1p3 cryptlvmThis creates a root volume and a swap volume in the encrypted partition.
root@archiso ~ # pvcreate /dev/mapper/cryptlvm
root@archiso ~ # vgcreate vg0 /dev/mapper/cryptlvm
root@archiso ~ # lvcreate -L 20G vg0 -n swap
root@archiso ~ # lvcreate -l 100%FREE vg0 -n rootUbuntu recommends the swap size should be equal to the size of RAM plus the square root of the RAM if hibernation is used. This follows that recommendation given the laptop will need to use hibernation.
root@archiso ~ # mkfs.ext4 /dev/vg0/root
root@archiso ~ # mkswap /dev/vg0/swaproot@archiso ~ # mount /dev/vg0/root /mnt
root@archiso ~ # swapon /dev/vg0/swap
root@archiso ~ # mkdir /mnt/boot
root@archiso ~ # mount /dev/nvme0n1p2 /mnt/boot
root@archiso ~ # mkdir /mnt/boot/efi
root@archiso ~ # mount /dev/nvme0n1p1 /mnt/boot/efiInstall the base packages
root@archiso ~ # pacstrap /mnt base base-devel grub-efi-x86_64 efibootmgr zsh vimThis is the first part of a workaround. See here and here for more details.
root@archiso ~ # mkdir /mnt/hostrun
root@archiso ~ # mount --bind /run /mnt/hostrun-
Fstab
root@archiso ~ # genfstab -U /mnt >> /mnt/etc/fstab
(Optional) To make /tmp a ramdisk, add the following line to /mnt/etc/fstab:
tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0 -
Enter the new system
root@archiso ~ # arch-chroot /mnt /bin/bash
-
Workaround for grub-mkconfig hanging (part 2)
[root@archiso /]# mkdir /run/lvm [root@archiso /]# mount --bind /hostrun/lvm /run/lvm
-
Set the time zone and adjust the clock
[root@archiso /]# ln -sf /usr/share/zoneinfo/America/New_York /etc/localtime [root@archiso /]# hwclock --systohc --utc
-
Configure Localization
Uncomment
en_US.UTF-8 UTF-8and other needed locales in/etc/locale.gen, then do the following:[root@archiso /]# vim /etc/locale.gen (uncomment en_US.UTF-8 UTF-8) [root@archiso /]# locale-gen [root@archiso /]# echo LANG=en_US.UTF-8 > /etc/locale.conf [root@archiso /]# export LANG=en_US.UTF-8
-
Configure network
Create the
/etc/hostnamefile:[root@archiso /]# echo myhostname > /etc/hostname
Add matching entries to
/etc/hosts:127.0.0.1 localhost ::1 localhost 127.0.1.1 myhostname.localdomain myhostname -
Set root password
[root@archiso /]# passwd
-
Create User
[root@archiso /]# useradd -m -g users -G wheel -s /bin/zsh mgaffney [root@archiso /]# passwd mgaffney [root@archiso /]# visudo #uncomment %wheel ALL=(ALL) ALL
-
Configuring mkinitcpio
[root@archiso /]# vim /etc/mkinitcpio.conf
Add 'ext4' to MODULES. Add
keyboard,encryptandlvm2toHOOKSbeforefilesystems.MODULES=(ext4) HOOKS=(base udev autodetect keyboard keymap modconf block encrypt lvm2 filesystems fsck)Regenerate initrd image:
[root@archiso /]# mkinitcpio -p linux
-
Setup grub
[root@archiso /]# grub-install [root@archiso /]# vim /etc/default/grub
Edit the following lines to:
GRUB_CMDLINE_LINUX="cryptdevice=/dev/nvme0n1p3:cryptlvm:allow-discards" ... GRUB_GFXMODE="1600x900x32"then run:
[root@archiso /]# grub-mkconfig -o /boot/grub/grub.cfg [root@archiso /]# umount /run/lvm
-
Exit new system and unmount all partitions
[root@archiso /]# exit root@archiso ~ # umount -R /mnt root@archiso ~ # swapoff -a
-
Reboot into the new system, don't forget to remove the cd/usb
root@archiso ~ # shutdown now
All of the following steps assume you are logged in as root.
The following steps will configure the laptop to:
- start/stop using an ethernet connection when a cable is plugged in/unplugged.
- start/stop using a wifi access point when the laptop enters/leaves the range of the access point
Verify the laptop is still connected to the ethernet cable.
-
Connect to the network to download and install additional packages
[root@hostname ~]# pacman -S dhcpcd [root@hostname ~]# systemctl enable dhcpcd.service [root@hostname ~]# systemctl start dhcpcd.service [root@hostname ~]# pacman -S ifplugd wpa_actiond [root@hostname ~]# systemctl stop dhcpcd.service [root@hostname ~]# systemctl disable dhcpcd.service
-
Configure ethernet connection
See here and here for more details.
[root@hostname ~]# cd /etc/netctl [root@hostname netctl]# cp examples/ethernet-dhcp . [root@hostname netctl]# vim ethernet-dhcp
Edit the following lines:
Interface=enp58s0u1 Priority=2[root@hostname netctl]# systemctl enable [email protected] [root@hostname netctl]# systemctl start [email protected]
-
Configure Wifi connection(s)
See here, here and here for more details.
[root@hostname ~]# cd /etc/netctl [root@hostname netctl]# cp examples/wireless-wpa home-wifi [root@hostname netctl]# vim home-wifi
Edit the following lines:
Interface=wlp59s0 ESSID='my-home-essid' Key='super-secret-password'[root@hostname netctl]# systemctl enable [email protected] [root@hostname netctl]# systemctl start [email protected]
[root@hostname ~]# pacman -Syu[root@hostname ~]# systemctl enable systemd-timesyncd.service
[root@hostname ~]# systemctl start systemd-timesyncd.service
[root@hostname ~]# timedatectl status # to verify- VPN
For your partitioning step, instead of using
cgdisk, you can usesgdiskto automate/script that step as well you can see and example of that here:https://github.com/shadowfax-chc/gentoo-bootstrap/blob/176fe61968ec85e7225aee5d021e59c37610d2dc/gentoo-bootstrap.sh#L74-L78