Arch with LUKS and LVM
Disk setup Check your drives:
fdisk -l
fdisk /dev/mmcblk1
let's start with listing the partitions
: p
: n, enter, enter, +500M
: t, 1
: n, enter, enter, +500M
: t, 20
: n, enter, enter, enter
: t, 30
: p
: w
/dev/mmcblk1p1 for EFI. Weāll format it with FAT. /dev/mmcblk1p2 for /boot. Weāll format it with EXT4. /dev/mmcblk1p3 for LVM. Weāll set up LUKS in this disk. So, letās create the file systems:
mkfs.fat -F32 /dev/mmcblk1p1
mkfs.ext4 /dev/mmcblk1p2
cryptsetup luksFormat /dev/mmcblk1p3
cryptsetup open --type luks /dev/mmcblk1p3 myvolume
Next, we need to configure LVM and create two partitions for the system and home. Letās first create the physical volume.
pvcreate --dataalignment 1m /dev/mapper/myvolume
vgcreate volumegroup /dev/mapper/myvolume
create the system partition -
lvcreate -l 100%FREE volumegroup -n root
And now, letās create the file systems.
mkfs.ext4 /dev/volumegroup/root
mount /dev/volumegroup/root /mnt
mkdir /mnt/home
mkdir /mnt/boot
mount /dev/mmcblk1p2 /mnt/boot
mkdir /mnt/etc
genfstab -U /mnt >> /mnt/etc/fstab
pacstrap -i /mnt base linux linux-firmware
arch-chroot /mnt
pacman -S linux-headers intel-ucode base-devel nano networkmanager wpa_supplicant sudo netctl dialog lvm2
systemctl enable NetworkManager
/etc/hostname # contains a single line with the host name.
c300
/etc/hosts
127.0.0.1 localhost
::1 localhost
127.0.1.1 c300.lan c300
This step is important. We need to enable encryption in the hooks of mkinitcpio.conf. To do so, edit the line which starts with HOOKS= in /etc/mkinitcpio.conf and add encrypt and lvm2. It should look like this:
/etc/mkinitcpio.conf
[...]
HOOKS=(base udev autodetect modconf block encrypt lvm2 filesystems keyboard fsck)
[...]
mkinitcpio -p linux
Now, uncomment your locale (remove the leading #) and generate it.
/etc/locale.gen
[...]
en_GB.UTF-8
[...]
locale-gen
change root password
passwd
useradd -m -g users -G wheel username
change 'username' password
passwd username
Now, make users in the wheel group superusers by uncommenting the %wheel line
EDITOR=nano visudo
visudo
[...]
%wheel ALL=(ALL) ALL
[...]
pacman -S grub efibootmgr dosfstools mtools
/etc/default/grub
[...]
GRUB_CMDLINE_LINUX_DEFAULT="loglevel=3 cryptdevice=/dev/mmcblk1p3:volumegroup:allow-discards quiet"
[...]
GRUB_ENABLE_CRYPTODISK=y
[...]
mkdir /boot/EFI
mount /dev/mmcblk1p1 /boot/EFI
grub-install --target=x86_64-efi --bootloader-id=grub_uefi --force --no-nvram --removable
mkdir /boot/grub/locale
cp /usr/share/locale/en\@quot/LC_MESSAGES/grub.mo /boot/grub/locale/en.mo
grub-mkconfig -o /boot/grub/grub.cfg
dd if=/dev/zero of=/myswap bs=1M count=8192 status=progress
chmod 600 /myswap
mkswap /myswap
echo '/myswap none swap defaults 0 0' | tee -a /etc/fstab
The bulk of this was inspired by this, I have changed it to work with my disks and modified to work with a chromebook. I also wanted a copy in case it got deleted!
Posted
10:57 25-08-2021