Skip to content

Instantly share code, notes, and snippets.

@MAAYDEN
Forked from mattiaslundberg/arch-linux-install
Last active March 1, 2020 22:02
Show Gist options
  • Select an option

  • Save MAAYDEN/bb374eb378adb1cd8387e955e9111e70 to your computer and use it in GitHub Desktop.

Select an option

Save MAAYDEN/bb374eb378adb1cd8387e955e9111e70 to your computer and use it in GitHub Desktop.
Install Arch Linux w/ LVM on LUKS (BIOS)

Based on:

...

  • In my option /dev/sda is the system disk and /dev/sdb the USB-drive.
  • I used 'Rufus' to write an image

Preparing

  1. Change keyboard layout (optional), in my case it's German.

    # localectl list-keymaps
    # loadkeys <keymap> (e.g for German: `de-latin1` or `de`)
    
  2. Connect to internet:

  • For LAN:

      # systemctl start dhcpcd.service
    
  • For WLAN:

      # wifi-menu
    

Partitioning

  1. A drive should first be partitioned and afterwards the partitions should be formatted with a file system. Use fdisk to create MBR partitions.

    # fdisk /dev/sda
    
  2. First, create an empty MBR partition table. (WARNING: This will erase entire disk)

    # (fdisk) o
    
  3. I'm going to create 2 main partitions. (/dev/sda1 & /dev/sda2)

    Device     Boot     Start       End   Sectors   Size Id Type
    /dev/sda1            2048    526335    524288   256M 83 Linux      /boot
    /dev/sda2          526336 765986815 765460480   365G 83 Linux      Encrypted with LUKS, 3 LVM partitions:
        swap  vg0 -wi-ao----   8.00g                                   swap
        root  vg0 -wi-ao----  80.00g                                   /
        home vg0 -wi-ao---- XXX.XXg
    
  4. Create Partitions:

    # (fdisk) n
    # (fdisk) p
    # (fdisk) 1
    # (fdisk) <Enter>
    # (fdisk) +256M
    # (fdisk) t
    # (fdisk) <Enter>
    # (fdisk) 83
    
    # (fdisk) n
    # (fdisk) p
    # (fdisk) 2
    # (fdisk) <Enter>
    # (fdisk) <Enter>
    # (fdisk) t
    # (fdisk) <Enter>
    # (fdisk) 83
    
    # (fdisk) w
    
  5. Format boot - Partition: (/dev/sda1)

    # mkfs.ext2 /dev/sda1
    
  6. Setup Encryption:

    # cryptsetup -c aes-xts-plain64 -y --use-random luksFormat /dev/sda2
    # cryptsetup luksOpen /dev/sda2 luks
    
  7. Create LVM Partitions:

    # pvcreate /dev/mapper/luks
    # vgcreate vg0 /dev/mapper/luks
    # lvcreate --size 8G vg0 --name swap
    # lvcreate --size 80G vg0 --name root
    # lvcreate -l +100%FREE vg0 --name home
    
  8. Format LVM partitions:

    # mkfs.ext4 /dev/mapper/vg0-root
    # mkfs.ext4 /dev/mapper/vg0-home
    # mkswap /dev/mapper/vg0-swap
    
  9. Mount the new system:

    # mount /dev/mapper/vg0-root /mnt
    # mkdir /mnt/boot
    # mount /dev/sda1 /mnt/boot
    # swapon /dev/mapper/vg0-swap
    

Installing

  1. Install the base system w/ important components:

    # pacstrap -i /mnt base base-devel git vim lvm2 linux linux-firmware
    
  2. Generate /etc/fstab. This file can be used to define how disk partitions, various other block devices, or remote filesystems should be mounted into the filesystem.

    # genfstab -pU /mnt >> /mnt/etc/fstab
    

Configure New System

  1. Enter the new system:

    # arch-chroot /mnt /bin/bash
    
  2. Set TimeZone:

  • See available timezones w/

      # ls /usr/share/zoneinfo/
    
  • Set timezone: (e.g. for Germany)

      # ln -s /usr/share/zoneinfo/Europe/Berlin /etc/localtime
    
  1. Set Locale: (can be different if you use another layout)

    # vim /etc/locale.gen (uncomment en_US.UTF-8 UTF-8)
    # locale-gen
    # echo LANG=en_US.UTF-8 > /etc/locale.conf
    # export LANG=en_US.UTF-8
    
  2. Set the hardware clock mode uniformly between your operating systems. Otherwise, they may overwrite the hardware clock and cause time shifts.

    # hwclock --systohc --utc
    
  3. Set hostname:

    # echo <myhostname> >/etc/hostname
    
  4. Add following to /etc/hosts:

    127.0.1.1  myhostname.localdomain  myhostname
    
  5. Create User:

    # adduser <username>
    # usermod -aG wheel <username>
    # passwd <username>
    # vim /etc/sudoers
    
  • Uncomment following:

      %wheel ALL=(ALL) ALL
    
  1. Set root password:

    # passwd root
    
  2. Download/Configure mkinitcpio with modules needed for the initrd image:

    # pacman –S mkinitcpio
    # vim /etc/mkinitcpio.conf
    
  • Add ext4 to MODULES

  • Add encrypt and lvm2 to HOOKS before filesystems

      # mkinitcpio -p linux
    

GRUB

  1. Setup grub:

    # pacman -S grub
    # grub-install --target=i386-pc --recheck /dev/sda
    
  • In /etc/default/grub edit the line GRUB_CMDLINE_LINUX to:

    GRUB_CMDLINE_LINUX="cryptdevice=/dev/sda2:luks:allow-discards"

  • [Tip] To automatically search for other operating systems on your computer, install os-prober (pacman -S os-prober) before running the next command.

      # grub-mkconfig -o /boot/grub/grub.cfg
    

Reboot

  • WARNING! Before you unmount & reboot, it’s highly recommended to install followings to have Internet-Connection:

  • For wifi-menu:

      # sudo pacman –S netctl dialog wpa_supplicant
    
  • For LAN:

      # sudo pacman –S dhcpcd
    
  1. Exit new system and unmount all partitions:

    # exit
    # umount -R /mnt
    # swapoff –a
    
  2. Reboot into the new system: (Don't forget to remove the CD/USB.)

    # reboot
    
  3. Start network & check internet connection:

    # systemctl enable dhcpcd.service
    # systemctl start dhcpcd.service
    
    # ping google.com
    
  • WARNING! There could be an error like below, after connecting w/ wifi-menu to your Network, e.g. Job for netctl@wlp0s19f2u2\networkname.service failed because the control process exited with error code. See “systemctl status “netctl@wlp0s19f2u2\networkname.service”” and “journal –xe” for details.

  • So what I did was:

      # systemctl stop dhcpcd.service
      # ip link set down wlp0s19f2u2
    
  • Then:

      # systemctl start netctl@wlp0s19f2u2\networkname.service 
    
  • or

      # wifi-menu
    

GUI

  1. Now you need GUI (I hope), for KDE Plasma:
  • Install xorg & sddm:

      # pacman -S xorg xorg-server xorg-xinit sddm xterm
    
  • Install graphics driver:

  • Use lscpi | grep VGA to detect your VGA Controller and install your one or install 'em all:

      # pacman –S xf86-video-intel xf86-video-amdgpu xf86-video-ati
    
  • Now install KDE & Enable Display Manager (sddm):

      # pacman –S plasma kde-applications
      # systemctl enable sddm
    
  1. Now reboot:

    # reboot
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment