5.5. Managing images¶
Acronis Cyber Infrastructure allows you to upload ISO images and templates that can be used to create VM volumes. An ISO image is a typical OS distribution that needs to be installed on disk. In turn, a template is a ready volume in the QCOW2 format with an installed operating system and applications and a set minimum size. Many OS vendors offer templates of their operating systems under the name “cloud images”. For a list of guest OSes that are supported in virtual machines, refer to Supported guest operating systems.
Note
Images are stored according to the default storage policy.
When you install the load balancer or Kubernetes service, special images appear in the compute cluster, which are used by the system for creating service VMs. Such images are marked with the System tag and cannot be modified or deleted in the admin panel.
5.5.1. Uploading, editing, and removing images¶
To add an image, do the following:
On the Compute > Virtual machines > Images tab, click Add image.
In the Add image window, do the following:
Click Browse and select a template or ISO file.
Specify an image name to be shown in the admin panel.
Select the correct OS type from the drop-down list.
Important
The OS type affects VM parameters such as hypervisor settings. VMs created from an image with an incorrect OS type may not work correctly, for example, they may crash.
Optionally, select the Share between all projects check box. With the option disabled, the image will only be available in the admin project of the Default domain.
Click Add to upload the image.
The admin panel will show the upload progress.
Important
Do not reload the page while the image is being uploaded or the process will fail.
To edit an image, select it, and then click the pencil icon next to a parameter you need to change.
To remove an image, click the ellipsis button next to it, and then click Delete.
5.5.2. Creating volumes from images¶
You can create volumes from both ISO images and templates. Do the following:
On the image panel, click Create volume.
In the Create volume window, specify the volume name, size, and choose a storage policy.
Click Create.
The new volume will appear on the Compute > Storage > Volumes tab.
5.5.3. Mounting ISO images to virtual machines¶
Note
This feature is supported only for Linux virtual machines. You can, however, mount an ISO image to a Windows VM via the vinfra
tool. Use the instructions provided in Installing guest tools in existing virtual machines. Replace the guest tools image in the examples with your image.
To mount an ISO image to a Linux VM, do the following:
- Create a volume from the ISO image, as described in Creating volumes from images.
- Attach the resulting volume to the desired VM, as described in Attaching and detaching volumes.
The mounted disk will appear inside the Linux VM.
5.5.4. Preparing templates¶
You may need to create a template in these cases:
- to rescue a virtual machine
- to create a VM accessible via SSH
- to create a VM customizable with user data
In general, the actions to create a template from an ISO image are the following:
- Create a virtual machine from an ISO image (refer to Creating virtual machines).
- Install the guest OS using the built-in VNC console.
- Shut down the VM.
- Convert the VM boot volume to a template (refer to Creating images from volumes).
However, to be able to customize a VM or connect to it via SSH, you also need to install cloud-init and OpenSSH inside its template before the VM deployment. Preparation of such templates differs depending on the guest operating system and is described in the sections below.
5.5.4.1. Preparing Linux templates¶
As all Linux guests have OpenSSH Server pre-installed by default, you only need to make sure a Linux template has cloud-init installed.
The easiest way to get a Linux template with cloud-init installed is to obtain it from its official repository or build one with the diskimage-builder
tool. For more information, refer to Creating Linux templates.
5.5.4.2. Preparing Windows templates¶
Windows guests have neither Cloudbase-Init nor OpenSSH Server pre-installed by default. You need to install and configure them manually. Do the following:
Create a VM from a Windows image as described in Creating virtual machines.
Log in to the VM and install the guest OS by using the built-in VNC console.
Create a new administrator account that will be used for SSH connections and log in with it.
If you need to install and configure OpenSSH Server, do the following:
Run Windows PowerShell with administrator privileges and set the execution policy to unrestricted, to be able to run scripts:
> Set-ExecutionPolicy Unrestricted
Download OpenSSH Server (for example, from the GitHub repository), extract the archive into the
C:\Program Files
directory, and then install it by running:> & 'C:\Program Files\OpenSSH-Win64\install-sshd.ps1'
Start the
sshd
service and set its startup type to “Automatic”:> net start sshd > Set-Service sshd -StartupType Automatic
Open TCP port 22 for the OpenSSH service in the Windows Firewall:
On Windows 8.1, Windows Server 2012, and newer versions, run:
> New-NetFirewallRule -Protocol TCP -LocalPort 22 -Direction Inbound \ -Action Allow -DisplayName OpenSSH
On Windows 7, Windows Server 2008, and Windows Server 2008 R2, run:
> netsh advfirewall firewall add rule name=sshd dir=in action=allow \ protocol=TCP localport=22
Open the
C:\ProgramData\ssh\sshd_config
file:> notepad 'C:\ProgramData\ssh\sshd_config'
Comment out the following lines at the end of the file:
#Match Group administrators #AuthorizedKeysFile __PROGRAMDATA__/ssh/administrators_authorized_keys
Save the changes.
Create the
.ssh
directory inC:\Users\<current_user>
and an emptyauthorized_keys
file inside it:> cd C:\Users\<current_user> > mkdir .ssh > notepad .\.ssh\authorized_keys
Remove the
.txt
extension from the created file:> move .\.ssh\authorized_keys.txt .\.ssh\authorized_keys
Modify the permissions for the created file to disable inheritance:
> icacls .\.ssh\authorized_keys /inheritance:r
Download Cloudbase-Init (for example, from the official site), launch the installation, and then follow the on-screen instructions:
In the Configuration options window, enter the current username in the Username field:
Important
The user account password will be reset on the next VM startup. You will be able to log in with this account by using the key authentication method or you can set a new password with a customization script (refer to Creating virtual machines).
When the installation is complete, do not run Sysprep and click Finish:
Run Windows PowerShell with administrator privileges and open the file
C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\cloudbase-init.conf
:> notepad 'C:\Program Files\Cloudbase Solutions\Cloudbase-Init\conf\cloudbase-init.conf'
Add
metadata_services
andplugins
on two lines:metadata_services=cloudbaseinit.metadata.services.configdrive.ConfigDriveService,\ cloudbaseinit.metadata.services.httpservice.HttpService plugins=cloudbaseinit.plugins.common.mtu.MTUPlugin,\ cloudbaseinit.plugins.windows.ntpclient.NTPClientPlugin,\ cloudbaseinit.plugins.common.sethostname.SetHostNamePlugin,\ cloudbaseinit.plugins.windows.createuser.CreateUserPlugin,\ cloudbaseinit.plugins.common.networkconfig.NetworkConfigPlugin,\ cloudbaseinit.plugins.windows.licensing.WindowsLicensingPlugin,\ cloudbaseinit.plugins.common.sshpublickeys.SetUserSSHPublicKeysPlugin,\ cloudbaseinit.plugins.windows.extendvolumes.ExtendVolumesPlugin,\ cloudbaseinit.plugins.common.setuserpassword.SetUserPasswordPlugin,\ cloudbaseinit.plugins.common.userdata.UserDataPlugin,\ cloudbaseinit.plugins.windows.winrmlistener.ConfigWinRMListenerPlugin,\ cloudbaseinit.plugins.windows.winrmcertificateauth.ConfigWinRMCertificateAuthPlugin,\ cloudbaseinit.plugins.common.localscripts.LocalScriptsPlugin
Note
Make sure to remove all backslashes in the lines above.
Save the changes.
Stop the VM.
After the VM is shut down, convert its boot volume to a template (refer to Creating images from volumes).