7. Virtual machines
Install Virtual Machines from the App Catalog. It runs virtual machines with KVM, the hypervisor built into Linux. To run them at full speed, the processor needs VT-x or AMD-V, turned on in the computer's firmware (Hardware). Without it, virtual machines still run, but very slowly.
Creating a virtual machine
Virtual Machines > Create... offers three ways:
- A ready-made system: Debian, Ubuntu or AlmaLinux, ready in one click, with no installer to go through and an account made for you. The image comes from its publisher, checked against the publisher's own checksums, and is kept for the next virtual machine, which can then be made without the internet. Its disk is at least as large as the publisher's image (OSM says so if the size chosen is smaller). OSM makes the account's password: it is shown when the virtual machine is made, and again with Account... in its More menu.
- A virtual machine: Windows, Linux or anything else, from its installer ISO. Put the ISO file in the shared folder iso first (the Administrators may write there, with Files or from a computer over the network), or in any other shared folder, then choose it here.
- OSM: to try OSM in OSM, started from OSM's installer. Put OSM's USB image or ISO in a shared folder with Files first.
Then choose:
- the processors, memory and disk size (the disk is a file on a volume, which grows as it is used). The whole size of its disks must fit in the volume's free space now, with 1 GB to spare, as for a disk added later: when it does not, nothing is made and OSM says how much it needs and how much is free. OSM keeps an eighth of the server's memory, 2 GB at least and 8 GB at most, for itself and its apps: a virtual machine starts only when its memory fits beside the ones running, and the page shows how much is free for virtual machines;
- the network: on the server's bridge, the virtual machine gets its own address from your router, like any computer; on NAT, it reaches the network through the server and is hidden behind it;
- UEFI with Secure Boot, and a TPM 2.0 (needed by Windows 11).
Using a virtual machine
- Connect opens the screen of a virtual machine that is on (running, paused, or shutting down) in a window of the desktop, with its keyboard and mouse; one that is off shows Start. Resume and Force stop are in More.
- Paste text... on the screen types a text into the virtual machine for you, key by key, as if on its keyboard: a command, a product key, a few lines of a script (5,000 characters at most). It works everywhere a keyboard does, in an installer or at a sign-in too. Choose the keyboard layout the virtual machine is set to: English (US), English (UK), German or French (each VM remembers its choice, and one you have not chosen for yet offers the last layout you chose). Before it types, OSM tells you the characters that layout cannot type, for example an é with the English ones. Each line break presses Enter; Stop typing stops it. Copying text out of a virtual machine is not possible this way.
- Shut down asks the system inside to shut down; Force stop is like pulling the plug; Pause and Resume freeze and continue it.
- Settings... changes its priority and whether it starts with the server (General, also while it runs), its processors, memory, network and the rest of its hardware (Hardware), and its disks and CD drive (Disks, also Disks... in its More menu): see Disks and hardware below. Only what you changed changes; a change the virtual machine refuses (a disc while its tray is locked) changes nothing at all.
- To take the ISO out once the system is installed, choose Eject under CD / DVD drive in Disks. An OSM virtual machine started from OSM's USB image has Remove the installer... in its More menu instead.
- Delete... removes the virtual machine and its disk files, unless you tick Keep its disk files. Its backups stay (below). The dialog also lists its detached disk files (disks taken out of it, still in its folder), each with a tick box: the ones you tick are deleted with it, the others stay. Its name stays taken while one of its disk files is left; delete them later under Kept files..., or under Disk files not attached in the Disks of another virtual machine. With its last disk file, what OSM made beside them goes too (the account it made, the console's text, the installer's copy), and the name is free again.
- Kept files... (in the window's bar, while something is kept) lists what Virtual Machines keeps on the volumes that no virtual machine uses: the images of the ready-made systems, kept for the next one made from them, and the disk files left by virtual machines deleted or detached from them. Delete... removes one; a kept image is downloaded again when it is next needed. What is kept can keep its volume from being deleted, or from being mirrored by High Availability: delete here what is no longer needed.
- A virtual machine on a High Availability pair is deleted on both servers: the other server lets go of its copy first. When that server does not answer, the virtual machine stays as it was, running if it ran; once that server has been silent for a while, Delete anyway deletes it here now, and from the other server when it is back.
Disks and hardware
More > Disks... (or Settings... > Disks) lists the virtual machine's disks: each one's name in the virtual machine (vda, sda...), its bus, its size and what its file takes on the volume so far, and the disk it starts from.
- Add a disk..., while the virtual machine is shut down:
- A new disk: its size, the volume it goes on (each with its free space) and its bus. It is a file in the virtual machine's own folder on that volume and takes only the space the virtual machine writes, but its whole size must fit in the volume's free space, with 1 GB to spare.
- A copy of a disk image: a .vmdk, .vdi, .vhd, .vhdx, .qcow2 or raw .img file you put in a shared folder, such as the disk of a virtual machine from another program. OSM copies it into the virtual machine's own folder as a disk of its own (a large disk takes a while: the copy shows how far it is), and the image stays where it was. Its whole size must fit in the volume's free space. OSM reads the image with your own permissions: one you may not open yourself is refused before anything is made. OSM copies images of one file only: export a disk made of several files (a VMDK "descriptor" and its parts) as one file first, and merge a disk with snapshots into one.
- Grow... makes a disk bigger, also while the virtual machine runs. A disk never shrinks: the system in it keeps its partitions and files up to its end. What it grows by must fit in its volume's free space. Then grow the partition and the file system inside the virtual machine: in Windows with Disk Management (Extend Volume), in Linux with growpart and resize2fs (the ready-made systems do it by themselves at their next start). A VirtIO disk shows its new size at once, a SATA disk after the virtual machine restarts. A disk with snapshots made outside OSM does not grow: going back to one would take the disk back to its old size.
- More > Bus, cache, freed space..., while it is shut down: VirtIO is the fastest bus, SATA works with every system. Windows needs the virtio-win drivers before its system disk moves to VirtIO, or it does not start (move it back to SATA then). The disk's name in the virtual machine changes with its bus (sda, vda). Cache: none is the safest, and the one OSM gives a disk. Freed space: given back to the volume (the system's TRIM), or kept in the disk's file.
- More > Detach..., while it is shut down: the disk leaves the virtual machine, and its file stays. For the disk the virtual machine starts from, OSM says so first: it then starts from its next disk, if a system is installed there, or from its CD drive.
- Disk files not attached lists the disks detached from a virtual machine, and those kept when their virtual machine was deleted. Attach gives one to this virtual machine (its file moves into this virtual machine's folder); Delete... deletes its file for good, once you type its name.
- CD / DVD drive: Insert, Change the disc or Eject an ISO file, also while the virtual machine runs.
Settings... > Hardware, while the virtual machine is shut down: its processors and memory; its network (the bridge, NAT or none) and network adapter (VirtIO, the fastest, or the Intel e1000e, which every system has a driver for), its MAC address kept so that your router gives it the same address; what it starts from first (its disk, or its CD drive while you install a system); its TPM 2.0 (the system finds one added at its next start; one taken away takes what it holds with it, so a Windows with BitLocker asks for its recovery key); and the channel of QEMU's guest agent, with whether the agent answers. The firmware (BIOS, UEFI, UEFI with Secure Boot) stays as the virtual machine was made: a system installed for one does not start with another.
- A virtual machine on a High Availability pair keeps its disks as they are (they are mirrored on both servers); its CD drive and its hardware still change.
- While a backup of the virtual machine runs, its disks do not change, and no backup starts while they change. After a disk is added, detached, grown or moved to another bus, its next backup version holds every block again.
Priority and start order
Like apps, each virtual machine has a Priority: Critical, High, Normal or Low, for the processor and the disks when the server is busy. When the server starts, the virtual machines that start with it come up in order of priority, Critical first. One that cannot start then (not enough memory, for example) is a notification that says why; it goes once that virtual machine has started, or is deleted.
Devices
PCI and USB devices... gives a device of the server to one virtual machine: a USB stick or dongle, a graphics card, a network card, a disk controller.
- PCI devices need the IOMMU (VT-d or AMD-Vi) turned on in the firmware; OSM then turns it on in Linux with one switch, which takes a restart (the notification about it goes once the server runs so). A device is given with the other devices of its IOMMU group, which Settings > System Info > Hardware lists; the group of the chipset itself cannot be given away.
- PCI devices are added and removed only while the virtual machine is shut down; USB devices also while it runs.
- A device the server uses itself is marked The server uses it. To give it away anyway, you tick I understand, and want it anyway: the server can lose its disks, its network or its screen.
- While the virtual machine runs, the device belongs to it alone; it comes back to the server afterwards.
Protecting a virtual machine's data
A virtual machine's disks are files in a system folder of a volume, so the volume's RAID protects them from a failed disk. Against the rest (a system that no longer starts, files deleted or encrypted in it, an update gone wrong), OSM backs virtual machines up from the outside, with nothing to install in them:
- In Virtual Machines, choose More > Backups... of the virtual machine, then Settings....
- Tick Back this virtual machine up, and choose the volume to keep its versions on, when (every day or every week at an hour, or by hand) and which versions to keep, as for backup tasks: one a day for so many days, one a week, one a month, one a year. The newest version always stays.
- Back up now makes a version at once.
- A running virtual machine runs on during its backup. Its first version holds every block of its disks; each next one holds only the blocks written since, so it is quick and small. With QEMU's guest agent in it (qemu-guest-agent in Linux, which the ready-made systems have; the virtio-win guest tools in Windows), its file systems are frozen for a moment as the backup starts, and the version is consistent: as after a clean shutdown. Without one, a version is as after a power cut, and the list of versions says so. If the guest agent does not answer when its file systems should be thawed, OSM says so and tries again every few minutes, while the backup goes on too.
- A virtual machine that is shut down has its disks copied whole, and cannot start until the copy is done. One that has not run since its last version gets no new one.
- The versions are kept in a system folder of the volume (@vmbackup) that only the server reads, never in a shared folder. They hold the disks and the virtual machine's settings, not its TPM.
- A version dated in the future (made while the server's date was ahead) is kept, and OSM never deletes it for its date. It does not count as the newest, and no later version builds on it: the next backup holds every block again, and the ones after that only the changes, as usual. The backup's log and a notification say so; delete the version with Delete this version... once you no longer need it.
Each version has Restore:
- As a new virtual machine...: a new virtual machine beside the old one, with its own disks, new network addresses (MAC), no PCI or USB device and an empty CD drive. It is not started: both have the same system inside, so start it once the old one is off, or change its network first. It has a new TPM: a Windows with BitLocker asks once for its recovery key.
- A disk back into...: only while the virtual machine is shut down. The disk becomes as it was in the version, and what was written on it since is lost. The disk stays as it is until the version's copy is ready. If the virtual machine is started during the copy, the restore stops and nothing of it changes.
- Files...: choose the disk and its file system (ext4, XFS, Btrfs, NTFS or FAT), open its folders, tick what to restore and choose a shared folder: OSM makes a new folder Restore name date in it and copies them there. Links and special files stay behind. For a disk with LVM or encryption, restore the version as a new virtual machine and copy the files from inside it.
- Delete this version...: the next version first takes in what it needs from it.
The backups of a virtual machine you delete stay: Backups of deleted VMs... above the list opens them, to restore a version as a new virtual machine, take files out of it, or delete them. A backup that fails is a notification with the reason.