Day: December 9, 2024

  • Arch notes – post install config

    Arch notes – post install config

    This system is too butt-ass-naked to be useful, even just as a hypervisor, so more fuck’n around.

    more packages to install:
    sudo

    create user

    useradd -m frank
    passwd frank
    

    here I realize I don’t have a network connection

    en01 is now detected as eth0, for one, so edited /etc/systemd/network/20-wired.network to fix that.

    # enable NetworkManager
    systemctl enable NetworkManager
    systemctl start NetworkManager
    
    nmcli

    Sweet. where was I?

    I’ve got network, so I need ssh, because Hyper-V sucks for running linux. no copo pasto.

    pacman -S openssh
    systemctl enable sshd
    
    pacman -S sudo

    uncomment to allow users in wheel to sudo in /etc/sudoers

    usermod -G wheel frank

    finally, I can ssh in and copy and paste.

    list of more packages to install:

    posix wget zip unzip gzip libvirt qemu-base

  • Arch notes – basic setup

    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.