Install Arch Linux with LVM

on Dec. 31, 2021, 2:34 a.m.

The first step I check when I boot to the DVD is to make sure I have an IP from DHCP
ip addr
Next, for me, I setup keyboard layout
loadkeys us
Next, I check to see if arch is booted into EFI mode
ls /sys/firmware/efi/efivars
Next, I check the link and then ping a site to make sure DNS is working
ip link
ping archlinux.org
Next, I setup NTP. I typically point to my firewall since it's a my NTP server
pacman -Sy ntp
ntpdate 10.0.0.1
timedatectl set-ntp true
Next, I make sure the system can see my disk and then I start provisioning it. First, I list what I can see and then make note of the dev path
fdisk -l
Next, I create boot, swap, and LVM
fdisk /dev/sda
Create gpt disklabel
g
N for new partition
n
P for primary
p
1 for the first partition
1
Typically, it starts with 2048 section
2048
I set the size to 1M
+1M
Set partition type
t
And label it as boot partition
4
Next I setup partition for swap. Typically, it matches however much RAM you have.
This system has 16g of ram. So we want 16G of swap
n
2
4096
+16G
Set partition type to swap
t
2
19
Next we setup partition for LVM. This allows us to add disk and space later on the fly
n
3
accept default
accept default
Set partition type to Linux LVM
t
3
30
Write changes to disk
w
Next run fdisk -l to see if it looks something like this
Device Start End Sectors Size Type
/dev/sda1 2048 4005 2048 1M BIOS boot
/dev/sda2 4096 33558527 33554432 16G Linux swap
/dev/sda3 33558528 125829086 92270559 44G Linux LVM
Next setup LVM by starting with a scan for LVM partitions
lvmdiskscan
Create the physical volume
pvcreate /dev/sda3
Create the volume group
vgcreate VolGroup00 /dev/sda3
List the volume groups
vgdisplay
Create the logical volume with 100% of available space on this partition
lvcreate -l 100%FREE VolGroup00 -n lv_root
List logical volumes
lvdisplay
Activate the LVM partition
modprobe dm_mod
vgscan
vgchange -ay
Format root LVM partition with EXT4
mkfs.ext4 /dev/VolGroup00/lv_root
mount /dev/VolGroup00/lv_root /mnt
Format the swap partition
mkswap /dev/sda2
Activate swap
swapon /dev/sda2
Copy arch linux over to the disk
pacstrap /mnt base linux linux-firmware
Setup fstab
genfstab -U /mnt >> /mnt/etc/fstab
Change root filesystem
arch-chroot /mnt
Set timezone
ln -sf /usr/share/zoneinfo/US/Eastern /etc/localtime
Setup hardware clock
hwclock --systohc
Set localization
locale-gen
Add LANG=en_US.UTF-8
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
Set virutal console
echo "KEYMAP=us" > /etc/vconsole.conf
Set hostname
echo "atl-arch" > /etc/hostname
echo "127.0.0.1 atl-arch" >> /etc/hosts
Setup initramfs
mkinitcpio -P
Set root password
passwd
Install bootloader
pacman -Sy grub
grub-install --target=i386-pc /dev/sda
grub-mkconfig -o /boot/grub/grub.cfg
Edit /etc/default/grub and add LVM support to GRUB_PRELOAD_MODULES
GRUB_PRELOAD_MODULES="... lvm"
Add lvm2 to mkinitcpio.conf
vi /etc/mkinitcpio.conf
HOOKS="base udev autodetect modconf block lvm2 filesystems keyboard fsck"
Install lvm2
pacman -Sy lvm2
Regenerate ramdisk
mkinitcpio -p linux
Finally install some packages needed. I typically run I3 for a desktop environment
pacman -Sy i3-gaps i3-wm i3blocks i3lock i3status net-tools dnsutils whois nvidia-utils ipcalc sudo xorg-xinit mlocate nano openssh-server
Exit the chroot
exit
Umount the root filesystem
umount -R /mnt
Reboot and boot to the disk
reboot
Afterwards, setup up static IP
ip link set ens192 up
ip address add 10.0.0.10/24 broadcast + dev ens192
ip route add 0.0.0.0/0 via 10.0.0.1 dev ens192
cat /etc/systemd/network/ens192.network
[Match]
Name=ens192
[Network]
Address=10.0.0.10/24
Gateway=10.0.0.1
DNS=10.0.0.1
systemctl start systemd-networkd
systemctl enable systemd-networkd
systemctl start sshd
systemctl enabled sshd
pacman -Sy ntp
nano /etc/ntp.conf
Replace server with 10.0.0.1
Add interface listening
interface ignore wildcard
interface listen lo
ntpdate 10.0.0.1
systemctl start ntpd
systemctl enable ntpd