thecweb.com

A place just for me

Arch notes – basic setup

https://wiki.archlinux.org/title/Installation_guide

Testing out minimal distros to run my hypervisor. Debian is fine and light enough, but the server doesn’t come for at least another day, so I’ve got time. I’ve been hearing about Arch for ever and I haven’t really looked into it, but it sounds exactly like what I’m looking for.

Arch boots into live cli environment, and then you have to manually partition the disk to start.

So, how do I want to do this?

Update the first partition must be the efi partition, and it cannot be in LVM, so do that first

fdisk /dev/sda
# g to create GPT table, n to make new, t to change type, and w to write
g
n
+1G
t
uefi
# make LVM partition
n

w

We should end up with something like this

Reddit has some ideas as usual. https://www.reddit.com/r/sysadmin/comments/1e4xnmq/linux_partition_scheme_recommendation_for_2024/

Looks like this list from open-scap is a good start. The rest is just standard linux crap.

  • /boot – 2 GB
  • swap – 4 GB
  • / – 8 GB
  • /home – 2 GB
  • /var – 4 GB
  • /var/log – 4 GB
  • /var/audit – 4 GB
  • /var/tmp – 2 GB
  • /tmp – 8 GB

reminder: pv = physical disk, vg = volume group, lv = logical volume

# list all physical volumes
lvmdiskscan

# create pv
pvcreate /dev/sda2

# display pv
pvdisplay

# summary 
pvscan

vg

# create volume group
vgcreate rootVG /dev/sda

# add another pv to vg
vgextend rootVG /dev/sdc

lv

# create lv
lvcreate -L 2G rootVG -n bootLV
lvcreate -L 4G rootVG -n swapLV
lvcreate -L 8G rootVG -n rootLV
lvcreate -L 2G rootVG -n homeLV
lvcreate -L 4G rootVG -n varLV
lvcreate -L 4G rootVG -n varlogLV
lvcreate -L 4G rootVG -n varauditLV
lvcreate -L 2G rootVG -n vartmpLV
lvcreate -L 8G rootVG -n tmpLV

# create lv on specific pv
lvcreate -L 10G VolGroup00 -n lvolhome /dev/sda

mkfs

# boot partition is FAT32 - efi mandates as a standard
mkfs.fat -F 32 /dev/sda1
mkfs.fat -F 32 /dev/rootVG/bootLV

# swap
mkswap /dev/rootVG/swapLV

# the rest
mkfs.ext4 /dev/rootVG/rootLV

mount shit under /mnt. This better get less do-it-yourself real soon or I’m going back to debian. But, if I can slap these in a script I’ll be fine.

# mount root filesystem
mount /dev/rootVG/rootLV /mnt

# make all those mf mount points you just had to have
mount --mkdir /dev/rootVG/bootLV /mnt/boot
mount --mkdir /dev/rootVG/varLV /mnt/var
      and so on...

# enable swap
swapon /dev/rootVG/swapLV

Package list:

base linux linux-firmware vim efibootmgr grub intel-ucode
networkmanager dosfstools exfatprogs e2fsprogs ntfs-3g lvm2
sshd sudo

pacstrap -K /mnt base linux linux-firmware

fstab

# Generate an fstab file (use -U or -L for UUID or labels)
genfstab -L /mnt >> /mnt/etc/fstab

chroot to new install

# fancy smancy arch version of chroot
arch-chroot /mnt

set a bunch of shit you normally never have to…

# time zone
ln -sf /usr/share/zoneinfo/America/Chicago /etc/localtime

# hw clock
hwclock --systohc

# Edit /etc/locale.gen and uncomment en_US.UTF-8 UTF-8
# fuck, install vim with 'pacman -S vim' if you forget it
locale-gen

# Create the locale.conf(5) file, and set the LANG variable accordingly
echo LANG=en_US.UTF-8 >> /etc/locale.conf

echo archkvm >> /etc/hostname

net config

# install Network Manager - nmcli
pacman -S networkmanager

# add this stuff to /etc/systemd/network/20-wired.network
[Match]
Name=en01

[Link]
RequiredForOnline=routable

[Network]
DHCP=yes

initramfs

# because we are using LVM we need to create a new initramfs.  Also needed for encryption and RAID.
# edit /etc/mkinitcpio.conf
# remove udev and replace with systemd
# insert vlm2 between block and filesystems
HOOKS=(base systemd ... block lvm2 filesystems)

# rebuild image
mkinitcpio -P

# install lvm2 and rebuild again because it gave you an error about exactly that
pacman -S lvm2
mkinitcpio -P

root password

passwd

install bootloader – I’m doing grub for now, but I may either put the /boot partition outside of LVM and load directly from UEFI.

# install grub and efibootmgr (if you haven't already)
pacman -S grub efibootmgr

# mount efi partition
mount --mkdir /dev/sda1 /boot/efi

# install grub
grub-install --target=x86_64-efi --efi-directory=/boot/efi --bootloader-id=GRUB

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

NOTE: it is here where you realize the efi partition can NOT be on an LVM partition, even though GRUB is fine with /boot being there. Starting over and updating notes. fml

cross fingers and reboot

# exit chroot
exit

umount -R /mnt

reboot

Aaaaannnd voila!!!

The most basic-bitch linux distro I’ve ever seen. Well, except for LFS, and I guess Gentoo was possibly worse because you had to wait five hours of compiling to realize you fucked up. But this is what I wanted. A Hypervisor should be very minimal.

Leave a Reply

Your email address will not be published. Required fields are marked *