Skip to content

Instantly share code, notes, and snippets.

@yuvadm
Last active October 12, 2020 11:21
Show Gist options
  • Save yuvadm/52b3f350293a96501478 to your computer and use it in GitHub Desktop.
Save yuvadm/52b3f350293a96501478 to your computer and use it in GitHub Desktop.
Arch Linux installation on Lenovo ThinkPad X200s
# Arch Linux installation procedure on a Lenovo ThinkPad X200s
# BIOS boot (no UEFI), SSD + LVM + LUKS + TRIM + discards
# Randomize (or zero) drive contents
dd if=/dev/urandom of=/dev/sda
# Create GPT and partitions
# Use gdisk to ensure proper partition alignment
gdisk /dev/sda
# 100MB boot partition on /dev/sda1 type 8300
# Remaining root partition on /dev/sda2 type 8300
# Setup encryption
cryptsetup --cipher aes-xts-plain64 --key-size 512 --hash sha512 \
--iter-time 5000 --use-random --verify-passphrase luksFormat /dev/sda2
cryptsetup luksOpen /dev/sda2 cryptdisk
# Create LVM partitions
pvcreate /dev/mapper/cryptdisk
vgcreate vgroup /dev/mapper/cryptdisk
lvcreate --size 30G --name lvroot vgroup
lvcreate --extents +100%FREE --name lvhome vgroup
# Create filesystems
mkfs.ext4 /dev/sda1
mkfs.ext4 /dev/mapper/vgroup-lvroot
mkfs.ext4 /dev/mapper/vgroup-lvhome
# Mount filesystems
mount /dev/mapper/vgroup-lvroot /mnt
mkdir -p /mnt/{boot,home}
mount /dev/sda1 /mnt/boot
mount /dev/mapper/vgroup-lvhome /mnt/home
# Install base system
pacstrap -i /mnt base base-devel
genfstab -U -p /mnt >> /mnt/etc/fstab
# edit the fstab and add the `discard` option to all partitions
# Chroot
arch-chroot /mnt
# Some general stuff
echo computer_name > /etc/hostname
ln -sf /usr/share/zoneinfo/zone/subzone /etc/localtime
# uncomment locales in /etc/locale.gen
locale-gen
echo LANG=your_locale > /etc/locale.conf
vi /etc/mkinitcpio.conf
# add `ext4 dm_mod dm_crypt aes_x86_64 i915` modules
# add the `encrypt` `lvm2` (before `filesystems`) and `shutdown` hooks
mkinitcpio -p linux
vi /etc/lvm/lvm.conf
# set `issue_discards = 1`
# Syslinux
pacman -S syslinux gptfdisk
syslinux-install_update -i -a -m
vi /boot/syslinux/syslinux.cfg
# use APPEND root=/dev/mapper/vgroup-lvroot cryptdevice=/dev/sda2:vgroup:allow-discards
@LeonFedotov
Copy link

LeonFedotov commented May 18, 2016

Awesome 👍

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