These are some guides for various use.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

173 lines
8.2 KiB

8 months ago
  1. # Arch installation with LUKS encryption and LVM
  2. This is the german version of the [installation guide on rvbg.eu](https://wiki.rvbg.eu/#arch/installation.md).
  3. This guide is based upon a [german arch wiki entry](https://wiki.archlinux.de/title/Moderne_Installation_mit_UEFI_und_Verschlüsselung).
  4. At the end of this guide a fully functional Arch Linux will be installed.
  5. ## 1. Preparation
  6. Ahead of the installation an Arch boot-stick has to be created. The iso-file can be found on the [official website](https://www.archlinux.org/download/).
  7. The iso can be written on an USB-stick using ```dd```.
  8. After that the USB can be plugged in the system on which Arch should be installed.
  9. Boot the target system and select ```Boot Arch Linux (x86_64)```.
  10. If you need to set the keyboard layout to anything other than english you can temporarily do so by using the ```loadkeys``` command.
  11. This has to be followed by your country id (for example a german keyboard layout would be ```de```,```de-latin1``` or ```de-latin1-nodeadkeys```.
  12. ## 2. Formatting of the target drive
  13. Using ```lsblk``` you can list all the drives and partitions.
  14. Select a drive to install Arch on.
  15. For reasons of simplicity the following guide will assume the selected drive to be ```/dev/sda```.
  16. ### Clear disk completely:
  17. - `dd status=progress if=/dev/zero of=/dev/sda`
  18. Now all partitions should be removed.
  19. ### Create new partitions:
  20. If you missclick during the progress of the following commands you can press ```CTRL+C``` to close the program.
  21. No changes will be made until the confirmation at the end.
  22. The swap partition will be created later under lvm.
  23. - `gdisk /dev/sda`
  24. - `N` - Create a new empty partition table
  25. - `↵ Enter` - Create a partition
  26. - `↵ Enter` - Confirm first sector
  27. - `+512M` - Assign size of 512 MB for the first partition
  28. - `ef00` - Make the partition bootable
  29. - `n` - Create a second partition
  30. - `↵ Enter` - Confirm creation of partition
  31. - `↵ Enter` - Confirm first sector
  32. - `↵ Enter` - Confirm last sector
  33. - `↵ Enter` - Confirm partition type
  34. - `P` - Show created partitions
  35. - `W` - Save all changes
  36. - `Y` - Confirm saving changes
  37. ## 3. Encryption
  38. We need to find out which partitions is the one we want to encrypt.
  39. Using ```blkid | grep /dev/sda``` all partitions we created get listed.
  40. The right partition has the label ```Linux filesystem```.
  41. For this guide this partition is assumed to be ```/dev/sda2```.
  42. - `modprobe dm-crypt` - load kernelmodule for encryption
  43. - `cryptsetup -c aes-xts-plain -y -s 512 luksFormat /dev/sda2` - encryption
  44. - confirm with ```YES```
  45. - Now you can assign a passphrase.
  46. The passphrase has to be entered at boot to decrypt the system.
  47. Recovering of this passphrase is **not** possible.
  48. ## 4. Setup LVM
  49. - `cryptsetup luksOpen /dev/sda2 lvm` - Opening encrypted partition and mapping it to ```/dev/mapper/lvm```
  50. - `pvcreate /dev/mapper/lvm` - Create a LVM physical volume
  51. - `vgcreate main /dev/mapper/lvm` - Create LVM Volume Group
  52. - `lvcreate -L 16G -n swap main` - Create Swap in LVM (recommended: swap size is equal to ram size)
  53. - `lvcreate -l 100%FREE -n root main` - Create LVM Logical Volume for /
  54. ## 5. Create filesystems and mounting them temporarily
  55. We have to find out which partition is our boot-partition.
  56. Using ```blkid | grep /dev/sda``` once again, we can identify it by looking for the ```EFI system partition``` label.
  57. The guide assumes this partition to be at ```/dev/sda1```.
  58. - ```mkfs.fat -F 32 -n UEFI /dev/sda1``` - Assign filesystem of EFI partition
  59. - ```mkfs.ext4 -L root /dev/mapper/main-root``` - Assign filesystem of root partition
  60. - ```mkswap /dev/mapper/main-swap``` - Assign swap filesystem
  61. Now the created filesystems will be mounted for the installation.
  62. - `mount /dev/mapper/main-root /mnt` - Mounting root partition
  63. - `mkdir /mnt/boot`
  64. - `mount /dev/sda1 /mnt/boot` - Mount EFI partition
  65. - `swapon /dev/mapper/main-swap` - Mounting swap partition
  66. ## 6. Prepare base installation (optional)
  67. In this step the country specific mirrorserver for the installation will be configured.
  68. This will improve the download speed.
  69. - `cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak` - Create a backup of mirrorlist
  70. - `grep -E -A 1 ".*Germany.*$" /etc/pacman.d/mirrorlist.bak | sed '/--/d' > /etc/pacman.d/mirrorlist` - Example command to only use *German* mirrors
  71. - `cat /etc/pacman.d/mirrorlist` - Check if the file is to your liking. If it is not, you can just recover by using ```mirrorlist.bak```
  72. ## 7. Starting base installation
  73. - `pacstrap /mnt base base-devel dosfstools gptfdisk lvm2 linux linux-firmware wpa_supplicant wireless_tools networkmanager vim` - Installation of main system with needed tools
  74. - `genfstab -Up /mnt > /mnt/etc/fstab` - creation of fstab
  75. - `arch-chroot /mnt` - Switch into the newly installed system
  76. - `echo ArchLinux > /etc/hostname` - Assign hostname. ```ArchLinux``` can be changed for any name of your preference.
  77. - `echo LANG=de_DE.UTF-8 > /etc/locale.conf` - Systemsprache festlegen
  78. - `echo LANG=en_US.UTF-8 > /etc/locale.conf` - Assign system Language to be english (you can use other languages, look into the ```/etc/locale.conf``` for a list of all available languages)
  79. - `vim /etc/locale.gen` - Assigning system language
  80. - uncomment the lines depending on your needs.
  81. In this example:
  82. ```
  83. en_US.UTF-8 UTF-8
  84. ```
  85. - `locale-gen` - Generate languages
  86. - if you need any other keymap than english you can change it now for example to German by `echo KEYMAP=de-latin1 > /etc/vconsole.conf`.
  87. - `sed -i 's/MODULES=()/MODULES=(ext4)/g' /etc/mkinitcpio.conf` - Allow modules needed at boot
  88. - `sed -i 's/HOOKS=()/HOOKS=(base udev autodetect modconf block keyboard keymap encrypt lvm2 filesystems fsck shutdown)/g' /etc/mkinitcpio.conf` - Allow hooks needed at boot
  89. - `mkinitcpio -p linux` - generate Kernel-Image
  90. ## 8. Install and configure UEFI bootloader
  91. - `bootctl install` - Prepare bootloader
  92. - `vim /boot/loader/entries/arch.conf` - Create configuration
  93. It is recommended to use UUIDs where possible.
  94. Please find out what the UUID of your drive is, use ```ls -l /dev/disk/by-uuid``` to do this.
  95. ```
  96. title Arch Linux
  97. linux /vmlinuz-linux
  98. initrd /initramfs-linux.img
  99. options cryptdevice=UUID=<enter your uuid here>:lvm:allow-discards root=/dev/mapper/main-root:lvm:allow-discards resume=/dev/mapper/main-swap rw quiet lang=de init=/usr/lib/systemd/systemd locale=de_DE.UTF-8
  100. ```
  101. - `vim /boot/loader/entries/arch-fallback.conf` - Create fallback
  102. ```
  103. title Arch Linux
  104. linux /vmlinuz-linux
  105. initrd /initramfs-linux.img
  106. options cryptdevice=UUID=<enter your uuid here>:lvm:allow-discards root=/dev/mapper/main-root:lvm:allow-discards resume=/dev/mapper/main-swap rw quiet lang=de init=/usr/lib/systemd/systemd locale=de_DE.UTF-8
  107. ```
  108. - `vim /boot/loader/loader.conf` - Create loader configuration
  109. - Insert the following text
  110. ```
  111. timeout 1
  112. default arch
  113. ```
  114. ## 9. Finishing base installation
  115. - `exit` - exit the installed system
  116. - `umount /mnt/*` - unmount all partitions
  117. - `shutdown` - shutdown device
  118. - Now remove the Arch boot-stick
  119. If the system is installed in a virtual environment or a system with deactivated UEFI, don't forget to enable the EFI option, otherwise the system won't boot.
  120. ## 10. Activate Networkconnection
  121. - Start the device
  122. - Log in as ```root``` user
  123. - `systemctl enable NetworkManager.service` - Activate NetworkManager
  124. - `systemctl enable wpa_supplicant.service` - Activate wpa_supplicant
  125. - `systemctl start NetworkManager.service` - Start NetworkManager
  126. The device should connect to the internet if it is connected via LAN.
  127. Using ```nmtui``` you can administer the wired and wireless connections
  128. ## 11. Automatic timesettings
  129. - `pacman -Syu ntp` - Installing time service
  130. - `ntpd -qg` - Get current time
  131. - `hwclock --systohc` - Synchronize hardwareclock
  132. - `systemctl enable ntpd.service` - enable timeservice
  133. ## 12. Create user
  134. - `vim /etc/sudoers` - Open suoders file
  135. - uncomment the following lines
  136. ```
  137. %whell All=(ALL) ALL
  138. ```
  139. - `useradd -m user` - Create a user with ```user``` as name. For the user a home directory will be created.
  140. - `usermod -aG wheel user` - Add user ```user``` to wheel group
  141. - `passwd -d user` - Remove password for user ```user```
  142. On the freshly installed system there are 2 users.
  143. Make sure to set the password!
  144. You can add one using ```passwd```.
  145. > 03.04.2020 - Version 1.0
  146. > 03.04.2020 - Version 1.1en