Managing virtual machines

Changing hardware

Changing a virtual machine hardware will reboot your virtual machine.

Change virtual machine CPU and memory

To change a virtual machine parameters, open the virtual machine details, click on the Edit icon and modify the CPU and/or memory amount using the sliders. Amount will be changed after clicking Confirm button. If you want to discard changes, click Discard button.

You can edit virtual machine's CPU or memory amount only when it is powered off or powered on. If change was made when machine was powered on, it will be rebooted.

Change virtual machine CPU

Add disk to virtual machine

To add disk to a virtual machine, open the virtual machine details, click on Edit icon and click on Add additional disk button. Then modify the size of the disk using the slider or provide specific size into the field next to slider. Disk will be added to your machine after clicking Confirm button. If you want to discard changes, click Discard button.

Disk will be hot added to your virtual machine, i.e. there is no need for machine rebooting. Sometimes disk will not be visible directly after this operation, thus you will need to manually reboot virtual machine. It should be visible in the machine afterwards.

However on Linux based systems you can add this new disk without rebooting a machine, using commands presented below (must be used on root account):

echo "- - -" > /sys/class/scsi_host/host0/scan
echo "- - -" > /sys/class/scsi_host/host1/scan
echo "- - -" > /sys/class/scsi_host/host2/scan

This command rescans the SCSI bus, which lets Linux kernel to find the new disk. You can check the result using fdisk -l command. It should list disks found on current machine, including the new one.

Add disk to virtual machine

This operation will only add physical disk to your machine, thus partitions or file systems need to be manually resized.

  • If your virtual machine runs a Linux based operating system, you should resize your LVM volume.
  • If your virtual machine runs a Windows based operating system, you should use Disk Management tool on your server.

Depending on the operating system, please refer to documentation linked below:

Operating system
Windows https://technet.microsoft.com/en-us/library/cc771097.aspx
Ubuntu https://wiki.ubuntu.com/Lvm
fedora https://docs.fedoraproject.org/en-US/Fedora/14/html/Storage_Administration_Guide/ch-lvm.html
ArchLinux https://wiki.archlinux.com/LVM
Debian https://wiki.debian.org/LVM
OpenSUSE https://www.suse.com/documentation/sles10/book_sle_reference/data/sec_yast2_system_lvm.html
CentOS https://www.centos.org/docs/5/html/Cluster_Logical_Volume_Manager/LVM_CLI.html

For example if you have a virtual machine named ubuntu06e8a982 that had one disk and you have just added a second one. Your primary disk is /dev/sda and the disk that was just added would be visible as /dev/sdb (make sure you have rescaned the ISCSI bus or rebooted the virtual machine). To see if the disk is visible you can run the following command:

### sudo ls /dev/sd*
/dev/sda /dev/sda1 /dev/sda2 */dev/sdb*

Now to expand the filesystem you have to create a physical volume on the newly created disk. Then you have to extend the existing volume group with the physical disk and extend the root logical volume to the maximum available space that the volume group has. The last thing to do is to resize the filesystem on the logical volume. All of those commands are listed below:

### sudo pvcreate /dev/sdb
  Physical volume "/dev/sdb/" successfully created
### sudo vgextend *ubuntu06e8a982* /dev/sdb
  Volume group "ubuntu06e8a982" successfully extended
### sudo lvextend -l +100%FREE /dev/*ubuntu06e8a982*/root
  Size of logical volume ubuntu06e8a982.root changed from XX GiB (x extents) to YY GiB (y extents).
### sudo btrfs filesystem resize max /
  Resize ‘/‘ of ‘max’

Use the following command to check if the root logical volume did expand properly and if the free space was properly added:

### df -h

Expanding storage with persisting data

To expand disk size edit a virtual machine and increase the size by dragging the storage sliders. Next confirm the selected size. The disk will be expanded, yet still you have to expand the partition inside the operating system.

Caution: You can only expand disk space. You cannot shrink it.

Disks can be identified by their SCSI identification in Virtual Machine edit info: Virtual Machine SCSI Info

Storage change request will impact the Virtual Machine hourly price in accordingly to the size and current pricing.

SCSI bus number and disk number (Windows)

Information can be found in Disk Device properties in Disk Management add-on.

Windows SCSI ID

Please send whole content of 'Location' row.

SCSI bus number and disk number (Linux)

You can get these information using commands below:

user@ubuntu ~ $ ls /dev/disk/by-path/ -l
total 0
lrwxrwxrwx 1 root root  9 Apr 25  2018 pci-0000:00:10.0-scsi-0:0:0:0 -> ../../sda
lrwxrwxrwx 1 root root  9 Apr 25  2018 pci-0000:00:10.0-scsi-0:0:1:0 -> ../../sdb
lrwxrwxrwx 1 root root  9 Apr 25  2018 pci-0000:00:10.0-scsi-0:0:2:0 -> ../../sdc
lrwxrwxrwx 1 root root  9 Apr 25  2018 pci-0000:00:10.0-scsi-0:0:3:0 -> ../../sdc

Or

user@ubuntu ~ $ cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
  Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
  Type:   CD-ROM                           ANSI  SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02
Host: scsi2 Channel: 00 Id: 00 Lun: 00
  Vendor: VMware   Model: Virtual disk     Rev: 1.0
  Type:   Direct-Access                    ANSI  SCSI revision: 02

Send outputs of the above commands along with which disk sdX you want to expand.

Extending partitions in operating system (Windows)

Select Extend Volume by right clicking on a selected disk in Disk Management add-on. If the extended capacity if not shown, refresh the add-on. Windows SCSI resize 1

Next, extend the disk to the maximum available size: Windows SCSI resize 2

Storage space on that partition is extended to selected size. Windows SCSI resize 3

Extending partitions in operating system (Linux)

