<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Paulo Carvalho</title>
    <description>The latest articles on DEV Community by Paulo Carvalho (@thepaulo).</description>
    <link>https://dev.to/thepaulo</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2926626%2Fc7b11a25-2f1a-4672-b744-c5445fb0d2c7.jpg</url>
      <title>DEV Community: Paulo Carvalho</title>
      <link>https://dev.to/thepaulo</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/thepaulo"/>
    <language>en</language>
    <item>
      <title>Create an Ubuntu 24.04 Template with Cloud-Init on Proxmox</title>
      <dc:creator>Paulo Carvalho</dc:creator>
      <pubDate>Sun, 09 Mar 2025 20:24:17 +0000</pubDate>
      <link>https://dev.to/thepaulo/create-an-ubuntu-2404-template-with-cloud-init-on-proxmox-5f52</link>
      <guid>https://dev.to/thepaulo/create-an-ubuntu-2404-template-with-cloud-init-on-proxmox-5f52</guid>
      <description>&lt;p&gt;In this tutorial, we will go over the steps required to create an Ubuntu 24.04 template in Proxmox and instantiate a VM based on it.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 0: Proxmox Shell Access
&lt;/h2&gt;

&lt;p&gt;All Proxmox commands referenced in this article should be run in the proxmox shell.&lt;/p&gt;

&lt;p&gt;To access the shell select the xterm.js option from the dropdown in the desired node as shown in the image below.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1: Download Ubuntu Image
&lt;/h2&gt;

&lt;p&gt;We will use the Ubuntu image provided in the Ubuntu Cloud Images directory here. Specifically, we will select the latest available Ubuntu cloud release version.&lt;/p&gt;

&lt;p&gt;There are two approaches to download the image. Either run the below command in the Proxmox Shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;wget -P /var/lib/vz/template/iso/ https://cloud-images.ubuntu.com/daily/server/releases/24.04/release/ubuntu-24.04-server-cloudimg-amd64.img
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or download via the GUI as shown below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxlhldkypd69h8u52uuxe.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxlhldkypd69h8u52uuxe.png" alt="GUI approach to uploading an OS image" width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 2: Create the Base VM
&lt;/h2&gt;

&lt;p&gt;The base VM is a virtual machine we will be converting into a template.&lt;/p&gt;

&lt;p&gt;The easiest way to create it is to run the below command in the Proxmox shell:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qm create 9000 --name "ubuntu-24.04-cloud-init-template" --memory 2048 --cores 2 --net0 virtio,bridge=vmbr1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A few notes on the above command:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;9000&lt;/code&gt; - Is the unique identifier of your VM. If you haven't been managing this before, your first VM has likely been assigned an ID of 100 and each successive VM increments by 1. Some users prefer to organize the IDs in a way that groups VMs. 9000 is a high enough number such this VM is separated from the default ones.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--name&lt;/code&gt; - Name of the virtual machine&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--memory&lt;/code&gt; - Amount of RAM in megabytes.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--cores&lt;/code&gt; - Number of CPU cores.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;--net0&lt;/code&gt; - Network card configuration (uses virtio with bridge vmbr1). Depending on your specific configuration you would likely be using vmbr0 or vmbr1. In my case, it's the latter since I use vmbr1 for my private subnet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 3: Assign Required Hardware to Base VM
&lt;/h2&gt;

&lt;p&gt;In order for the base VM to work, we need to assign it some hardware.&lt;/p&gt;

&lt;p&gt;The first one is a disk containing the image we downloaded previously:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qm importdisk 9000 /var/lib/vz/template/iso/ubuntu-24.04-server-cloudimg-amd64.img local-lvm
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will create a disk for VM with ID 9000 using the downloaded image and placed in the local-lvm storage. If you are using a different type of storage, adjust accordingly.&lt;/p&gt;

&lt;p&gt;We will then configure this storage to be of the desired type and assign it as a boot volume:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qm set 9000 --scsihw virtio-scsi-pci --scsi0 local-lvm:vm-9000-disk-0
qm set 9000 --boot c --bootdisk scsi0
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Finally, we will create a cloud-disk storage so that Proxmox cloud-init configuration can be read by the VM:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qm set 9000 --ide2 local-lvm:cloudinit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 4: Configure Cloud-Init
&lt;/h2&gt;

&lt;p&gt;Cloud-init is a useful tool to configure VM parameters safely such as the password of a new VM instance.&lt;/p&gt;

&lt;p&gt;To configure the desired values, you can run the following commands:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qm set 9000 --ipconfig0 ip=dhcp
qm set 9000 --ciuser ubuntu --cipassword 'your-favorite_password'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or you can set them directly via the Proxmox web interface as shown in the image below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk8rhj2rekptdtw1yday.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuk8rhj2rekptdtw1yday.png" alt="GUI to setup cloud-init config" width="800" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 5: Convert to Template
&lt;/h2&gt;

&lt;p&gt;In order to create new VMs from our current VM we should transform it into a template with the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qm template 9000
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Step 6: Create a VM from the Temple
&lt;/h2&gt;

&lt;p&gt;We can now use the previously created template (ID 9000) to create any number of new VMs with the command below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qm clone 9000 201 --name "new-ubuntu-vm"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;201&lt;/code&gt; is the ID of the new VM.&lt;/p&gt;

&lt;h2&gt;
  
  
  Optional: Resize VM Disk Size
&lt;/h2&gt;

&lt;p&gt;Note that the VM disk is currently somewhere between 3–4GB since it defaulted from the original disk image size. We can increase by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;qm resize 201 scsi0 +10G
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will increase the disk size by 10GB for the newly created VM of ID 201.&lt;/p&gt;

&lt;p&gt;However, resizing in Proxmox does not mean the VM OS will automatically use the increased volume size. For that, access the VM via the console option (or SSH) and run the following commands (NOTE: These command should be run in the VM shell NOT the Proxmox shell):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;sudo su
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The above command will change your session from ubuntu user to root user. You can then run the &lt;code&gt;df&lt;/code&gt; command to see the partitions you currently have and their size. It should look something like the image below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe8wt7y4t120l91yw5u7r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe8wt7y4t120l91yw5u7r.png" alt="Result of command in CLI" width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can then run the below command to manage the partition:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;parted /dev/sda
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The output should look something like the screenshot below:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fufni0aghylfk52ffnrjw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fufni0aghylfk52ffnrjw.png" alt="Result of command in CLI" width="800" height="372"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can then resize the sda1 partition by running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;resizepart 1 100%
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0aqeau5efcbzhyld4635.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0aqeau5efcbzhyld4635.png" alt="Results of running command in CLI" width="800" height="292"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;We have gone over the process of creating a Proxmox Ubuntu 24.04 template with cloud-init and created a VM from it.&lt;/p&gt;




&lt;p&gt;If you need help with this process or are looking to perform a more complex private/public cloud deployment visit our &lt;a href="https://avantsoft.com.br" rel="noopener noreferrer"&gt;website&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>devops</category>
      <category>selfhosted</category>
      <category>proxmox</category>
    </item>
  </channel>
</rss>
