Proxmox: Quickly Building Arch Linux Containers

Proxmox: Quickly Building Arch Linux Containers

Summary

I've typically used Ubuntu containers in Proxmox, but have recently started spinning up Arch Linux containers due to the low resource requirements. This is more internal documentation on building them so I don't need to reference it later. There seems to be a nuance with Proxmox and Arch Linux where it needs to be an unprivileged container for networking to "just work" at boot.

Please note this is for an internal lab and isn't designed to be Internet-facing.

Setup

Uncomment the mirrors for your region, initialize and populate the keyring, and update everything to the latest:

vi /etc/pacman.d/mirrorlist

pacman-key --init
pacman-key --populate archlinux
pacman -Sy gnupg archlinux-keyring
pacman-key --refresh-keys
pacman -Syu

Configure the timezone:

ln -sf /usr/share/zoneinfo/Region/City /etc/localtime

# For example:
# ln -fs /usr/share/zoneinfo/America/Detroit /etc/localtime

Set the language:

echo "LC_ALL=en_US.UTF-8" >> /etc/environment
echo "en_US.UTF-8 UTF-8" >> /etc/locale.gen
echo "LANG=en_US.UTF-8" >> /etc/locale.conf
locale-gen en_US.UTF-8

Enable SSH:

systemctl enable sshd
systemctl start sshd

Create a user:

useradd -m -G wheel -s /bin/bash username
passwd username

# For example:
# useradd -m -G wheel -s /bin/bash nlabadie
# passwd nlabadie

Install a bunch of packages. YMMV depending on your requirements:

pacman -S pacman-contrib base-devel sudo neovim bash-completion git nmap tcpdump mlocate bind-tools tmux zsh

Add the user you'd created above to the sudoers file:

visudo

# I typically uncomment this line.
%wheel ALL=(ALL) NOPASSWD: ALL

Install paru for the AUR packages:

# Switch to the user you'd created above.
# e.g. su - nlabadie

su - username
git clone https://aur.archlinux.org/paru.git
cd paru
makepkg -si

Install the symlinks for neovim:

paru -S neovim-symlinks

Fix a few items with the Arch template:

# If it's an unprivileged container. 
setcap cap_net_raw+p /bin/ping

Install zsh and a bunch of plugins. Full instructions are available here:

Configuring ZSH
This is a quick and easy guide for installing ZSH on Ubuntu, setting up a basic configuration, and enabling it as your default shell.

Conclusion

You should have a light-weight Arch Linux LXC at this point. Hope this helps!

Show Comments