According to "the internet" you can install the qemu-agent running a command directly on the image previous the the qm importdisk command. Which is this "virt-customize -a ubuntu-22.04-minimal-cloudimg-amd64.qcow2 --install qemu-guest-agent". I tried myself and it worked fine. This way the template already have the qemu-agent and you don't need to install it in every new deployed VM.
i watched the whole video expecting Jay to mention that , but he did it manually still, the comment gave me enough insurance to try it myself tho , thanks!
Note that this will result in a /etc/machine-id file being generated on that disk image. If it isn't removed, every machine you create by cloning it is going to get the same IP via DHCP, which will cause problems on your network.
Thanks Jay!! As a Linux noob (I am a Windows Server guy) and new to Proxmox, the way you teach, the tranquility you radiate, its awesome and helps me a lot. many many thanks!
Absolutely agree. I've been in tech for over 35 years. Did hardware and Windows admin for quite a while and then moved over to cloud and software development. I'm now diving into Home Lab stuff and Proxmox, so it's finally time to drive my skills up in the Linux space. I love Jay's content.
Hello Jay! It's rare to find someone who explains things in a simple way and also describe the 'why'. It helps engrave the learning process when you do something a certain way, there's a reason for it. Great job!
Great and easy steps. Now Imagine an automated process for creating and provisioning this clone with Ansible or similar. This will be an awesome tutorial. Nice work Jay.
As always another awesome video, thanks Jay!!! I am in the process of moving back to Proxmox from XCP-ng/Xen-Orchestra, so I am re-watching this entire series again. I have found that Proxmox is easier to get around in. In the step where you import the disk into the template, I have found that if you are using NFS it will import it as RAW file instead of QCOW2. If a person wants to stick with QCOW2 then just add the switch "--format qcow2" at the end of the command.
Discovered LLtv just a few days ago and I really love and enjoyed every video I watched so far. In fact the Proxmox series is the reason I ordered a miniPC to play with. Great job Jay!!!!
I did and liked your whole proxmox course when you would release each module/video in parts. I followed along all the way to adding another node for clustering, but I couldn't get it to work. I also screwed up SSD trying. No problem. I reinstalled proxmox again today and did this module. It's the starting point for your Kubernetes cluster install on proxmox video!
QCOW2 format provides more advanced features than IMG, such as copy-on-write, snapshots, compression, and encryption. The format is more flexible and can grow dynamically, whereas a plain ".img" file that must be preallocated to its maximum size. Further, the qcow2 format provides better performance, as it avoids the overhead of updating an entire ".img" file whenever a small change is made to a virtual disk.
the reason why you have to add a Cloudinit Drive CD-ROM to vm is because the custom cloud-init config will be "burned" to this CD-ROM, so when the attached vm is being started, the cloud-init inside of it can detect the corresponding filesystem (with fs label `cidata` and fs type `iso9660`) the CD-ROM provides, you can observe the `mount and umount of /dev/sr0 (which is cloud-init drive CD-ROM)` behaviour within /var/log/cloud-init.log, hopefully this helps!
Thanks Jay! I was able to apply these same instructions to setting up a template for Rocky 9 using the generic-cloud/openstack images. worked on the 1st try.
The major thing missing from this is how to customize the Ubuntu image prior to converting it to a template. That’s the reason many people would use a template to begin with.
I haven't dabbled with Linux in a while so it's been a long time since I've checked out the channel, however I really wanted to say that beard looks great on you.
That would be handy to make changes to said template. I would love to be able to add my own packages and still use cloudinit... Now I need to try that. :)
To all the folks you suffer SSH not available once they spin up the VMs from the template. Please run the following command in the proxmox console of all the VMs you created from the template. This will solve your SSH problem. sudo dpkg-reconfigure openssh-server
I would like to add a little to one of the posts here in the comments, a few necessary first steps with the system image: 1. virt-customize -a yaimage.img --install qemu-guest-agent 2. virt-customize -a yaimage.img --run-command "sudo echo > /etc/machine-id; sudo ln -sf /etc/machine-id /var/lib/dbus/machine-id" ...and what I do also: 3. virt-customize -a yaimage.img --root-password password:yourpass - set root password 4. virt-customize -a yaimage.img --timezone "Europe/Kiev" - set ya time zone 5. virt-customize -a yaimage.img --install - install some packages, for example qemu-guest-agent 6. virt-edit yaimage.img /etc/cloud/cloud.cfg - system setup, for example enable root 7. virt-edit yaimage.img /etc/ssh/sshd_config - ssh setup, for example enable password authentication and etc... Wsup!
Am i the only one that struggles with cloud-init in Proxmox? I got it to work with OpenSuse Leap 15 sp3 but no luck with Ubuntu 20.04 or 22.04, (i use Proxmox 6.4.8). Any suggestions?
Hello Jay, first i want to thank You for great tutorial. But always when i setup template and using cloud-init from Proxmox (without configuring SSH public key option) i have problem to login to VM (created from template) via ssh - Permission denied (publickey) . Can you give me some advise how to do it? Many thanks.
Hey Jay. I love this video. The idea of just grabbing a live image rather than having to do an install each time I want a new image type is very appealing. I have one question though. Having gone through some of your previous videos, I've created a custom cloud-int cloud.cfg file for a few use cases. Is there a relatively simple way to use the specific file I've created without having to spin up the new template, replace the existing file, and then clean it up before turning into a template?
Great video Jay! Thanks :) i am trying to create Ubuntu 22.04 Template but i don't understand when you add the ssh key to it . i mean where you get the ssh key ? Thanks
Hello Jay, Thanks for the video and your work. The question I have is does the template take those resources from the host and reserve them making them part of the used resources on host? I am sure the answer is yes, but I had to ask. Thanks again.
Set up with network storage by adjusting the command like 'qm importdisk 900 ubuntu-22.04.qcow2 nfsstorage' - the disk showed up as a '.raw' format but still worked flawlessly.
I appreciate your youtube videos, and the way you explain. Looking at the video I found that you have more Bridges for different purposes. On the internet it is not explained clearly how to route traffic between these bridges to have the machines encapsulated under one bridge. There are some examples with NAT. Also is possible to do with VLANS instead of bridges but also is not clear. If you have time, it will be nice to cover this theme, because there is very little info on the net. Thank you very much.
I got up to the point of logging in, but authentication keeps failing on the credentials I installed in CloudInit. I'm seeing “Failed to start Execute cloud user/final scripts.” and wondering if that's the issue?
Wow. This was amazing. Jay, when you create these templates, every New vm from The same template will have different Host Keys (ssh) and Mac Address, or they will be idênticas to the template?
Hello Jay, Really love your videos. Just wanted to know how to install 'qemu-guest-agent' (or any other package) in the template itself so we don't have to install it in each VM cloned from that template?
Great video as usual. Only question is what is the advantage over the traditional downloading the iso, building a VM, install what I need, seal it and create a template? Are you just demonstrating a new way of creating a template or a better way? After following your procedures I was missing many packages (vi, vim) that I would need to install manually whenever using this template.
I believe you'll find that the cloud-init image is an actual bootable Ubuntu disk image so most of the slow installation process is skipped. (Ex. no probing the hardware. no disk formating. no downloads. no installs. almost no config.) The "cloud-init" portion of what is in that bootable image will clean up a few things upon first boot. You can watch other videos about what cloud init is and how it works on first-boot and not on second boot.
Nice video! Covered the basics. Now going to more advanced question: How to create customized template? Lets say I want to have a template with the qemu-guest-agent already installed instead of me going to the server and installing it manually, then how to proceed?
I've tried to follow this guide but have ran into 2 caveats: Cloud init just wasn't executed for VMs of type q35. Switching it in the template worked and cloud-init seemed to work, at least I got cloud-init related output in the console after starting up a fresh clone. But when I want to login it doesn't accept the user and password combination set in cloud-init. Any hints?
Perfect explanation. Can I install qemu agent on template itself ? Can I regenerate cloud image on new template based machine to have different user name Can templates also be backed up to PBS .
11:30 or just read the manual 12:22 no need, you can 'qm set 900 --scsi0 local-lvm:0,import-from=/root/ubuntu-22.04-minimal-cloudimg-amd64.img' and resize via GUI later.
Thanks for a great tutorial! Just a comment: I've replaced image with [/jammy/current/jammy-server-cloudimg-amd64.img] and default console works fine, no need to add serial.
13:00 qemu can use qcow2 or raw filesystem images. With Raw there's now way for qemu to determine it's actually format because there's not file header say "This is disk image" it just has to guess. (A raw file image could be completely blank). If you pass raw direclty to qemu it'll give a warning say you should use the format=raw option to avoid issues. With the file extension qemu assumes it's a qcow2 image. It could guess based on filestrcture if it's qcow2 file anyway, it's very unlinkly it could be a raw image with data that looks like qcow2 anwyay.
Now that i've checked you can import without renaming the file like this (replacing VMID with your vm id and STORAGE with your image storage) qm disk import VMID ubuntu-22.04-minimal-cloudimg-amd64.img STORAGE --format qcow2
Hi, by using this method is it possible to directly install the qemu-agent + add my own script? and if can, which step should i install and add my script before creating the template?
Great video and helped me a lot. Question can i use the same method to build a Ubuntu desktop template, would i just use another image say "Cloud image for 64-bit computers (USB image)"
Hello, hope you're doing well. I want to try building an Ubuntu template with version 24.04. Are the steps the same, or are there any changes I should be aware of? Thanks for your video!
Seems that downside with this approach that installing custom things won't be part of the template? Such as the Qemu agent, and any other default packages you want setup in the template. Any way to solve that with this method, or follow the old video?
Today i have told my coleague to take a look at cloud init if you are going for templates, what a coinsidence. I have not noticed, was the secure boot option enabled?
Is there another step if I don't have an ssh public key? If i try to log on from powershell I get permission denied (public key). Any help would be greatly appreciated. :)
@examen1996 Yes, but if he is going to install Ubuntu as server it is more efficient to use LXC. If he was using it for things other than terminal apps them it would make sense to install to a VM. Maybe you can tell us an example of why using and Ubuntu server in a VM is better?
@@mhavock I've run into several dependencies issues when trying to run certain things in a container. For example, I have rport running just fine in a LXC container, but I couldn't get netbox running right. Same way with the Fedora container. I tried to do freeipa in it, didn't work.
Hello, when I create the clone'd machine it shows up as "Ubuntu" on my network. Why is that? The hostname and hosts file both read "gameserver" so I don't understand why my router can't assign it a normal name like when I create a regular VM straight through Proxmox with an ubuntu ISO.
Unfortunately this isn't working for me on Proxmox 7.2-11. The console isn't working on VM startup even though I executed the qm set command as shown (I only see "starting serial terminal on interface serial0). One of the CPU cores maxes out on the VM generated from the template, but it's inaccessible and never gets an IP, making it useless.
How to actually boot into the image and customize it/how to customize the steps cloud-init is doing a bit more? E.g. the default ssh-host-keys and sshd_config is geared towards compatability over security, but if I don't need to be backward compatible, how where could one define it so it generates stronger keys and sets my desired sshd_config? Or is that something that we'll have to keep using ansible for?
Hi, thanks for the video; at first, i tought a vm template would look like a DockerFile, so i can setup some stuff already, like "all my vms have python, nano, or whatever"; is something like that possible ?
I followed the steps to create a VM, but cannot SSH into it. Have tried cloud-init clean and dpkg-reconfigure openssl-server, but in vain. Is there any help here?
Same problem. Had to: edit the /etc/ssh/sshd_config file and change the following entries. Then later can configure properly ie to allow just key auth instead user #PermitRootLogin prohibit-password #PasswordAuthentication yes The above entries should be as shown below: PermitRootLogin yes PasswordAuthentication yes
thank very match. i have a question, about ssh-key. where is this ssh key? i don't put in the box. than i want to connect from (laptop 1), permission denied (publickey). i must put ssh-key inside the box, right? must i have ssh-keygen for each pc? please help, how do the best way.
Hi, thanks for this tutorial, I have one issue please if you could help, I have followed the same instruction but when I typed ip a to see the @ip, I dont see it, (I have choosed DHCP in cloud-init as you did), do you know please what could be the problem ?
without qemu guess agent i think we also able to shutdown ? hemm..what is actually the purpose? can u give tutorial to enlarge entire disk automatically?
Hello, a quick question to the community. I created a VM using the ubuntu.23.10.minimalist and I can't mount a cifs share. After a lot of research and no solutions I think it is the minimalist build that is the issue. I have installed cifs-utils and a bunch of other packages to no avail. I will most likely install the full server version in the next day or two, but want to know if anyone else had this issue? The actual error I get after I run the mount command and put in my password is: mount error: cifs filesystem not supported by the system mount error(19): No such device
I have a few problems with that method 1. SSH will not work, unless you reboot the VM after the 1st boot 2. All ProxMox (7.2-3) commands related to the VM = Stop, Reboot, Shutdown are not working. You will need to type all these in the VM itself to have it to work, which is... a pain
After downloading the image at 10:26 : (solves for 2.) virt-customize -a ubuntu-22.04-minimal-cloudimg-amd64.img --install qemu-guest-agent (solves for 1.) virt-customize -a ubuntu-22.04-minimal-cloudimg-amd64.img --run-command "sudo echo > /etc/machine-id; sudo ln -sf /etc/machine-id /var/lib/dbus/machine-id" Then rename the image to qcow2 etc
@@fanuchman Thanks for this. I already have it setup as per the video steps. Do I need to blow that away and start from scratch and add your two commands to the image or can I do this with my image already modified and renamed as per the steps in the video with my template created?
Anyone else having troubles running docker swarm on VMs created this way? More specifically: trouble accessing services (stacks) deploy on docker swarm? Problem seems specifically for docker swarm: I can publish services using "docker compose" without a problem, but when deploying the same configuration in docker swarm mode, the service isn't accessible (logs show that it is running correctly). Deploying those very same services on a VM installed in the 'classic' way works without any problems. Have been scratching my head for 2 days on this problem now, starting to go bald here :(
Linux n00bie. I've tried this 3 times and I always end up with vms that get stuck on "starting serial terminal on interface ". This doesn't happen all the time, the first time it was because of my network settings, but now it's just intermittent and I can't figure out why. Any pointers on where to look?
Thanks for this - very helpful - though my problem is that the machine-id of every clone of the image is the same --> cloud-init does not seem to reset this, so I get the same machine with the same dhcp ip address every time.
@@Ecker00 Yes, it ended up being simple, you just have to make sure you do not login at any stage. That seems to set it. You have to do all of the work creating the image and setting it up before first use.
@@stevegailey770 alright so delete the machine id, shutdown, convert to template, clone, clone, clone and then it will be regenerated on first boot/login.
@@Ecker00 virt-customize, virt-filesystems and qemu-img are your friends... Managed to find the commands I regularly use getting the image ready for first use...
Для этого перед созданием шаблона нужно запустить виртуалку, а тогда сразу запустится cloud init для настройки, и больше не получится сделать такую настройку под каждую клонированную виртуалку с помощью cloud init диска. Если нужно много всего поставить, то можно вручную поставить систему, а потом подготовить её для конвертации в шаблон. На этом канале есть урок. Но мне больше понравился этот способ, потому что получается меньше ненужного говна в шаблоне. Единственное, с чем пока не разобрался - это как в самом шаблоне разрешить ssh аутентификацию по паролю, а не по ключу. После каждого клонирования лень редактировать sshd_config
@@kolyacpp Не обязательно, можно через команду: qemu-img resize ubuntu-20.04.img 32G сразу увеличить и потом: virt-customize -a ubuntu-20.04.img --install qemu-guest-agent. Работает на ура
@@MrPDC-jr5yl Круто! Я погуглил, у этой штуки есть ещё --run-command. По идее можно запустить команду, которая отредактирует PasswordAuthentication в sshd_confing. Но если openssh ставится с помощью cloud-init, то этого файла там ещё не будет. Как костыль можно добавить это в греп) и потом туда костыль, чтобы почистить греп, когда замена удастся)
"it is what it is" bruhhh i had been wondering for a while why my command wouldnt execute even thought i was doing the same as the tutorial i was looking at the time lol
According to "the internet" you can install the qemu-agent running a command directly on the image previous the the qm importdisk command. Which is this "virt-customize -a ubuntu-22.04-minimal-cloudimg-amd64.qcow2 --install qemu-guest-agent". I tried myself and it worked fine. This way the template already have the qemu-agent and you don't need to install it in every new deployed VM.
Fantastic tip 👍
i watched the whole video expecting Jay to mention that , but he did it manually still, the comment gave me enough insurance to try it myself tho , thanks!
For future note, I had to install tools for accessing and modifying virtual machine disk images with "apt-get install libguestfs-tools"
Note that this will result in a /etc/machine-id file being generated on that disk image. If it isn't removed, every machine you create by cloning it is going to get the same IP via DHCP, which will cause problems on your network.
@@danbrown586 how would I create an image with a custom set of tools installed without the issues of machines having same ID
Thanks Jay!!
As a Linux noob (I am a Windows Server guy) and new to Proxmox, the way you teach, the tranquility you radiate, its awesome and helps me a lot. many many thanks!
Absolutely agree. I've been in tech for over 35 years. Did hardware and Windows admin for quite a while and then moved over to cloud and software development. I'm now diving into Home Lab stuff and Proxmox, so it's finally time to drive my skills up in the Linux space. I love Jay's content.
Hello Jay! It's rare to find someone who explains things in a simple way and also describe the 'why'. It helps engrave the learning process when you do something a certain way, there's a reason for it. Great job!
Great and easy steps. Now Imagine an automated process for creating and provisioning this clone with Ansible or similar. This will be an awesome tutorial.
Nice work Jay.
As always another awesome video, thanks Jay!!! I am in the process of moving back to Proxmox from XCP-ng/Xen-Orchestra, so I am re-watching this entire series again. I have found that Proxmox is easier to get around in. In the step where you import the disk into the template, I have found that if you are using NFS it will import it as RAW file instead of QCOW2. If a person wants to stick with QCOW2 then just add the switch "--format qcow2" at the end of the command.
Thank you, I added the "--format qcow2" flag at the end of the import disk command, worked perfectly.
Discovered LLtv just a few days ago and I really love and enjoyed every video I watched so far. In fact the Proxmox series is the reason I ordered a miniPC to play with.
Great job Jay!!!!
I did and liked your whole proxmox course when you would release each module/video in parts. I followed along all the way to adding another node for clustering, but I couldn't get it to work. I also screwed up SSD trying. No problem. I reinstalled proxmox again today and did this module. It's the starting point for your Kubernetes cluster install on proxmox video!
Your videos are always so clear. Step-by-step. Very helpful. Very much appreciate the videos you produce on TH-cam!
much easier than your first video about templates. Thanks :D
QCOW2 format provides more advanced features than IMG, such as copy-on-write, snapshots, compression, and encryption. The format is more flexible and can grow dynamically, whereas a plain ".img" file that must be preallocated to its maximum size. Further, the qcow2 format provides better performance, as it avoids the overhead of updating an entire ".img" file whenever a small change is made to a virtual disk.
the reason why you have to add a Cloudinit Drive CD-ROM to vm is because the custom cloud-init config will be "burned" to this CD-ROM, so when the attached vm is being started, the cloud-init inside of it can detect the corresponding filesystem (with fs label `cidata` and fs type `iso9660`) the CD-ROM provides, you can observe the `mount and umount of /dev/sr0 (which is cloud-init drive CD-ROM)` behaviour within /var/log/cloud-init.log, hopefully this helps!
This is literally the best guidance and so well delivered. Definitely like and subscribe!
WOW! Thank you, other sites make this process seem so complicated, but your video got me going in minutes, Thank you!!!!
Great work, Jay. you can't make it easier than this. Thanks for the excellent work.
Thanks Jay! I was able to apply these same instructions to setting up a template for Rocky 9 using the generic-cloud/openstack images. worked on the 1st try.
this is cleaner than the 20.04 tutorial. Thank you so much
Great video, and exactly what I needed to generate an efficient Ubuntu template for my ProxMox VMs. Thanks a bunch !
For those that want to use machine q35 use the following command to change the cloudinit from ide2 to scsi
qm set {VMID} --scsi1 local-lvm:cloudinit
Thanks, this is exactly what I needed! Mine wasn't running any of the cloudinit scripts or setting the user.
The major thing missing from this is how to customize the Ubuntu image prior to converting it to a template. That’s the reason many people would use a template to begin with.
I haven't dabbled with Linux in a while so it's been a long time since I've checked out the channel, however I really wanted to say that beard looks great on you.
You can convert a template back to a regular vm. It's in the vm config file. Template=1 or template=0 IIRC.
That would be handy to make changes to said template. I would love to be able to add my own packages and still use cloudinit... Now I need to try that. :)
To all the folks you suffer SSH not available once they spin up the VMs from the template. Please run the following command in the proxmox console of all the VMs you created from the template. This will solve your SSH problem. sudo dpkg-reconfigure openssh-server
THANK YOU!
I ran this command in the VM I created from the template and still had the issue
Your are great and explain everything in detail. I like your work!
I would like to add a little to one of the posts here in the comments, a few necessary first steps with the system image:
1. virt-customize -a yaimage.img --install qemu-guest-agent
2. virt-customize -a yaimage.img --run-command "sudo echo > /etc/machine-id; sudo ln -sf /etc/machine-id /var/lib/dbus/machine-id"
...and what I do also:
3. virt-customize -a yaimage.img --root-password password:yourpass - set root password
4. virt-customize -a yaimage.img --timezone "Europe/Kiev" - set ya time zone
5. virt-customize -a yaimage.img --install - install some packages, for example qemu-guest-agent
6. virt-edit yaimage.img /etc/cloud/cloud.cfg - system setup, for example enable root
7. virt-edit yaimage.img /etc/ssh/sshd_config - ssh setup, for example enable password authentication and etc...
Wsup!
This is the kind of details missing here, thank you. Seems you can do quite a lot with the virt command!
@@Ecker00 yeah sure, u can prepare image for any case and with any inside. Word up!
great video, accurate instructions and work like a charm, thanks Jay
Thanks very much. So easy to follow with great explanations at each step. Fabulous work.
You don't have to rename the image from .img to .qcow2 if you pass the parameter --format qcow2 to the qm importdisk command!
Am i the only one that struggles with cloud-init in Proxmox? I got it to work with OpenSuse Leap 15 sp3 but no luck with Ubuntu 20.04 or 22.04, (i use Proxmox 6.4.8). Any suggestions?
Learned something today, thanks a million Jay!
Thank you so much, these videos are tremendously helpful!
Hello Jay,
first i want to thank You for great tutorial.
But always when i setup template and using cloud-init from Proxmox (without configuring SSH public key option) i have problem to login to VM (created from template) via ssh - Permission denied (publickey) . Can you give me some advise how to do it?
Many thanks.
I'm having exactly the same problem. Did you manage to fix it? :)
youtube.com/@LearnLinuxTV I'm having this problem also...can you help?
Same problem here... Someone knows how to fix it or can explain? Would really appreciate!
same problem
Love the guide, except for several "...now BEFORE you click on this" (as I'm clicking on it...)
Hey Jay. I love this video. The idea of just grabbing a live image rather than having to do an install each time I want a new image type is very appealing. I have one question though.
Having gone through some of your previous videos, I've created a custom cloud-int cloud.cfg file for a few use cases. Is there a relatively simple way to use the specific file I've created without having to spin up the new template, replace the existing file, and then clean it up before turning into a template?
Great video Jay! Thanks :) i am trying to create Ubuntu 22.04 Template but i don't understand when you add the ssh key to it . i mean where you get the ssh key ? Thanks
Bro ur so good at making tutorials
Hi Jay, I just noticed that the minimal image that you are working with in your tutorial is the same as the one used for the Container image. Cheers
Thanks for the demo and info, have a great day
Thanks, you too!
Hello Jay, Thanks for the video and your work. The question I have is does the template take those resources from the host and reserve them making them part of the used resources on host? I am sure the answer is yes, but I had to ask. Thanks again.
Set up with network storage by adjusting the command like 'qm importdisk 900 ubuntu-22.04.qcow2 nfsstorage' - the disk showed up as a '.raw' format but still worked flawlessly.
Great video Jay! Thanks again!
I appreciate your youtube videos, and the way you explain.
Looking at the video I found that you have more Bridges for different purposes.
On the internet it is not explained clearly how to route traffic between these bridges to have the machines encapsulated under one bridge. There are some examples with NAT.
Also is possible to do with VLANS instead of bridges but also is not clear.
If you have time, it will be nice to cover this theme, because there is very little info on the net.
Thank you very much.
I got up to the point of logging in, but authentication keeps failing on the credentials I installed in CloudInit. I'm seeing “Failed to start Execute cloud user/final scripts.” and wondering if that's the issue?
Wow. This was amazing. Jay, when you create these templates, every New vm from The same template will have different Host Keys (ssh) and Mac Address, or they will be idênticas to the template?
Hello Jay, Really love your videos. Just wanted to know how to install 'qemu-guest-agent' (or any other package) in the template itself so we don't have to install it in each VM cloned from that template?
sudo apt install libguestfs-tools
sudo virt-customize -a image-name.qcow2 --install qemu-guest-agent
Was there a way to queue up the apt commands as part of the template / cloud-init phase to not have to run them every time you clone?
Very good explanation! Right the thing I need. Many thanks.
Thank you very much, again. Very useful.
Great video as usual. Only question is what is the advantage over the traditional downloading the iso, building a VM, install what I need, seal it and create a template? Are you just demonstrating a new way of creating a template or a better way? After following your procedures I was missing many packages (vi, vim) that I would need to install manually whenever using this template.
I believe you'll find that the cloud-init image is an actual bootable Ubuntu disk image so most of the slow installation process is skipped. (Ex. no probing the hardware. no disk formating. no downloads. no installs. almost no config.) The "cloud-init" portion of what is in that bootable image will clean up a few things upon first boot. You can watch other videos about what cloud init is and how it works on first-boot and not on second boot.
Nice video! Covered the basics. Now going to more advanced question: How to create customized template? Lets say I want to have a template with the qemu-guest-agent already installed instead of me going to the server and installing it manually, then how to proceed?
I wish I could put more than one like on this video ;)
I've tried to follow this guide but have ran into 2 caveats: Cloud init just wasn't executed for VMs of type q35. Switching it in the template worked and cloud-init seemed to work, at least I got cloud-init related output in the console after starting up a fresh clone. But when I want to login it doesn't accept the user and password combination set in cloud-init. Any hints?
Very good, excelent tutorial, recomended
Perfect explanation.
Can I install qemu agent on template itself ?
Can I regenerate cloud image on new template based machine to have different user name
Can templates also be backed up to PBS .
11:30 or just read the manual
12:22 no need, you can 'qm set 900 --scsi0 local-lvm:0,import-from=/root/ubuntu-22.04-minimal-cloudimg-amd64.img' and resize via GUI later.
Thanks for a great tutorial! Just a comment: I've replaced image with [/jammy/current/jammy-server-cloudimg-amd64.img] and default console works fine, no need to add serial.
13:00 qemu can use qcow2 or raw filesystem images. With Raw there's now way for qemu to determine it's actually format because there's not file header say "This is disk image" it just has to guess. (A raw file image could be completely blank). If you pass raw direclty to qemu it'll give a warning say you should use the format=raw option to avoid issues.
With the file extension qemu assumes it's a qcow2 image. It could guess based on filestrcture if it's qcow2 file anyway, it's very unlinkly it could be a raw image with data that looks like qcow2 anwyay.
Now that i've checked you can import without renaming the file like this (replacing VMID with your vm id and STORAGE with your image storage)
qm disk import VMID ubuntu-22.04-minimal-cloudimg-amd64.img STORAGE --format qcow2
Hi, by using this method is it possible to directly install the qemu-agent + add my own script? and if can, which step should i install and add my script before creating the template?
Tnx, fyi with command qm importdisk I added -format qcow2 leaving extension to img seems to work
Great video and helped me a lot. Question can i use the same method to build a Ubuntu desktop template, would i just use another image say "Cloud image for 64-bit computers (USB image)"
Brilliant, thank you!
Hello, hope you're doing well. I want to try building an Ubuntu template with version 24.04. Are the steps the same, or are there any changes I should be aware of?
Thanks for your video!
Seems that downside with this approach that installing custom things won't be part of the template? Such as the Qemu agent, and any other default packages you want setup in the template. Any way to solve that with this method, or follow the old video?
why wouldn't you install the qemu-guest-agent as part of the template?
Probably to prevent replication of the ID or secret
Great video! Thnx a lot!
Today i have told my coleague to take a look at cloud init if you are going for templates, what a coinsidence. I have not noticed, was the secure boot option enabled?
Is there another step if I don't have an ssh public key? If i try to log on from powershell I get permission denied (public key). Any help would be greatly appreciated. :)
very important step before you clone your template it to remove the Machine-IDs.
But there is already an LXC template available in proxmox with Ubuntu 22.04. Why not use that?
IKR 😀, I was about to ask why he did it this way.
Learning from scratch... This is the way !!
@examen1996 Yes, but if he is going to install Ubuntu as server it is more efficient to use LXC. If he was using it for things other than terminal apps them it would make sense to install to a VM. Maybe you can tell us an example of why using and Ubuntu server in a VM is better?
@@mhavock I've run into several dependencies issues when trying to run certain things in a container. For example, I have rport running just fine in a LXC container, but I couldn't get netbox running right. Same way with the Fedora container. I tried to do freeipa in it, didn't work.
thanks Jay !
Could qemu-guest-agent somehow be installed on the template so it gets automatically installed on every VM ?
You could just start the machine and install the preferred software and then do a second template.
yep: virt-customize -a ubuntu-22.04.img --install qemu-guest-agent
Hello, when I create the clone'd machine it shows up as "Ubuntu" on my network. Why is that? The hostname and hosts file both read "gameserver" so I don't understand why my router can't assign it a normal name like when I create a regular VM straight through Proxmox with an ubuntu ISO.
Unfortunately this isn't working for me on Proxmox 7.2-11. The console isn't working on VM startup even though I executed the qm set command as shown (I only see "starting serial terminal on interface serial0). One of the CPU cores maxes out on the VM generated from the template, but it's inaccessible and never gets an IP, making it useless.
I had the same issue. I just went into the UI and changed the interface back to default and it worked for me.
I discovered that this was due to upgrading to Proxmox 7 without rebooting afterwards. Once I rebooted the server, this tutorial worked as described!
unfortunately not working for me. Unable to login to VM. no ssh, no user/passwd
cracking good tutorial Jay
You are the best
I didn't use an SSH key, but when I try to putty in to the VM I get an error: Permission denied (publickey). Any ideas?
I had the same issue. Setting one solved it.
why do you make the template BIOS instead of UEFI?
How to actually boot into the image and customize it/how to customize the steps cloud-init is doing a bit more? E.g. the default ssh-host-keys and sshd_config is geared towards compatability over security, but if I don't need to be backward compatible, how where could one define it so it generates stronger keys and sets my desired sshd_config? Or is that something that we'll have to keep using ansible for?
Hi, thanks for the video; at first, i tought a vm template would look like a DockerFile, so i can setup some stuff already, like "all my vms have python, nano, or whatever"; is something like that possible ?
Hello Jay! Great video. When I clone the template and boot the VM I get the Grub rescue prompt everytime
I found this useful, so I'm leaving a vapid comment to appease our algorithmic overlords.
I followed the steps to create a VM, but cannot SSH into it. Have tried cloud-init clean and dpkg-reconfigure openssl-server, but in vain. Is there any help here?
Did you find a solution for this? Thank you!
Same problem. Had to: edit the /etc/ssh/sshd_config file and change the following entries. Then later can configure properly ie to allow just key auth instead user
#PermitRootLogin prohibit-password
#PasswordAuthentication yes
The above entries should be as shown below:
PermitRootLogin yes
PasswordAuthentication yes
@@MrPDC-jr5yl THANKS SOOOOO MUCH!!!
@@MrPDC-jr5yl there is a file under /etc/ssh/sshd_config.d/ directory that overrides this. You have to set PasswordAuthentication yes in there.
thank very match.
i have a question, about ssh-key. where is this ssh key? i don't put in the box. than i want to connect from (laptop 1), permission denied (publickey). i must put ssh-key inside the box, right? must i have ssh-keygen for each pc?
please help, how do the best way.
i have kvm running raw and cloudinit installs the qemu agent as part of update to cloudimage. - can proxmox not do that
Hi,
thanks for this tutorial, I have one issue please if you could help,
I have followed the same instruction but when I typed ip a to see the @ip, I dont see it, (I have choosed DHCP in cloud-init as you did), do you know please what could be the problem ?
What do you see instead? I'm not sure I'm following.
Looks like a network issue when leasing IP from DHCP server,
The cloud-init images are very minimal. Is there any way to use full featured Ubuntu server for this?
What are ssh public key used for? (referencing @7:03)
I have an ssh key video that’s dedicated to that topic.
without qemu guess agent i think we also able to shutdown ? hemm..what is actually the purpose?
can u give tutorial to enlarge entire disk automatically?
Okay, I did everything like that and I can't connect via ssh to VM created by cloud init (permission denied (publickey). What can I do to fix this?
OK! I AM IDIOT GUYS
I need to specify where is my private key on my machine and then everything works beautifully :)
Can you install qemu directly in the template ?
Thanks for the video
See @FilipeNeto616 comment
Hello, a quick question to the community. I created a VM using the ubuntu.23.10.minimalist and I can't mount a cifs share. After a lot of research and no solutions I think it is the minimalist build that is the issue. I have installed cifs-utils and a bunch of other packages to no avail. I will most likely install the full server version in the next day or two, but want to know if anyone else had this issue? The actual error I get after I run the mount command and put in my password is:
mount error: cifs filesystem not supported by the system
mount error(19): No such device
Is it possible to create a template for Debian with LVM included?
I have a few problems with that method
1. SSH will not work, unless you reboot the VM after the 1st boot
2. All ProxMox (7.2-3) commands related to the VM = Stop, Reboot, Shutdown are not working. You will need to type all these in the VM itself to have it to work, which is... a pain
After downloading the image at 10:26 :
(solves for 2.) virt-customize -a ubuntu-22.04-minimal-cloudimg-amd64.img --install qemu-guest-agent
(solves for 1.) virt-customize -a ubuntu-22.04-minimal-cloudimg-amd64.img --run-command "sudo echo > /etc/machine-id; sudo ln -sf /etc/machine-id /var/lib/dbus/machine-id"
Then rename the image to qcow2 etc
@@fanuchman Thanks for this. I already have it setup as per the video steps. Do I need to blow that away and start from scratch and add your two commands to the image or can I do this with my image already modified and renamed as per the steps in the video with my template created?
@@fanuchman The virt-customize package is not installed in proxmox. The package cannot be found either. Can you share how to get it installed?
@@BillCClinton It is the "libguestfs-tools" package, so "apt install libguestfs-tools"
@@ComMcNeil It will not install inside proxmox. It is not compatible. It can be installed in a VM but not via the proxmox terminal.
Is this for all Linux distros or just for Ubuntu?
Anyone else having troubles running docker swarm on VMs created this way? More specifically: trouble accessing services (stacks) deploy on docker swarm?
Problem seems specifically for docker swarm: I can publish services using "docker compose" without a problem, but when deploying the same configuration in docker swarm mode, the service isn't accessible (logs show that it is running correctly).
Deploying those very same services on a VM installed in the 'classic' way works without any problems.
Have been scratching my head for 2 days on this problem now, starting to go bald here :(
Linux n00bie. I've tried this 3 times and I always end up with vms that get stuck on "starting serial terminal on interface ". This doesn't happen all the time, the first time it was because of my network settings, but now it's just intermittent and I can't figure out why. Any pointers on where to look?
Sometimes I can just press enter and I'm good, other times no response.
Thanks for this - very helpful - though my problem is that the machine-id of every clone of the image is the same --> cloud-init does not seem to reset this, so I get the same machine with the same dhcp ip address every time.
Found any solution to this?
@@Ecker00 Yes, it ended up being simple, you just have to make sure you do not login at any stage. That seems to set it. You have to do all of the work creating the image and setting it up before first use.
@@stevegailey770 alright so delete the machine id, shutdown, convert to template, clone, clone, clone and then it will be regenerated on first boot/login.
@@Ecker00 virt-customize, virt-filesystems and qemu-img are your friends... Managed to find the commands I regularly use getting the image ready for first use...
Why you did not integrate (install) QEMU agent into your template?
Для этого перед созданием шаблона нужно запустить виртуалку, а тогда сразу запустится cloud init для настройки, и больше не получится сделать такую настройку под каждую клонированную виртуалку с помощью cloud init диска.
Если нужно много всего поставить, то можно вручную поставить систему, а потом подготовить её для конвертации в шаблон. На этом канале есть урок. Но мне больше понравился этот способ, потому что получается меньше ненужного говна в шаблоне.
Единственное, с чем пока не разобрался - это как в самом шаблоне разрешить ssh аутентификацию по паролю, а не по ключу.
После каждого клонирования лень редактировать sshd_config
@@kolyacpp Не обязательно, можно через команду: qemu-img resize ubuntu-20.04.img 32G сразу увеличить и потом: virt-customize -a ubuntu-20.04.img --install qemu-guest-agent. Работает на ура
@@MrPDC-jr5yl Круто! Я погуглил, у этой штуки есть ещё --run-command. По идее можно запустить команду, которая отредактирует PasswordAuthentication в sshd_confing. Но если openssh ставится с помощью cloud-init, то этого файла там ещё не будет. Как костыль можно добавить это в греп) и потом туда костыль, чтобы почистить греп, когда замена удастся)
"it is what it is" bruhhh i had been wondering for a while why my command wouldnt execute even thought i was doing the same as the tutorial i was looking at the time lol
Can we do something similar for debian,