BMX - Generic VM Template
Setup
Update Host
apt update
Install sudo:
apt install sudo
Add a user:
usermod -aG sudo yourusername
Add user to sudoers:
As root, open /etc/sudoers.
Add this entry to the bottom:
yourusername ALL=(ALL:ALL) ALL
Package Install
Update the base image:
sudo apt update
sudo apt upgrade -y
Install core admin and networking tools:
sudo apt install -y \
openssh-server sudo ca-certificates curl wget gnupg lsb-release \
nano vim less bash-completion locales tzdata \
iproute2 net-tools dnsutils iputils-ping traceroute tcpdump nmap netcat-openbsd \
htop iotop lsof psmisc strace procps sysstat \
jq tree file unzip zip tar rsync dos2unix \
apache2-utils openssl \
chrony \
git make build-essential python3 python3-pip python3-venv \
nfs-common cifs-utils \
parted gdisk smartmontools acl \
tmux screen ncdu \
sqlite3
Install network tools:
sudo apt install -y mtr-tiny socat
Install certificate debugging tools:
sudo apt install -y ssl-cert
Install http API debugging tools:
sudo apt install -y httpie
Install process debugging tools:
sudo apt install -y dstat
Install NGINX
sudo apt install -y nginx
sudo systemctl enable nginx
sudo systemctl start nginx
Install Docker
First remove conflicting packages:
sudo apt remove -y docker.io docker-doc docker-compose podman-docker containerd runc || true
Add Docker repo and key:
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/debian/gpg | \
sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] \
https://download.docker.com/linux/debian \
$(. /etc/os-release && echo $VERSION_CODENAME) stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
Install Docker:
sudo apt update
sudo apt install -y \
docker-ce docker-ce-cli containerd.io \
docker-buildx-plugin docker-compose-plugin
Enable Docker:
sudo systemctl enable docker
sudo systemctl start docker
Allow user to run Docker without sudo:
sudo usermod -aG docker $USER
Add offline package management for Docker:
sudo apt install -y dpkg-dev
.NET Runtime
This requires a couple steps.
Do this, first:
wget https://packages.microsoft.com/config/debian/13/packages-microsoft-prod.deb -O packages-microsoft-prod.deb
sudo dpkg -i packages-microsoft-prod.deb
rm packages-microsoft-prod.deb
sudo apt update
Install the runtime:
sudo apt install -y dotnet-runtime-8.0
Install the aspnet runtime:
sudo apt install -y aspnetcore-runtime-8.0
Install the .NET sdk:
sudo apt install -y dotnet-sdk-8.0
Verify the installed version:
dotnet --info
Have it list the runtimes, as well:
dotnet --list-runtimes
Do a quick hello world, to test the runtime.
mkdir ./dotnet-test && cd ./dotnet-test
dotnet new console
dotnet run
Cleanup
sudo apt autoremove --purge -y
sudo apt clean
sudo rm -rf /var/lib/apt/lists/*
sudo journalctl --vacuum-time=1d
sudo rm -rf /tmp/* /var/tmp/*
Validation Checks
systemctl status nginx
systemctl status docker
docker run hello-world
Template Reset Script
The template VM has a reset script installed at: /etc/template/reset.sh.
Run it each time you shutdown the template VM, to reset needed info, for cloning.
It can be executed with this:
sudo /etc/template/reset.sh
The script contents are here: Template VM Reset Script
Zero Out Free Space
To make the VM smaller, this needs to be done.
sudo dd if=/dev/zero of=/EMPTY bs=1M status=progress || true
sudo rm /EMPTY
sync