install_archlinux_with_lvm_on_luks_bios:gpt
Differences
This shows you the differences between two versions of the page.
Next revision | Previous revision | ||
install_archlinux_with_lvm_on_luks_bios:gpt [2023/11/21 22:30] – created dougy147 | install_archlinux_with_lvm_on_luks_bios:gpt [2024/08/18 13:04] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
< | < | ||
- | Installing ArchLinux with LVM on LUKS on a BIOS/GPT system. | + | Installing ArchLinux with LVM on LUKS on a BIOS/GPT system |
# Keyboard | # Keyboard | ||
Line 7: | Line 7: | ||
loadkeys fr | loadkeys fr | ||
``` | ``` | ||
- | Available layouts are located in `/ | ||
- | List them all with `ls / | + | List available fonts with `ls / |
# Fonts | # Fonts | ||
- | Do yourself a favour: increase the terminal font during install | + | Do yourself a favour: increase the terminal font for visual comfort ;-) |
``` | ``` | ||
Line 19: | Line 18: | ||
``` | ``` | ||
- | Available fonts are located here `/ | + | List available fonts with `ls / |
- | + | ||
- | List them all with `ls / | + | |
# Boot mode | # Boot mode | ||
- | Remember this tutorial | + | Remember this guide is for BIOS boot firmware. |
- | Be sure to be in that mode as there are minor divergences with UEFI during partitioning and bootloader configuration. | + | As there are minor divergences with UEFI during partitioning and bootloader configuration. |
+ | Check whether this guide is suited for you: | ||
``` | ``` | ||
cat / | cat / | ||
- | # No such file or directory | + | # BIOS => "No such file or directory" |
- | # 32 or 64 => system booted with UEFI | + | # UEFI => "32" |
``` | ``` | ||
- | If the command returns | + | If the command returns |
- | Otherwise, if the command | + | |
+ | Otherwise, if it returns `64` (or `32`): your system booted in UEFI 64-bit x64 (or 32-bit IA32), and you should not use that guide. | ||
# Connect to the network | # Connect to the network | ||
- | If your computer | + | If the machine |
``` | ``` | ||
+ | ip a # identify your wireless card (usually wlan0) | ||
iwctl | iwctl | ||
station wlan0 scan | station wlan0 scan | ||
Line 57: | Line 57: | ||
# Partitioning | # Partitioning | ||
- | We want LVM on LUKS. That means a layer of encryption | + | We want LVM on LUKS. That means a layer of encryption |
- | It is better to have LVM **inside** the LUKS encryption. (But it is more common to say LVM **on** LUKS.) | + | It is better to have LVM **inside** the LUKS encryption< |
{{ : | {{ : | ||
Line 69: | Line 69: | ||
- LVM partitioning | - LVM partitioning | ||
- | Identify the drive you want to install the OS on (usually | + | Identify the drive you want to install the OS on. (Usually |
``` | ``` | ||
Line 75: | Line 75: | ||
``` | ``` | ||
- | To avoid copy-pasting mistakes, we will assume the drive to be `/dev/sdXXX`. Change it accordingly. | + | We will assume the drive to be `/dev/sdz`. Change it accordingly. |
Line 85: | Line 85: | ||
cryptsetup benchmark # if you want to chose the fastest algorithm (aes-xts for now) | cryptsetup benchmark # if you want to chose the fastest algorithm (aes-xts for now) | ||
ALGO=" | ALGO=" | ||
- | cryptsetup open --type plain --cipher " | + | cryptsetup open --type plain --cipher " |
lsblk # you should see the drive ' | lsblk # you should see the drive ' | ||
dd if=/ | dd if=/ | ||
Line 106: | Line 106: | ||
``` | ``` | ||
- | cfdisk /dev/sdXXX | + | cfdisk /dev/sdz |
``` | ``` | ||
Line 115: | Line 115: | ||
It is going to be unencrypted (BIOS boot) and will be used to store the second stage of BIOS bootloader. | It is going to be unencrypted (BIOS boot) and will be used to store the second stage of BIOS bootloader. | ||
- | |||
- | ## (almost) full disk encryption | ||
- | |||
- | You should still be in `cfdisk` (else `cfdisk /dev/sdXXX` again). | ||
Use remaining `<Free Space>` as a `< | Use remaining `<Free Space>` as a `< | ||
Line 125: | Line 121: | ||
Then `< | Then `< | ||
- | ``` | + | Our drive is " |
- | cryptsetup luksFormat --type luks1 /dev/sdXXX2 # this NON-boot partition | + | * `/dev/sdz1`: BIOS boot partition |
- | # BEFORE typing your secure passphrase READ BELOW | + | * `/ |
- | ``` | + | |
+ | |||
+ | ## (almost) full disk encryption | ||
+ | |||
+ | Let's encrypt | ||
| IMPORTANT NOTE | | | IMPORTANT NOTE | | ||
Line 134: | Line 135: | ||
| You really should read this if you don't use a QWERTY layout. Indeed, the keyboard layout will by default be " | | You really should read this if you don't use a QWERTY layout. Indeed, the keyboard layout will by default be " | ||
+ | ``` | ||
+ | cryptsetup luksFormat --type luks1 /dev/sdz2 | ||
+ | # BEFORE typing your secure passphrase READ ABOVE | ||
+ | ``` | ||
+ | |||
+ | After initializing the LUKS partition, let's open it and map it to a name (`cryptlvm` here): | ||
``` | ``` | ||
- | cryptsetup open /dev/sdXXX2 | + | cryptsetup open /dev/sdz2 cryptlvm # open LUKS partition |
# type secure passphrase to decrypt | # type secure passphrase to decrypt | ||
``` | ``` | ||
Line 166: | Line 173: | ||
``` | ``` | ||
- | ## Install | + | # Install |
+ | |||
+ | Partitioning is finally done. Let's install basic programs and write the partition table to our future system `fstab`: | ||
``` | ``` | ||
Line 220: | Line 229: | ||
``` | ``` | ||
- | ## Configure bootloader | + | ## Bootloader |
Configure GRUB to allow booting from `/boot` on a LUKS1 encrypted partition. | Configure GRUB to allow booting from `/boot` on a LUKS1 encrypted partition. | ||
Line 233: | Line 242: | ||
The first line sets the kernel parameters so the initramfs can unlock the encrypted root partition, using the `encrypt` hook. | The first line sets the kernel parameters so the initramfs can unlock the encrypted root partition, using the `encrypt` hook. | ||
- | The `< | + | The `< |
To find UUID : `blkid` for GPT (else `lsblk -f`). | To find UUID : `blkid` for GPT (else `lsblk -f`). | ||
- | |||
- | ## Install bootloader (GRUB) | ||
``` | ``` | ||
- | grub-install --target=i386-pc --recheck /dev/sdXXXX # not a parition, it's the whole disk (e.g. /dev/sda) | + | grub-install --target=i386-pc --recheck /dev/sdz |
``` | ``` | ||
Line 260: | Line 267: | ||
Everything should be fine. | Everything should be fine. | ||
- | ## Avoid having to enter your passphrase twice | + | # Enter your passphrase |
- | As boot and root are on the same partition you will be asked twice for your passphrase. | + | As boot and root are on the same partition you will be asked twice for your passphrase |
The first time, GRUB asks for the passphrase to decrypt the boot partition. | The first time, GRUB asks for the passphrase to decrypt the boot partition. | ||
The second time, it is the encrypt hook which asks you for the root partition' | The second time, it is the encrypt hook which asks you for the root partition' | ||
- | If you do not want to be asked for your root partition password again, you will have to embed the keyfile in the initramfs and configure it to be used on system boot to decrypt and mount the root partition. | + | If you do not want to be asked for your root partition password again, you will have to embed a keyfile in the initramfs and configure it to be used on system boot to decrypt and mount the root partition |
- | [From this post](https:// | + | So, when booting your system, GRUB will ask you to decrypt your `/boot` partition |
- | So, when booting your system, GRUB will ask you to decrypt your `/boot` partition (remember the keyboard | + | We will indeed avoid that by creating a keyfile. It will be read after boot decryption and used to decrypt the `root` partition |
- | Once decrypted, it will ask you again to decrypt the `root` partition. | + | |
- | We will avoid that by creating a keyfile that will be read after decrypting the boot, so GRUB knows how to decrypt the `root` partition in the mean time. | + | Let's first create a keyfile and add it as LUKS key: |
- | + | ||
- | First create a keyfile and add it as LUKS key: | + | |
``` | ``` | ||
dd bs=512 count=4 if=/ | dd bs=512 count=4 if=/ | ||
chmod 000 / | chmod 000 / | ||
- | cryptsetup -v luksAddKey /dev/sdXXX2 | + | cryptsetup -v luksAddKey /dev/sdz2 / |
``` | ``` | ||
Line 289: | Line 293: | ||
Recreate the initramfs image and secure the embedded keyfile: | Recreate the initramfs image and secure the embedded keyfile: | ||
+ | ``` | ||
+ | mkinitcpio -P | ||
- | `chmod 600 / | + | chmod 600 / |
+ | ``` | ||
Set the following kernel parameters to unlock the LUKS partition with the keyfile. Using the encrypt hook: | Set the following kernel parameters to unlock the LUKS partition with the keyfile. Using the encrypt hook: | ||
- | `GRUB_CMDLINE_LINUX=" | + | ``` |
+ | GRUB_CMDLINE_LINUX=" | ||
+ | ``` | ||
+ | |||
+ | Recreate `grub.cfg`: | ||
+ | |||
+ | ``` | ||
+ | grub-mkconfig -o / | ||
+ | ``` | ||
If for some reason the keyfile fails to unlock the boot partition, systemd will fallback to ask for a passphrase to unlock and, in case that is correct, continue booting. | If for some reason the keyfile fails to unlock the boot partition, systemd will fallback to ask for a passphrase to unlock and, in case that is correct, continue booting. | ||
+ | |||
+ | # Exit to your system | ||
+ | |||
+ | Congratulations! You can leave the installation medium to dive into your new system: | ||
+ | |||
+ | ``` | ||
+ | exit | ||
+ | umount -R /mnt | ||
+ | cryptsetup close cryptlvm | ||
+ | reboot | ||
+ | # remove USB key | ||
+ | ``` | ||
+ | |||
+ | Enjoy |
install_archlinux_with_lvm_on_luks_bios/gpt.1700605808.txt.gz · Last modified: (external edit)