How To Convert A Linux Disk Or Image File To VMDK File

In this post I will show you how to convert a Linux disk or raw image file to a VMDK file so you can create a VMWare Workstation virtual machine from it. The basic steps are creating a raw image file of the physical disk using dd and converting the raw image file to a VMware disk/vmdk file. I was using Windows to do this but I’ll mention some Linux instructions as well.

Why this scenario

For on-line Linux machines you can use vCenter Converter to create a virtual machine the catch is it only supports ESXi. In my case I had to create a virtual machine from a disk /off-line machine for VMware Workstation on a Windows machine. At the time I couldn’t find a free native Windows tool that would create a raw image of the  Linux disk. Potentially you could use disk imaging software to clone the disk in a virtual machine but the free Windows ones I tried didn’t have the necessary drivers included in their boot environments for VMWare disk controllers.

Creating the raw image file

To run dd on Windows requires Cygwin, there are no additional settings or packages required. I just accepted all the defaults during installation. It is important to run Cygwin as administrator in Windows or you will get permission denied errors in Linux when you run dd. Once inside Cygwin run the following to identify your attached disks:

cd /dev
ls -la

The device name of your disks will depend on the type and number of attached devices, in my case it was /dev/sdc (the third disk). You can read about Linux device naming here. I wanted to write the image file to my Windows D: drive which will be mounted as /cygdrive/d. Once you identified the source and destination you can run dd to create the image file.

dd if=/dev/sdc of=/cygdrive/d/diskimage.img

Note: I looked into using Windows Subsystem for Linux instead of Cygwin but from what I Googled WSL doesn’t have the ability to address block devices so dd won’t work.

Converting the raw image file to VMDK

I used Starwind V2V Converter to convert the raw img file to a VMDK file, it is free but you have to supply some personal details to get the download link. The app is easy enough to use so I won’t show all the steps here, just choose Local file for the source and Local file VMDK as the destination. Starwind V2V has the option to convert a physical disk to a VMDK file but it didn’t show my Linux disks as a source, only the Windows ones.

On Linux you can use Qemu to convert img files to VMDK and other virtual disk formats. You can also use Qemu to convert a physical disk directly to VMDK file without creating the raw image file first.

I looked into using Qemu in Cygwin instead of Starwind V2V Converter but at the time Qemu packages weren’t available for Cygwin but I guess you could compile it from source and install the dependencies if you really want to go that way.

Creating the VM

Once you have the VMDK file you can create a new Linux virtual machine in VMWare Workstation. Be sure to match the Linux distribution of your source machine. I was converting an Ubuntu machine and it booted successfully without any additional work.

LinuxVM

The final step is to install  open-vm-tools for desktop or server.

#Desktop
sudo apt install open-vm-tools-desktop
#Server
sudo apt install open-vm-tools

Francois Delport

Azure Disk And SQL Configuration Options In Azure Portal

In this post I’m going to take a closer look at Azure Disk and SQL configuration options in Azure Portal. Microsoft recently added some more configuration options for creating SQL virtual machines using the Azure Resource Manager (ARM) deployment model in the preview portal.

When you create a SQL VM you can specify connectivity options, SQL authentication, automatic patching, automatic backups, key vault integration and storage optimisation. Note this is only for SQL 2014 using ARM and Premium Storage for storage optimisation.

In this post I’m going to focus on the storage optimisation settings, the others are pretty much self explanatory and you can read more about all of the settings here.

Disk Performance
First a detour to talk about VM storage performance, independent of SQL. The type of VM you choose determines how many disks you can connect to a VM, the max IOPS on a disk or VM and whether you can use Premium Storage. You can read the details here but in short size A, D, Dv2, G is limited to 500 IOPS per disk, the number of disks you can have varies greatly from 1 to 64. DS and GS can use Premium Storage with 50 000 and 80 000 max IOPS per VM, the number of disks also varies greatly from 2 to 64. The throughput and IOPS per disk depends on the size of the Premium Storage disk you select, 128GB is 500 IOPS 100MB/s, 512GB is 2300 IOPS 150 MB/s and 1025GB is 5000 IOPS 200MB/s. Azure rounds the size of your disk up to the closest premium disk size, you can read the details here.

SQL Server Specified IOPS
If a single disk doesn’t provide the IOPS you require you can stripe multiple disks together using Storage Spaces to increase performance. This happens automatically when you specify the required IOPS when you create your SQL server VM. In the examples below the max IOPS is limited by the type of VM chosen DS2 or DS14.

Azure Disk And SQL Configuration Options In Azure Portal

Based on the required 51200 IOPS we selected you will see 11 disks added to the DS14 machine in the Storage Manager.

Azure Disk And SQL Configuration Options In Azure Portal

If you run:

Get-VirtualDisk | format-list

from a PowerShell command prompt you will see the virtual disk has 11 columns, meaning data written to the disk will be striped into 11 blocks, each block written to a single underlying disk.

If for some reason you can’t use Premium Storage you can do the same with Standard Storage data disks but you have to do it yourself after the VM is created. When you create the virtual disk make sure the number of columns match the number of disks for maximum performance.

When adding multiple disks to a VM keep in mind the IOPS limit on each disk and also the VM IOPS limit that overrides the disk IOPS limit.

Disk Caching
When you create a disk in Azure you can choose what type of caching you want for the disk.

Azure Disk And SQL Configuration Options In Azure Portal
The data disks (not the OS disk) added to the SQL VM are all set to use read-only cache by default, this might seem counter intuitive to using read/write cache but there is a good reason. SQL uses write-through writes which bypasses cache anyway and goes directly to Azure Storage instead of local cache. Secondly there is no artificial limit imposed on read-only cache thus you can get very good read performance with read-only cache but write cache is limited to 4000 IOPS.

Francois Delport