Skip to content

VM management

OpenStack provides many facilities to manipulate virtual machines. The full details are available in the OpenStack site user guide (although some features may not yet be implemented at infomaniak).

Stopping and Starting

VMs can be stopped and started in different ways. These operations are performed by the openstack command with appropriate actions.

reboot is equivalent to powering down the machine and then restarting it. A complete boot sequence takes place and thus the machine returns to use in a few minutes. A soft reboot attempts a graceful shut down and restart of the instance. A hard reboot power cycles the instance.

pause/unpause allows for temporary suspension of the VM. The VM is kept in memory but it is not allocated any CPU time. This is useful if you are performing an intervention on a set of servers and want to avoid that a VM continues to process while the intervention is underway. Unpause takes less than a second.

suspend/resume stores the VM onto disk and recovers it later (in less than a minute). This is faster than stop/start and the VM returns to the place is was when the suspend was performed rather than a new boot cycle.

shelve/unshelve. Shelving stops the instance and takes a snapshot of it. In the next hour your VM will be destroyed from the hypervisor but all the information will be kept in the Openstack database (such as IP) allowing you to unshelve the VM when you decide to. This allows you to save some money as you won't be charged for the CPU/RAM nor for the high available and performant CEPH cluster hosting your VM Disk. Instead you'll be charged for the cold storage hosting the snapshot of your VM which is cheaper.

These various approaches can be very useful in environments such as software builds or scale-out services to pre-create VMs and then rapidly bring them online.

The actions can all be performed using the openstack unified CLI with

$ openstack server <operation> <hostname>

such as

$ openstack start infomaniak-vm-2

The status of a VM can be shown using openstack server show:

taylor@laptop:~$ openstack server show infomaniak-vm-2
| Field                       | Value                                                                  |
| OS-DCF:diskConfig           | MANUAL                                                                 |
| OS-EXT-AZ:availability_zone | b10                                                                    |
| OS-EXT-STS:power_state      | Running                                                                |
| OS-EXT-STS:task_state       | None                                                                   |
| OS-EXT-STS:vm_state         | active                                                                 |
| OS-SRV-USG:launched_at      | 2021-02-25T08:57:50.000000                                             |
| OS-SRV-USG:terminated_at    | None                                                                   |
| accessIPv4                  |                                                                        |
| accessIPv6                  |                                                                        |
| addresses                   | ext-net1=2001:1600:115:1::2e8,                           |
| config_drive                |                                                                        |
| created                     | 2021-02-25T08:57:28Z                                                   |
| flavor                      | cpu2-ram6-disk20 (2655c1e3-a43a-4dea-a957-650517e8fa72)                |
| hostId                      | 039729bd995a8226cb76588d9e24e7156f29e9ce5cbbf6e7ef4b8e70               |
| id                          | 0c2b0e8f-0a59-4d81-9545-fd90dc7fee73                                   |
| image                       | debian-10.8-openstack-amd64.raw (0c857837-f852-44dc-b986-bcc488bf7b70) |
| key_name                    | mykeypair                                                              |
| name                        | infomaniak-vm-2                                                        |
| progress                    | 0                                                                      |
| project_id                  | ac4fafd60021431585bbb23470119557                                       |
| properties                  |                                                                        |
| security_groups             | name='default'                                                         |
|                             | name='taylor'                                                          |
| status                      | ACTIVE                                                                 |
| updated                     | 2021-02-25T08:57:50Z                                                   |
| user_id                     | b1580497f51e4d10b9110c60c154562c                                       |
| volumes_attached            |                                                                        |

Renaming VMs

Once a VM is created, its name is fixed when the openstack server create command is run. Renaming a virtual machine is not supported. Alternatively, a new VM can be created using a snapshot of the old VM as follows:

  • Snapshotting the source VM to create a copy of the virtual machine.
  • Creating the destination VM with the new name from the source snapshot.
  • Check that the new service is working as desired.
  • Delete the source VM

Rescueing a VM

ℹ Note: this procedure has not been tested for Windows virtual machines.

In some cases, a virtual machine may fail to boot. Reasons such as incorrect configuration or a problem with the system disk can block the boot process. The virtual machine console can provide useful diagnostic information on the root cause and may help to resolve the problem.

