Last active
February 3, 2022 17:40
-
-
Save ansulev/bfeb93a905470a4a23ebed27fa5769f5 to your computer and use it in GitHub Desktop.
Install Arch Linux with Btrfs - dual boot with Win10 on ThinkPad t480s
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Install Arch Linux dual boot with Windows 10 on Thinkpad T480s. | |
# Btrfs subvolumes inside. UEFI and Secure Boot enabled. | |
# filename: install-arch-linux-btrfs-dual-boot-t480s.txt | |
# The official guide: https://wiki.archlinux.org/index.php/Installation_Guide | |
# Shrink Windows partition to make room for the linux. | |
# Remove BitLocker encryption and Fast Boot. After install can re-enable BitLocker. | |
# Need to setup again Bitlocker, PIN, Fingerprint (tested on Win10 1909) | |
# Download the archiso image from https://www.archlinux.org/download/ | |
# Copy to a usb-drive | |
dd bs=16M if=archlinux.iso of=/dev/sdx status=progress oflag=sync # on linux | |
# Disable secure boot during install | |
# Boot from the usb. | |
# Set keymap | |
loadkeys us | |
# Connect to Internet: | |
# Ethernet - plug in the cable | |
# WLAN - use iwctl utility | |
# WWAN - use mmcli utility | |
# Connect to WLAN using wlan0: | |
iwctl | |
[iwd]# station wlan0 connect SSID | |
# enter the passphras | |
# or directly connect from zsh: | |
iwctl --passphrase passphrase station wlan0 connect SSID | |
# Check connection: | |
ping archilinux.org | |
# Use cfdisk to create linux partition on the freed space. | |
cfdisk /dev/nvme0n1 | |
# Create and mount btrfs filesystem (mine is nvme0n1p4) | |
mkfs.btrfs --force --label archlinux -n 32k /dev/nvme0n1p4 | |
o=defaults,x-mount.mkdir | |
o_btrfs=$o,compress=zstd,ssd,noatime,nodiratime,space_cache | |
mount -t btrfs LABEL=archlinux /mnt | |
# Create btrfs subvolumes | |
btrfs subvolume create /mnt/@ | |
btrfs subvolume create /mnt/@home | |
btrfs subvolume create /mnt/@snapshots | |
btrfs subvolume create /mnt/@var_log | |
btrfs subvolume create /mnt/@vault | |
# Umount everything | |
umount -R /mnt | |
# Remount only the subvolumes | |
mount -t btrfs -o subvol=@,$o_btrfs LABEL=archlinux /mnt | |
mount -t btrfs -o subvol=home,$o_btrfs LABEL=archlinux /mnt/home | |
mount -t btrfs -o subvol=@snapshots,$o_btrfs LABEL=archlinux /mnt/.snapshots | |
mount -t btrfs -o subvol=@var_log,$o_btrfs LABEL=archlinux /mnt/var/log | |
mount -t btrfs -o subvol=@vault,$o_btrfs LABEL=archlinux /mnt/vault | |
# Mount EFI partition - in my case: /dev/nvme0n1p1 | |
mkdir /mnt/boot | |
mount /dev/nvme0n1p1 /mnt/boot | |
# Install base system y tools | |
pacstrap /mnt base base-devel btrfs-progs mlocate htop vim dialog bash-completion \ | |
gptfdisk dosfstools efibootmgr os-prober grub intel-ucode iw iwd net-tools \ | |
linux-zen linux-zen-headers zsh zsh-completions irqbalance cpupower \ | |
x86_energy_perf_policy powertop smartmontools snapper rfkill upower acpid \ | |
lm_sensors tlp thermald p7zip lzop ntfs-3g lsof ifplugd wget aria2 \ | |
ethtool elinks whois hping dnsutils nethogs wavemon linux-firmware \ | |
wireless_tools wpa_supplicant dhcpcd dnsmasq privoxy torsocks netcat ntop | |
# Generate fstab | |
genfstab -L -p /mnt >> /mnt/etc/fstab | |
vim /mnt/etc/fstab | |
....... | |
# /dev/nvme0n1p4 UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | |
LABEL=archlinux / btrfs rw,noatime,nodiratime,commit=60,compress=zstd,ssd,space_cache,subvolid=256,subvol=@ 0 0 | |
# /dev/nvme0n1p4 UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | |
LABEL=archlinux /home btrfs rw,noatime,nodiratime,commit=60,compress=zstd,ssd,space_cache,subvolid=257,subvol=@home 0 0 | |
# /dev/nvme0n1p4 UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | |
LABEL=archlinux /.snapshots btrfs rw,noatime,nodiratime,commit=60,compress=zstd,ssd,space_cache,subvolid=258,subvol=@snapshots 0 0 | |
# /dev/nvme0n1p4 UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | |
LABEL=archlinux /var/log btrfs rw,noatime,nodiratime,commit=60,compress=zstd,ssd,space_cache,subvolid=259,subvol=@var_log 0 0 | |
# /dev/nvme0n1p4 UUID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | |
LABEL=archlinux /vault btrfs rw,noatime,nodiratime,commit=60,compress=zstd,ssd,space_cache,subvolid=260,subvol=@vault 0 0 | |
# /dev/nvme0n1p1 UUID=xxxx-xxxx | |
LABEL=EFI /boot vfat rw,relatime,fmask=0022,dmask=0022,codepage=437,iocharset=iso8859-1,shortname=mixed,utf8,errors=remount-ro 0 2 | |
# swap in zram (we have 4 CPU cores) | |
/dev/zram0 none swap defaults 0 0 | |
/dev/zram1 none swap defaults 0 0 | |
/dev/zram2 none swap defaults 0 0 | |
/dev/zram3 none swap defaults 0 0 | |
# user cache on tmpfs (4GB) | |
tmpfs /home/angel/.cache tmpfs noatime,nodev,nosuid,size=4000M 0 0 | |
# mysqltmp on /tmp (mariadb-969, mysql-89) | |
tmpfs /var/lib/mysqltmp tmpfs rw,gid=969,uid=969,size=100M,mode=0750,noatime 0 0 | |
.... | |
# Notes: | |
# We don't use discard option for btrfs subvols. Will set later: systemctl enable fstrim.timer | |
# Set noatime,nodiratime,commit=60 for best performence. | |
# Using autodefrag on btrfs ssd is discused here: https://www.mail-archive.com/[email protected]/msg30749.html | |
# To set noCOW for BDs, VMs, Torrents dirs: chattr +C /dir/file | |
# Add root password and Boot into new system | |
# You may need to run 'rm /mnt/etc/securetty /mnt/usr/share/factory/etc/securetty' | |
# if you get 'Login incorrect' error | |
# Aditionally add these files to NoExtract in pacman.conf | |
systemd-nspawn -D /mnt | |
passwd | |
logout | |
systemd-nspawn -bD /mnt | |
# Generate and set default locale | |
vim /etc/locale.gen | |
# Uncomment en_US.UTF-8 | |
locale-gen | |
systemd-firstboot --prompt-locale | |
# Set time - Hardware clock to UTC. Need to setup Windows, too. | |
timedatectl set-ntp 1 | |
timedatectl set-timezone Europe/Madrid | |
#hwclock --systohc --utc | |
# Hostname | |
hostnamectl set-hostname myhostname | |
vim /etc/hosts | |
... | |
127.0.0.1 localhost.localdomain localhost | |
::1 localhost.localdomain localhost | |
127.0.1.1 myhostname.localdomain myhostname | |
... | |
# Set virtual console | |
vim /etc/vconsole.conf | |
KEYMAP=us | |
FONT=latcyrheb-sun32 | |
vim /etc/mkinitcpio.conf | |
... | |
MODULES=(atkbd intel_agp i915) | |
BINARIES=(/usr/sbin/btrfs) | |
HOOKS=(base udev autodetect modconf block filesystems keyboard fsck) | |
COMPRESSION="zstd" | |
COMPRESSION_OPTIONS=(-T0 -19) | |
... | |
mkinitcpio -P | |
# Set root password | |
passwd | |
# Create user | |
useradd -m -G wheel angel | |
passwd angel | |
# Install GRUB2 | |
grub-install --target=x86_64-efi --efi-directory=/boot --bootloader-id=ArchLinux --recheck | |
# Edit /etc/default/grub | |
... | |
GRUB_CMDLINE_LINUX_DEFAULT="acpi_osi='Windows 2018' acpi=force acpi_enforce_resources=lax i915.modeset=1 i915.fastboot=1 i915.enable_psr=1 i915.enable_guc=3 i915.enable_fbc=1 i915.enable_dc=1 net.ifnames=0 spectre_v2=off pti=off mds=off nowatchdog audit=0 psmouse.elantech_smbus=0 msr.allow_writes=on usbhid.mousepoll=4 sysrq_always_enabled=1" | |
GRUB_PRELOAD_MODULES="part_gpt part_msdos" | |
GRUB_GFXMODE=1920x1080 | |
GRUB_DISABLE_LINUX_UUID=true | |
GRUB_DISABLE_RECOVERY=true | |
GRUB_DISABLE_SUBMENU=y | |
#GRUB_FONT="/boot/grub/terminus.pf2" | |
GRUB_SAVEDEFAULT="true" | |
... | |
Note: | |
### Full options off cmdline with vsyscall=emulate, audit=1 and silent boot | |
#GRUB_CMDLINE_LINUX_DEFAULT="acpi_osi=! acpi_osi='Windows 2018' acpi=force acpi_enforce_resources=lax i915.modeset=1 i915.fastboot=1 i915.enable_psr=1 i915.enable_guc=3 i915.enable_fbc=1 i915.enable_dc=1 net.ifnames=0 spectre_v2=off nopti nowatchdog mds=off vsyscall=emulate psmouse.elantech_smbus=0 ec_sys.write_support=1 audit=1 audit_backlog_limit=8192 quiet loglevel=3 rd.systemd.show_status=auto rd.udev.log_priority=3" | |
# Generate config file | |
grub-mkconfig -o /boot/grub/grub.cfg | |
# Exit nspawn, umount all and reboot | |
poweroff | |
umount -R /mnt | |
reboot | |
# Configure new system | |
# Download yay helper from AUR (need pacman -S go) | |
wget https://aur.archlinux.org/cgit/aur.git/snapshot/yay.tar.gz | |
# Install YAY as regular user (extract, run makepkg, pacman -U) | |
# Modify pacman.conf and add extra repos: | |
vim /etc/pacman.conf | |
... | |
XferCommand = /usr/bin/aria2c --allow-overwrite=true --continue=true --file-allocation=none --log-level=error --max-tries=2 --max-connection-per-server=2 --max-file-not-found=5 --min-split-size=5M --no-conf --remote-time=true --summary-interval=60 --timeout=5 --dir=/ --out %o %u | |
NoExtract = usr/lib/binfmt.d/wine.conf | |
NoExtract = usr/share/applications/wine.desktop | |
NoExtract = etc/securetty | |
NoExtract = usr/share/factory/etc/securetty | |
# Misc options | |
#UseSyslog | |
Color | |
#TotalDownload | |
CheckSpace | |
#VerbosePkgLists | |
ILoveCandy | |
[DEB_Arch_Extra] | |
SigLevel = Optional TrustAll | |
Server = https://mega.nz/linux/MEGAsync/Arch_Extra/$arch | |
[archlinuxcn] | |
Include = /etc/pacman.d/archlinuxcn-mirrorlist | |
#Server = http://repo.archlinuxcn.org/$arch | |
[chaotic-aur] | |
Include = /etc/pacman.d/chaotic-mirrorlist | |
[blackarch] | |
SigLevel = TrustAll | |
Include = /etc/pacman.d/blackarch-mirrorlist | |
#[archlinuxgr] | |
#SigLevel = Optional TrustAll | |
#Server = http://archlinuxgr.tiven.org/archlinux/$arch | |
#[archstrike] | |
#Server = https://mirror.archstrike.org/$arch/$repo | |
#[muflone-aur] | |
#SigLevel = Required | |
#Server = https://www.muflone.com/repositories/archlinux/$repo/$arch | |
#[sublime-text] | |
#Server = https://download.sublimetext.com/arch/dev/x86_64 | |
... | |
# X server | |
yay -S xorg-server xorg-xbacklight xorg-xdpyinfo xorg-xev xorg-xinit \ | |
xorg-xinput xorg-xkill xorg-xrandr xorg-xset mesa xf86-video-intel xf86-video-fbdev | |
# Terminals | |
pacman -S xterm rxvt-unicode terminator lxterminal screen tmux | |
# Fonts | |
yay -S ttf-liberation ttf-droid ttf-hack terminus-font terminus-font-ttf ttf-monaco ttf-symbola \ | |
ttf-pacifico noto-fonts-emoji | |
# Media (TODO: PulseAudio for bluetooth) | |
pacman -S alsa-utils alsa-plugins alsa-firmware pulseaudio-alsa pulseaudio-bluetooth pulseaudio-jack pulsemixer pulseaudio-equalizer-ladspa pulseaudio-equalizer | |
# Install OpenBox WM and few applications (or i3 or xfce4 - TODO:) | |
yay -S openbox tint2 udevil conky dmenu compton volumeicon scrot slock feh xarchiver cups-pdf sane | |
yay -S clipit scite spacefm-git redshift perwindowlayoutd gxkb nitrogen gpicview viewnior mtpaint | |
# TODO: | |
# Configure visudo for regular user and autologin. Add DM and configure WM (Openbox) | |
# Install and configure other needed packages | |
# Install and configure rest of system... (Work in progress...) | |
# Networking | |
# Configire netctl-auto & dnsmasq: TODO | |
# Configure Xorg |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment