Creating Your Own ProxCP KVM Templates
From ProxCP Documentation
This tutorial covers how to create a custom KVM template for use with ProxCP and Proxmox.
Required: at least 1 Proxmox node
Assumption: The desired operating system ISO is already downloaded onto your Proxmox node.
The commands covered here are relevant to Debian and RHEL-based operating systems however the process can be applied to any other operating system.
Contents
Create VM
- Create a new VM in Proxmox with the following settings:
- VMID: anything
- Name: operating system description (i.e. centos-8-amd64)
- OS: your chosen ISO image
- Hard Disk: use VirtIO SCSI (scsi0) with 10GB storage and no caching
- CPU & Memory: 1 kvm64 CPU core, 1GB memory
- Network: VirtIO (virtio0), vmbr0 bridge, no firewall
- After creation, go to the Hardware tab and delete the CDROM ISO. Add a cloud-init drive on ide2. Add the CDROM ISO back as ide0.
Base OS
- Boot the new VM and complete the base operating system installation. Generally, templates should use most default settings and minimal packages. There are a few things to keep in mind during installation:
- Partitions: create 1 ext4 root "/" partition (no LVM, no SWAP)
- Networking: use a generic hostname (i.e. localhost or centos-8-amd64)
- Packages: use minimal packages, however the OpenSSH server is required
OS Setup Stage 1
- Once the base OS installation is complete, shutdown the VM
- In Proxmox, go to Options and set the boot order to scsi0 only (1 option)
- Go to the Hardware tab and remove the ide0 CDROM. Verify the network device is net0 using vmbr0 bridge
- Power on the VM
- Login as root
- If you created a user during installation, remove that user with
deluser [username] && rm -rf /home/[username]
- Complete updates
apt update && apt upgrade && apt install setserial
oryum update && yum install setserial
Serial Console Setup
KVM templates have to be configured to use a serial console for noVNC access.
- Edit the
/etc/default/grub
file:- Add or replace
GRUB_CMDLINE_LINUX='quiet console=tty0 console=ttyS0,115200' GRUB_TERMINAL=serial GRUB_SERIAL_COMMAND="serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1"
- Save the file
- Run
update-grub
(debian/ubuntu) orgrub2-mkconfig -o /boot/grub2/grub.cfg
(centos/rhel) - Run
cat /etc/securetty | grep ttyS0
and ensure ttyS0 is in /etc/securetty. This file may not exist which is okay.
If you are creating a template for a newer operating system using "systemd":
- Run
systemctl enable serial-getty@ttyS0.service && systemctl start serial-getty@ttyS0.service
Next:
- Shutdown the VM
shutdown -h now
- In Proxmox go to the Hardware tab and add a Serial Port (serial0) then set the Display to Serial Terminal 0 (serial0)
- Start the VM
OS Setup Stage 2
- Login as root
- Edit
/etc/ssh/sshd_config
and ensurePort is 22
andPermitRootLogin is yes
- It is best to uncomment these lines to explicitly declare these settings
- Install any other software you want to include in this template
- Some good examples to include: htop bmon zip unzip wget nano curl ethtool net-tools
- Confirm with
fdisk -l
that there are no other disk partitions after root "/"
Cloud-init
- Install cloud-init:
- Debian/Ubuntu:
apt install cloud-init cloud-initramfs-growroot cloud-guest-utils xfsprogs gdisk
- CentOS/RHEL:
yum install cloud-init cloud-utils-growpart cloud-guest-utils xfsprogs libicu gdisk
- Debian/Ubuntu:
- Proxmox requires cloud-init 18.2 or newer
cloud-init --version