Create Virtual Machine from a template

From Sea of Fate
Revision as of 06:21, 13 March 2025 by Sailor (talk | contribs) (Created page with "==Introduction== This is not a deep dive in to ansible or similar but a simple quick and dirty guide to creating a new VM from a template and configuring some of the networking with cloud init. ==qm clone== To create a new host from your template with the specified IP address, gateway, DNS server, and search domain, you can use the Proxmox command-line interface (CLI) with the qm clone command and appropriate Cloud-Init parameters. Here's how you can do it: Using t...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Introduction

This is not a deep dive in to ansible or similar but a simple quick and dirty guide to creating a new VM from a template and configuring some of the networking with cloud init.


qm clone

To create a new host from your template with the specified IP address, gateway, DNS server, and search domain, you can use the Proxmox command-line interface (CLI) with the qm clone command and appropriate Cloud-Init parameters.

Here's how you can do it:

Using the qm clone Command:

Bash

qm clone <template_vmid> <new_vmid> --name <new_hostname> --ipconfig0 "ip=192.168.100.26/24,gw=192.168.100.1" --nameserver 192.168.110.11 --searchdomain seaoffate.local Explanation:

qm clone <template_vmid> <new_vmid>: This is the base command to clone a VM. Replace <template_vmid> with the ID of your template VM. Replace <new_vmid> with the desired ID for the new VM. --name <new_hostname>: Replace <new_hostname> with the desired hostname for the new VM. --ipconfig0 "ip=192.168.100.26/24,gw=192.168.100.1": This sets the IPv4 configuration for the first network interface (eth0 or similar). ip=192.168.100.26/24 sets the IP address and netmask. gw=192.168.100.1 sets the gateway address. --nameserver 192.168.110.11: This sets the DNS server address. --searchdomain seaoffate.local: This sets the search domain. Example:

If your template VM ID is 100, and you want to create a new VM with ID 101 and hostname "newhost," the command would be:

Bash

qm clone 100 101 --name newhost --ipconfig0 "ip=192.168.100.26/24,gw=192.168.100.1" --nameserver 192.168.110.11 --searchdomain seaoffate.local Important Notes:

Cloud-Init: This command assumes that your template VM has Cloud-Init installed and configured. Network Interface Name: The network interface name might vary. If your VM uses a different interface name (e.g., ens3), you might need to adjust the Cloud-Init configuration accordingly. Testing: After creating the new VM, verify that the IP address, gateway, DNS server, and search domain are correctly configured. Proxmox User Permissions: The user running this command must have sufficient permissions to create VMs. Firewall: Ensure that your firewall allows network traffic to and from the new VM. DHCP: Make sure that the IP address does not conflict with any IP addresses assigned by a DHCP server. By using this command, you can easily create new VMs from your template with the desired network configuration.