Creating Virtual Environments with virt-install
While you typically create virtual machines and containers using prlctl, you can also do the same with virt-install. You will need to install it from the Virtuozzo official repository with yum install virt-install.
You can manage VMs created with virt-install using prlctl. You will need, however, to manually delete the hard disk images after you delete such VMs with prlctl delete.
To shorten the commands and make sure that the required parameters are always supplied, the common options for creating virtual environments are placed in presets. You can list the default presets and their contents as follows:
| |
You can also create your own presets and place them in /etc/virt-manager/presets. If a preset starts with a commented-out line, it is used to describe the preset in the output of virt-install --list-presets. Otherwise “No description” is shown.
vz_ct_windows preset is meant for the Windows Containers Demo. For more details, see the Windows Containers Demo Walkthrough.The following sample command creates a blank VM based on the vz_vm_linux preset optimized for running CentOS 7:
| |
The resulting VM has the following properties:
- 2048 MB RAM
- 1 CPU socket and 2 CPU cores
- 64 GB hard disk in the file
/vz/mylinuxvm/harddisk.hdd, which is created along with the VM (the directory must exist) - A CD-ROM drive where an existing file
myosdistrib.iso, e.g., a Linux distribution image, is mounted to boot and install from - VNC enabled on port 6533 at host’s IP address
The next sample command creates a blank VM based on the vz_vm_windows preset optimized for running Microsoft Windows Server 2019:
| |
The resulting VM has the following properties:
- 2048 MB RAM
- 1 CPU socket and 2 CPU cores
- 64 GB hard disk in the file
/vz/mywindowsvm/harddisk.hdd, which is created along with the VM (the directory must exist) - A CD-ROM drive where an existing file
myosdistrib.iso, e.g., a Microsoft Windows distribution image, is mounted to boot and install from - VNC enabled on port 6534 at host’s IP address
Finally, the sample commands to create a Linux container based on the CentOS 7 template are:
| |
The first command creates a hard disk image for the container. It is made from the same template that is used when creating containers using prlctl. The second command creates the container with the specified hard disk.
You can resize the disk with virsh blockresize <CT_name> <device_name> <size><units>. The container can be running or stopped. For example:
| |