Vmm /

Arch

NOTE: This guide assumes that you have 50G disk for your vm

  • `vmctl start -c -B cdrom <vm-name>`
  • Press `<TAB>`, then enter ` console=ttyS0,115200`
  • The problem may occur with loading `/dev/disk/by-label/ARCH_<SMTH>`
    • To fix it you need to create `/dev/disk/by-label/` if needed - `mkdir -p /dev/disk/by-label/`
    • Then check `blkid`, and `ln -s <path-to-iso-that-was-returned> /dev/disk/by-label/ARCH_<SMTH>` `ln -s /dev/sr0 /dev/disk/by-label/ARCH_202206`
    • exit from that console
  • login as `root`
  • check if network is working using `ping archlinux.org`
  • `timedatectl set-ntp true`
  • check what disk you need to format using `fdisk -l`
  • run `cfdisk <your-disk>`
    • choose `dos`
    • partition scheme - 2G swap, 23G /, 25G /home
    • mark root as bootable
    • /dev/vda1 - swap, /dev/vda2 - /, /dev/vda3 - /home
  • Formatting
    • `mkfs.ext4 -L ROOT /dev/vda2`
    • `mkfs.ext4 -L HOME /dev/vda3`
    • `mkswap -L SWAP /dev/vda1`
  • Mount
    • `mount /dev/vda2 /mnt`
    • `mkdir -p /mnt/home`
    • `mount /dev/vda3 /mnt/home`
    • `swapon /dev/vda1`
  • Installation process
    • `pacstrap /mnt base linux linux-firmware`
    • `genfstab -U /mnt >> /mnt/etc/fstab`
    • `arch-chroot /mnt`
    • `ln -sf /usr/share/zoneinfo/UTC /etc/localtime`
    • `hwclock --systohc`
    • install editor (for example: `pacman -S vim`)
    • edit /etc/locale.gen and uncomment `en_US.UTF-8 UTF-8`
    • `locale-gen`
    • Create /etc/locale.conf and insert `LANG=en_US.UTF-8`
    • Create /etc/hostname and insert hostname
    • set root password using `passwd`
  • Bootloader
    • `pacman -S syslinux`
    • `syslinux-install_update -i -a -m`
    • Fix /boot/syslinux/syslinux.cfg
      • in lines with `APPEND` change `root=/dev/sdaX` to `root=<your-root-partition>`
      • in the end of `APPEND` lines add `console=ttyS0,115200`
      • you should fix it for both: and for `arch` section, and for `archfallback` section
  • End of basic install
    • exit from chroot
    • `umount -R /mnt`
    • `poweroff`
  • Now boot your vm and connect to serial console using `vmctl start -c <vm-name>`
  • Fix networking
    • Create file /etc/systemd/network/20-wired.network and add this to it: [Match] Name=enp0s2
      [Network] Address=<ipv4-addr> Gateway=<gateway-ipv4-addr> Address=<ipv6-addr> Gateway=<gateway-ipv6-addr>
    • `systemctl enable systemd-networkd`
    • `systemctl start systemd-networkd`
    • Fix /etc/resolv.conf
      • Add `nameserver <gateway-ipv4-addr>`
  • Update your system using `pacman -Syu`
  • Add your own user and add it to wheel group
    • `useradd -m -G wheel <username>`
  • Install and configure sudo
    • `pacman -S sudo`
    • Edit /etc/sudoers
      • Uncomment line this line `%wheel ALL=(ALL:ALL) ALL` or this `%wheel ALL=(ALL:ALL) NOPASSWD: ALL`, if you want to allow sudo without password
  • Setup sshd
    • `pacman -S openssh`
    • Edit /etc/sshd/sshd\_config
      • Change PasswordAuthentication` field to no`
      • Change PermitRootLogin` field to `no`
      • Change PubkeyAuthentication` field to `yes`
    • Make in your user's home dir folder .ssh with 700 permissions
      • `mkdir -m 700 /home/<your-user-home-dir>/.ssh`
    • Add your public key to <your-user-home-dir>/.ssh/authorized_keys
    • `systemctl enable sshd`
    • `systemctl start sshd`
    • Try to connect to your server using ssh with key
  • It is recommended to `poweroff` your VPS and turn it on using `vmctl start <vm-name>` (maybe you will need to wait around 30 seconds or more)
  • If you having some issues with connecting, try to connect to serial console using `vmctl console <vm-name>`