The other approach is to use the rescue functions of OpenStack where a virtual machine is booted using the original image and the system disk is provided as a second disk to the virtual machine. This disk can then be manipulated such as fsck to clear a filesystem problem or mounting and editing the configuration.

$ openstack server rescue infomaniak-vm-2

ℹ Note: By default the instance is booted from a fresh copy of the original instance image if no specific rescue image is provided. Otherwise you can use the rescue image we provide allowing you to connect with a password in addition to your keypair (see how at the bottom of this page)

This will reboot the virtual machine and you can then log in using the key pair previously defined. You will see two disks, /dev/vda which is the new system disk and /dev/vdb which is the old one to be repaired.

The old one can be mounted and configuration files edited or fsck'd.

Example, to mount your broken disk (vdb)

root@infomaniak-vm-2:~$ lsblk
vda      8:0    0   2G  0 disk
└─vda1   8:1    0   2G  0 part
vdb      8:16   0  20G  0 disk
└─vdb1   8:17   0  20G  0 part /

root@infomaniak-vm-2:mount /dev/vdb1 /mnt/

root@infomaniak-vm-2:~$ ls -l /mnt/
total 76
lrwxrwxrwx  1 root root     7 Feb  6 10:30 bin -> usr/bin
drwxr-xr-x  4 root root  4096 Feb  6 10:33 boot
drwxr-xr-x  4 root root  4096 Feb  6 10:30 dev
drwxr-xr-x 68 root root  4096 Feb 25 08:58 etc
drwxr-xr-x  3 root root  4096 Feb 25 08:58 home
lrwxrwxrwx  1 root root    37 Feb  6 10:32 initrd.img -> boot/initrd.img-4.19.0-14-cloud-amd64
lrwxrwxrwx  1 root root    37 Feb  6 10:32 initrd.img.old -> boot/initrd.img-4.19.0-14-cloud-amd64
lrwxrwxrwx  1 root root     7 Feb  6 10:30 lib -> usr/lib
lrwxrwxrwx  1 root root     9 Feb  6 10:30 lib32 -> usr/lib32
lrwxrwxrwx  1 root root     9 Feb  6 10:30 lib64 -> usr/lib64
lrwxrwxrwx  1 root root    10 Feb  6 10:30 libx32 -> usr/libx32
drwx------  2 root root 16384 Feb  6 10:29 lost+found
drwxr-xr-x  2 root root  4096 Feb  6 10:30 media
drwxr-xr-x  2 root root  4096 Feb  6 10:30 mnt
drwxr-xr-x  2 root root  4096 Feb  6 10:30 opt
drwxr-xr-x  2 root root  4096 Jan 30 17:37 proc
drwx------  3 root root  4096 Feb 25 08:58 root
drwxr-xr-x  7 root root  4096 Feb  6 10:32 run
lrwxrwxrwx  1 root root     8 Feb  6 10:30 sbin -> usr/sbin
drwxr-xr-x  2 root root  4096 Feb  6 10:30 srv
drwxr-xr-x  2 root root  4096 Jan 30 17:37 sys
drwxrwxrwt  8 root root  4096 Feb 25 09:17 tmp
drwxr-xr-x 13 root root  4096 Feb  6 10:30 usr
drwxr-xr-x 11 root root  4096 Feb  6 10:30 var
lrwxrwxrwx  1 root root    34 Feb  6 10:32 vmlinuz -> boot/vmlinuz-4.19.0-14-cloud-amd64
lrwxrwxrwx  1 root root    34 Feb  6 10:32 vmlinuz.old -> boot/vmlinuz-4.19.0-14-cloud-amd64

On completion, the VM can be returned to active state with nova unrescue and rebooted.

$ openstack server unrescue infomaniak-vm-2

Using the infomaniak rescue image

ℹ Note: In case you broke your ssh authorized_keys file or lost your ssh key you can reboot your VM in rescue mode and connect via a password.

Your first have to set the temporary root password (Assuming your VM is infomaniak-vm-2)

$ openstack server set --property rescue_pass=my-Password-For-Ssh infomaniak-vm-2

Then you have rescue your VM using or rescue image Centos 7 Rescue Infomaniak with the id 8daa9682-451b-43c2-b573-5c2658e9111c and connect via ssh as root with the password you defined

$ openstack server rescue infomaniak-vm-2 --image 8daa9682-451b-43c2-b573-5c2658e9111c

Back to top