Creating a Virtual Machine Template
If you're running a homelab or managing a virtualized infrastructure with Proxmox VE, using templates to spin up virtual machines can drastically save time needing new instances. In this guide, I'll show you how to create a RockyLinux template on Proxmox so you can deploy a clean, updated Rocky instances in minute decreasing configuration time when trying new services on your network.
Creating a VM Template
Resources used:
ProxMox QEMU/KVM Virtual Machines Documentation
Download the Rocky Linux ISO
First we will need a ISO to upload to our hypervisor.
Upload them to your ProxMox storage configured to store ISOs.
Create a New VM
Lets create the Virtual Machine that we will convert to a template. Click on the "Create VM" button in the top-right corner of you web dashboard to start creating a new Virtual Machine.
You will be prompted to create a name, VM ID, and which node to deploy your Virtual Machine on. I typically give my Virtual Machine with a really high VM ID so that they appear at the bottom of my Datacenter View pane to easily distinguish my VMs from templates. You can change the VM ID of a template only while it is a Virtual Machine and NOT a template.
VM ID: 965
Name: rocky
In the "Use CD/DVD disc image file (iso)" select the storage colume name of where the ISO is stored and click inside the ISO image field to view and select the ISO image. Click "Next"
In the "System" section you can specify your virtualized computer configurations like:
- Graphics
- Machine types
- Virtualized BIOS
- Specify SCSI controller
- Add TPM functionality
- QEMU to be able to handle power functions if you have a QEMU agent installed.
You may leave these at defaults if you have no specific usage for them or starting out building a Virtual Machine for the first time. You can change these for cloned VMs as well. Click "Next".
On the "Disks" section specify which volume you want to create the virtual hard drive for the machine and select the size for the template. I typically launch new VMs for seperate services to tinker with so I typically do not need to provision large volumes for my Virtual Machines. I recommend 32 GB, since you will need to expand the volume for the machine if you need more.
For "CPU", "Memory", and "Network" I go with low sizes and my default network bridge to the Internet (to retrieve and install updates).
CPU: 1 thread
Memory: 2048MiB
Bridge: <Default Internet Bridge>, No VLAN
NOTE: Your CPU type will be dependent on your hypervisor's hardware and will SIGNIFICANTLY impact performance, and compatibility with hardware features.
ProxMox Documentation for CPU Types
On the "Confirm" section, review the values for creating this new virtual machine which will be the base of our template. Click "Finish" after verifying the key values are correct and you are ready to launch the Virtual Machine.
Install Rocky Linux
- Right-click on the Virtual Machine you just created from the Datacenter View pane.
- Click Start
- Double-click the Virtual Machine to launch and remote into the Virtual Machine in a new window.
Create a default username and password. Please take note of this since we will use this every time to deploy a Virtual Machine. We will go over how to remove this user once we deploy new VMs from this template later in this article.
Prep the VM for Templating
Update the system so we use less bandwidth and time when launching new updates to have an updated template. You will likely want to replace the template every few months to continue to benefit from an updated template, reducing update time post-cloning.
sudo dnf update
sudo dnf upgrade
When completed reboot the system to apply changes
sudo reboot
When it successfully reboots and applys changes, we will the power off the Virtual Machine to then convert it to a template.
sudo poweroff
Convert your VM to a Template
From your ProxMox's terminal perform the following command:
qm template <VMID>
OR
Right-click your Virtual Machine in the Datacenter View pane, and click on "Covert to a template".
Deploy New RockyLinux VMs
- Right-click the template, then click "Clone".
- Choose "Full Clone" or "Linked Clone" (I prefer full clone, will take longer write but has performance benefits).
- Name your new VM, and adjust settings as needed.
- Import SSH keys.
- Remote in via SSH.
- Create new user, and a new password
- Remove default admin username created during templating.
Comments
Post a Comment