Wondering how to create a custom Linux SolusVM KVM template? We can help you.
Here at Bobcares, we often handle requests from our customers to fix similar KVM queries.
Today we will see how our support engineers fix this for our customers as a part of our Server Management Services.
How to create a custom Linux SolusVM KVM template?
Today, let us see the steps followed by our Support Techs to create a custom Linux SolusVM KVM template.
Before you proceed, remove all user accounts and their home directories from source VPS. In Linux systems there are system accounts and user accounts.
By default user account have UID from 1000 to 65534.
All users are listed in the file /etc/passwd in format:
USERNAME:x:UID:GID:description:HOMEDIR:SHELL
Copy Code
To remove user use the following command:
deluser –remove-all-files USERNAME
Copy Code
Then, remove all SSH keys from the source VPS.
For generation 1 templates run the following command on source VPS:
rm /etc/ssh/ssh_host_*
Copy Code
Generation 1 template
Generation 1 templates are fixed-size byte by byte images.
You can use it if it is required to create a special template that either includes obscure partitions or filesystems that cannot manipulate from the host node.
Generation 1 templates can have networking setup by SolusVM, however, any filesystem resizing should script inside the template.
1.Firstly, prepare a source VPS from which template will be created.
2.Then, shutdown the server in SolusVM > Virtual Servers > the necessary VPS
3.Execute the following command to create a template:
# /scripts/kvmtemplate –mode=package –vmid=kvm101 –generation=1
Copy Code
Once the script is finished, the location of the created template will be displayed:
# Template: /home/solusvm/kvm/template/template-149fee41d5801f96368c959a00dd6092a56ba031.gz
Copy Code
4.Rename the template:
# mv /home/solusvm/kvm/template/template-149fee41d5801f96368c959a00dd6092a56ba031.gz /home/solusvm/kvm/template/linux-centos-7-x86_64-custom-gen1-v1.gz
Copy Code
5.Upload the created template to the Master server into the same template location:
# /home/solusvm/kvm/template/linux-centos-7-x86_64-custom-gen1-v1.gz
Copy Code
6.Add the template in SolusVM.
How to add Template in SolusVM?
1. Firstly, connect to the Master SolusVM server via SSH
2. Then, upload KVM template to the /home/solusvm/kvm/template/ directory. SolusVM provides its own pre-created KVM templates from TDN storage
3. After that log into SolusVM web interface and browse to Dashboard > Media > Add KVM Template
4. Then, configure the template per its requirements
5. Next, click on Add Template button.
6. Browse to Media > Media Sync > Create page
7. Sync templates between Master and Slave nodes
Click on Create Sync Job button
8. On the Jobs tab verify that the task is complete. It is possible to trigger this operation manually via Manually Force Sync button.
Master node:
# ls -lh /home/solusvm/kvm/template/windows-2012-server-trial-x86_64-gen2-v1.gz
-rw-r–r– 1 root root 0 Nov 22 23:29 /home/solusvm/kvm/template/windows-2012-server-trial-x86_64-gen2-v1.gz
Copy Code
Slave node:
# ls -lh /home/solusvm/kvm/template/windows-2012-server-trial-x86_64-gen2-v1.gz
-rw-r–r– 1 qemu qemu 3.7G Sep 12 2012 /home/solusvm/kvm/template/windows-2012-server-trial-x86_64-gen2-v1.gz
Copy Code
Generation 2 template
Usually, generation 2 templates are far more flexible than generation 1 templates with respect to filesystem resizing and configuration. Generation 2 templates should be used if the template will use standard filesystems ( ext3 or ext4).
Generation 2 templates do not currently support logical volumes or extended partitions, generation 1 templates should be used for that.
1. Firstly, prepare a source VPS from which template will be created.
2. Then, shutdown the server in SolusVM > Virtual Servers > the necessary VPS
3. Check partition table in the source VPS kvm123 to determine which partition should be resizable in the future – the necessary partition contains OS of the VPS/template:
# /scripts/kvmtemplate –mode=prescan –vmid=kvm123 –generation=2
Name Type VFS Label MBR Size Parent UUID
/dev/sda1 filesystem ext4 – – 20G – 23261380-2181-4fee-bf1a-b7235d2b9ad9
/dev/sda2 filesystem swap – – 99M – d0bc2596-74ae-45b2-b2d4-d59f06b54d07
/dev/sda1 partition – – 83 20G /dev/sda –
/dev/sda2 partition – – 82 99M /dev/sda –
/dev/sda device – – – 20G – –
Copy Code
In most cases, the partition to resize is the biggest partition. In the example above the biggest partition is /dev/sda1, so the partition to resize will be 1. Partition /dev/sd2 is SWAP.
4. Prepare the source VPS for template creation by removing any SSH keys, mac addresses, and udev rules:
# /scripts/kvmtemplate –mode=prepare –vmid=kvm123 –generation=2
Copy Code
5. Create the template:
# /scripts/kvmtemplate –mode=package –vmid=kvm123 –generation=2
Copy Code
The output of the command will contain the location of the created template:
# Template: /home/solusvm/kvm/template/template-149fee41d5801f96368c959a00dd6092a56ba031.gz
Copy Code
6. Rename the template:
# mv /home/solusvm/kvm/template/template-149fee41d5801f96368c959a00dd6092a56ba031.gz /home/solusvm/kvm/template/linux-centos-6-x86_64-custom-gen2-v1.gz
Copy Code
template name has to start with “linux”, as in the example above – “linux-centos-6-x86_64-custom-gen2-v1.gz”.
7. Upload the created template to the Master server into the same template location:
# /home/solusvm/kvm/template/linux-centos-6-x86_64-custom-gen2-v1.gz
Copy Code
8. Add the template in SolusVM.
[Need assistance with SolusVM issues? We can help you]
Conclusion
In short, we saw how our Support Engineers create a custom Linux SolusVM KVM template
0 Comments