After extending the selected disk you have to expand it in the operating system's partitions. To do so, firstly, you have to refresh the disk size available to the operating system (replace sdX with your disk id, for example sdb).

root@ubuntu ~ $ echo 1 >> /sys/block/sdX/device/rescan

Next resize the physical volume and extend your root volume. Remember to choose apropriate name for sdX and lvextend command. The last step extends the file system.

root@ubuntu ~ $ pvresize /dev/sdX
root@ubuntu ~ $ lvextend -l +100%FREE /dev/ubuntu/root
root@ubuntu ~ $ btrfs filesystem resize max /

After running above commands, the root partition is resized to maximum available size.

Remove disk from virtual machine

To remove disk from a virtual machine, open the virtual machine details, click on Edit icon and click on the Delete button next to the disk you wish to remove. Disk will be removed from your machine after clicking Confirm button. If you want to discard changes, click Discard button.

Disk will be hot removed from your virtual machine, i.e. there is no need for machine rebooting. To securely remove the disk from a virtual machine, you must backup all of your data stored on that disk and unmount it from the file system!

Remove disk from virtual machine

To securely remove the disk from the virtual machine you have to clear the data from the removed disk and make sure that you will have enough free space to migrate your data to other disks! Lets assume that we have a virtual machine ubuntu06e8a982 with two disks /dev/sda and /dev/sdb with single btrfs partition on the top of LVM volume and we want to remove the /dev/sdb disk.

NOTE:: Real available data space is avg. 94-96 % of disk size. NOTE:: Because LVM needs some space for configuration data we should try shrink our volumes to approximately 90% of target space. NOTE:: After disk removal procedure we can try to reclaim our 4-6 % of usable space (at the end of this document).

Firstly we have to shrink existing filesystem to target size. If our /dev/sda disk have 10 GiB and /dev/sdb have 20 GiB (so our partition total size is 30 GiB) we need to shrink filesystem to 10 GiB.

### sudo btrfs filesystem resize 9G /
  Resize ‘/‘ of ’9G’

Next we have to shrink LVM logical volume (LVM virtual partition)

### sudo lvreduce /dev/*ubuntu06e8a982*/root -L 9G
    WARNING: Reducing active and open logical volume to 9.00 GiB
    THIS MAY DESTROY YOUR DATA (filesystem etc.)
  Do you really want to reduce root? [y/n]: *y*
  Size of logical volume *ubuntu06e8a982*/root changed from 29.77 GiB (7621 extents) to 9.00 GiB (2304 extents).
  Logical volume root successfully resized.

Next we have to move the LVM scattered data off /dev/sdb so that we can remove it from the volume group:

### sudo pvmove /dev/sdb

If we do not have enough free space the command will output:

### sudo pvmove /dev/sdb
  No extents available for allocation

Next we have to remove physical volume from LVM volume group

### sudo vgreduce *ubuntu06e8a982* /dev/sdb
  Removed “/dev/sdb” from volume group “*ubuntu06e8a982*”

Last what we have to do is to remove LVM physical volume marks from /dev/sdb device

### sudo pvremove /dev/sdb
  Labels on physical volume “/dev/sdb” successfully wiped

Recover 4-6 % of usable data after disk removal (OPTIONAL)

If we want to recover lost disk space in the result of shrink procedure we need to follow this steps:

### sudo lvextend -l +100%FREE /dev/*ubuntu06e8a982*/root
  Size of logical volume ubuntu06e8a982.root changed from XX GiB (x extents) to YY GiB (y extents).
  Logical volume root successfully resized.
### sudo btrfs filesystem resize max /
  Resize ‘/‘ of ‘max’

Power control

Power on virtual machine

To power on virtual machine:

  • Use fast action buttons available for every machine in graphical view

Power on virtual machine fast action buttons

  • Use the fast action buttons available in table view,

Power on virtual machine fast action buttons

  • Open virtual machine details and click on Power on icon.

Power on virtual machine icon

Suspend virtual machine

To suspend virtual machine:

  • Use fast action buttons available after you hover on virtual machine icon in icon view,

Suspend virtual machine fast action buttons

  • Use fast action buttons available in table view.

Suspend virtual machine fast action buttons

  • Open a virtual machine details and click on Suspend icon.

Suspend virtual machine icon

Reboot virtual machine

To reboot virtual machine:

  • Use the fast action buttons available after you hover on the virtual machine icon in icon view,

Reboot virtual machine fast action buttons

  • Use fast action buttons available in table view.

Reboot virtual machine fast action buttons

  • Open the virtual machine details and click on Reboot icon.

Reboot virtual machine icon

Power off virtual machine

To power off virtual machine:

  • Use the fast action buttons available after you hover on the virtual machine icon in icon view,

Power off virtual machine fast action buttons

  • Use fast action buttons available in table view,

Power off virtual machine fast action buttons

  • Open virtual machine details and click on Power off icon.

Power off virtual machine icon

Snapshots

Snapshots are point in time copies of your virtual machine. They are mostly used before performing invasive actions inside of virtual machine operating system.

Create virtual machine snapshot

To create virtual machine snapshot, open virtual machine details, click on Snapshots icon and click on Create button.

Create virtual machine snapshot

Revert virtual machine from snapshot

To revert a virtual machine from snapshot, open the virtual machine details, click on Snapshots icon and click on Revert button.

Revert virtual machine from snapshot

Delete virtual machine snapshot

To delete virtual machine snapshot, open the virtual machine details, click on Snapshots icon and click on Delete button.

Delete virtual machine snapshot

Deleting virtual machine

Deleting a virtual machine is irreversible! To delete a virtual machine, open virtual machine details and click on the Delete icon.

Delete virtual machine snapshot

Still need help? support@onestepcloud.com
Last updated on 16th Mar 2020