Table of Contents
- Introduction
- Requirements
- Locate Image
- Convert Image
- Upload Image
- Provision Server
- Provision Storage
- Provision Networking
- Configure VirtIO
- Support
Introduction
This tutorial is designed to assist in moving a virtual machine (VM) running Linux under the VMware hypervisor into the ProfitBricks cloud.
Requirements
Before you begin you will need to have signed-up for a ProfitBricks account. It will also help to be familiar with working inside the ProfitBricks Data Center Designer. You will need to have created a Data Center to hold the imported virtual machines.
Locate Image
The location of your existing VMare virtual machine image can be determined from inside vSphere.
The VMware image file will have a file extension of .vmdk
. You may choose to browse the datastore inside vSphere and bring it down to your workstation, or find some other means of transferring the .vmdk
file.
One method that can work well, especially with "thin-provisioned" virtual machines, is to use the File->Export->Export OVF Template menu option from inside vSphere.
This results in a locally stored copy of the .vmdk
file.
Convert Image
ProfitBricks is able to accept a direct upload of your .vmdk
image file. Therefore converting the virtual machine image to another format should NOT be required. However, if you run into issues getting your virtual machine image to appear in the "Image Manager", you could try converting it to another format.
VMware's vCenter Converter allows conversion between some disk image formats. Information is available at vCenter Converter.
Third-party tools also exist for virtual machine disk image conversion. One example is the StarWind V2V Image Converter. It is free for use after registering with StarWind Software.
The ProfitBricks system will automatically expand the image to its full size before you can use it in the DCD. If you have a 20GB virtual machine that was initially configured using "thin-provisioning", the .vmdk
file may be much smaller than 20GB. Regardless of the size uploaded, during the conversion process it will expand to the fully provisioned size.
Upload Image
The virtual machine image file needs to get loaded into your ProfitBricks account. This can be done via FTPS. Information on this process is available under FTP Access.
In this example, we will be uploading an image to the 'us/las' location for use in ProfitBricks data centers provisioned in Las Vegas regional facility. You will want to upload your images to the appropriate region for the data center you have created.
Once you establish the FTPS connection, you will see two directories: hdd-images/
and iso-images/
. Upload the virtual machine image file into hdd-images/
.
Depending on the size of your image file, the upload can take a significant amount of time to complete.
Shortly after the image has been uploaded, it will be available inside the Data Center Designer. The short delay is due to ProfitBricks scanning and preparing the image for use inside the DCD.
Provision Server
Create a server with resources similar to what your VM was using before. In this example, we are moving a VM that was provisioned with one processor core and 1024 MB of memory.
Provision Storage
Create a new storage volume, give it a descriptive name, and select the correct uploaded image from Own Images.
Now we can connect the storage volume to the server.
Provision Networking
Connect the new server to the Internet
We will utilize a DHCP address for this tutorial, so we simply connect the first NIC of the server to the network.
Configure VirtIO
To improve the performance of the VM, we need to make sure that it is using the virtio
drivers. This may require that some changes be made to your VM.
If your VM is running a recent Ubuntu distribution, like the one we uploaded above, it should boot successfully with the bus type set to the default, VirtIO. Recent versions of SUSE should also work without making any changes.
If your VM is running a recent RedHat/CentOS/Fedora distribution, it is likely that it did not boot successfully.
In CentOS 7, the VirtIO drivers should already be present on your system. The issue is that the drivers are not included in the Initramfs
file that is called during the boot process. Because they are not present the VM will be unable to locate the root file-system and therefore unable to boot.
For a CentOS 7 VM, you could end up with something like this on the console:
In order to resolve this, we need to change the Bus Type to IDE inside the DCD.
Once the changes have been provisioned, the server will be restarted and can be accessed from the DCD's console or ssh. We will make changes to /etc/dracut.conf
to include the virtio
kernel modules. Do this by editing the file and uncommenting the add_drivers+=
line and adding the virtio
modules like this:
# additional kernel modules to the default
add_drivers+="virtio virtio_blk virtio_net virtio_pci"
This screenshot shows the relevant section of the default /etc/dracut.conf
file:
This screenshot shows the necessary changes:
Save the changed /etc/dracut.conf
file and then run dracut -f
as root
to replace the current /boot/initramfs-<kernel version>
file. You have the option of generating a new file, rather than replacing the existing one. In this example we will just overwrite the existing Initramfs
. Passing the -f
option to the dracut
command accomplishes this.
[root@centos7-2 boot]# pwd
/boot
[root@centos7-2 boot]# ls -ltr initramfs*
-rw-r--r--. 1 root root 17334463 Jul 30 21:36 initramfs-3.10.0-229.7.2.el7.x86_64.img
[root@centos7-2 boot]# dracut -f
[root@centos7-2 boot]# ls -ltr initramfs*
-rw-r--r--. 1 root root 28974815 Jul 30 18:49 initramfs-0-rescue-3e708124ba7f44f5a680bc4f17893b7c.img
-rw-r--r--. 1 root root 11150984 Jul 30 18:54 initramfs-3.10.0-123.el7.x86_64.img
-rw-r--r--. 1 root root 17217610 Aug 3 15:19 initramfs-3.10.0-229.7.2.el7.x86_64.img
There is no console output generated from running dracut -f
, but we can see that the initramfs-3.10.0-229.7.2.el7.x86_64.img
file has changed in size and has an updated timestamp.
If it has been a while since you updated the kernel in your VM, you could also make the changes to /etc/dracut.conf
shown above, then utilize yum update
to update your kernel. Since dracut
is run as part of the kernel update process, your newly updated initramfs
would also contain the virtio
modules.
There are some additional settings that can be configured to optimize performance of your virtual machine in the ProfitBricks Cloud. If you have the bus type set to VirtIO already, then we just want to verify that the network MTU has been set to 64000. Here are some commands that will allow us to check the MTU setting:
[root@localhost ~]# ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 02:01:15:a1:a3:65 brd ff:ff:ff:ff:ff:ff
[root@localhost ~]# ip addr show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 02:01:15:a1:a3:65 brd ff:ff:ff:ff:ff:ff
inet 162.254.27.214/32 brd 162.254.27.214 scope global dynamic eth0
valid_lft 430sec preferred_lft 430sec
inet6 fe80::1:15ff:fea1:a365/64 scope link
valid_lft forever preferred_lft forever
In the output above, the MTU is set to 1500. It can be changed by running:
ip link set dev eth0 mtu 64000
and we can verify the change like this:
[root@localhost ~]# ip link show eth0
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 64000 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 02:01:15:a1:a3:65 brd ff:ff:ff:ff:ff:ff
Since we want the change to be permanant, add a MTU=64000
entry to /etc/sysconfig/network-scripts/ifcfg-eth0
.
If you are using NetworkManager
to manage your network interfaces, then the nmtui
command will allow you to manage the MTU setting.
For the Ubuntu distribution, the change would need to be made in /etc/network/interfaces
by adding MTU 64000
to the eth0
configuration block.
Depending on the distribution of Linux, there may be other ways to view and change the MTU setting. The ifconfig
and netstat -i
commands may be helpful in changing or verifying the MTU value on your system.
ProfitBricks has some additional information on VirtIO available at ProfitBricks VirtIO Help.
Support
If you have comments or questions, you are welcome to add them below or on the DevOps Community Site.