«

»

Jun 03

Using linux vmfs-tools package to access virtual machines

Recently whilst doing some research on another VMware related topic I came across the name of a new package on my ubuntu 10.04 desktop. It is called vmfs-tools and it caught my attention.

So to cut a long story short, here I am today, testing out what this package can do for a vSphere administrator.

As of today it allows you – amongst other things to gain read access to a VMFS volume from a Linux desktop.

The home page of the project explains that the code is loosely based on the vmfs code from fluidOps and that it is included in some major linux distributions such as the current LTS ubuntu 10.04 release, further it is easy to setup and use.

So here we go, let’s have a look at this from my ubuntu 10.04 desktop.

Installing vmfs-tools

The first thing we do is install the packages by using apt-get.

The package is in the so called universe repository, so you’ll have to “enable universe” before you can install and run it.
To do so, System menu > Administration > Software Sources > check “Community maintained software” checkbox
Then click “Close” and “reload” when it asks for a reload.

 ~$ sudo apt-get install vmfs-tools
 Reading package lists... Done
 Building dependency tree
 Reading state information... Done
 The following NEW packages will be installed:
 vmfs-tools
 0 upgraded, 1 newly installed, 0 to remove and 37 not upgraded.
 Need to get 0B/87.1kB of archives.
 After this operation, 246kB of additional disk space will be used.
 Selecting previously deselected package vmfs-tools.
 (Reading database ... 145588 files and directories currently installed.)
 Unpacking vmfs-tools (from .../vmfs-tools_0.2.0-1_amd64.deb) ...
 Processing triggers for man-db ...
 Setting up vmfs-tools (0.2.0-1) ...

Ok now that we have it, lets see what is in the package:

 ~$ dpkg -L vmfs-tools
 /.
 /usr
 /usr/sbin
 /usr/sbin/debugvmfs
 /usr/sbin/fsck.vmfs
 /usr/sbin/vmfs-fuse
 /usr/share
 /usr/share/man
 /usr/share/man/man8
 /usr/share/man/man8/debugvmfs.8.gz
 /usr/share/man/man8/vmfs-fuse.8.gz
 /usr/share/doc
 /usr/share/doc/vmfs-tools
 /usr/share/doc/vmfs-tools/copyright
 /usr/share/doc/vmfs-tools/changelog.Debian.gz

what the above tells me is that we have three commands, debugvmfs, fsck.vmfs and vmfs-fuse and that there are man pages (Linux Help files) for both debugvmfs and vmfs-fuse.

Using vmfs-tools

Now let’s see what disk we want to mount by using the fdisk -l command.  For the none Linux experts what this does is simply list out the partition on my local disk.  I stripped out the other disks from the output to keep the output readable.

 ~$ sudo fdisk -l
 Disk /dev/sdb: 160.0 GB, 160041885696 bytes
 255 heads, 63 sectors/track, 19457 cylinders
 Units = cylinders of 16065 * 512 = 8225280 bytes
 Sector size (logical/physical): 512 bytes / 512 bytes
 I/O size (minimum/optimal): 512 bytes / 512 bytes
 Disk identifier: 0x49e2fd2f
 Device Boot      Start         End      Blocks   Id  System
 /dev/sdb1   *           1         140     1124518+  83  Linux
 /dev/sdb2             141         154      112455   fc  VMware VMKCORE
 /dev/sdb3             155       19457   155051347+   f  W95 Ext'd (LBA)
 /dev/sdb5             155       19457   155051316   fb  VMware VMFS

the above shows that the vmfs file system is situated on a logical partition on /dev/sdb5

Now there are a number of commands we can execute via debugvmfs without even mounting the disk.
Let’s try the “df -h” command and see the result.

 ~$ sudo debugvmfs /dev/sdb5 df -h
 Block size       : 1048576 bytes
 Total blocks     : 151296
 Total size       : 151296 Mb
 Allocated blocks : 18949
 Allocated space  : 18949 Mb
 Free blocks      : 132347
 Free size        : 132347 Mb

I previously set up a new folder called /opt/vmfs on my linux host,  so let’s mount the disk and see what happens.

 ~$ sudo vmfs-fuse /dev/sdb5 /opt/vmfs

No errors which is good.

 ~$ ls /opt/vmfs -alh
 ls: cannot access /opt/vmfs: Permission denied

Ah OK, but I’ve setup my /opt/vmfs folder with root privileges, so that’s normal.

 ~$ sudo ls /opt/vmfs -alh
 total 4.0K
 drwxr-xr-t 4 root root 1.6K 2010-06-01 16:40 .
 drwxr-xr-x 5 root root 4.0K 2010-06-02 12:35 ..
 drwxr-xr-x 2 root root 3.3K 2010-06-03 13:40 BrowserApp
 -rw-r--r-- 1 root root 1.5G 2010-06-01 16:22 BrowserApp-201001.tar.gz
 -rw-r--r-- 1 root root   59 2010-06-01 16:22 BrowserApp-201001.tar.gz.md5sum
 drwxr-xr-x 4 root root  840 2009-08-04 20:11 esxconsole-4b7875de-7178-3318-ccd9-0019a10f3bc0
 -r-------- 1 root root 832K 2009-08-04 19:58 .fbb.sf
 -r-------- 1 root root  61M 2009-08-04 19:58 .fdc.sf
 -r-------- 1 root root 244M 2009-08-04 19:58 .pbc.sf
 -r-------- 1 root root 249M 2009-08-04 19:58 .sbc.sf
 -r-------- 1 root root 4.0M 2009-08-04 19:58 .vh.sf

:O Holy guacamole, that looks impressive.

Verifying functionality

My ESX4 test environment here doesn’t have many VM’s on local storage. But for some of the larger files on there, I have made md5sums via the console in ESX.
I’ve compared those to see if the fuse driver is seeing the same bits and bytes as my vSphere setup.

 ~$ sudo cat /opt/vmfs/BrowserApp-201001.tar.gz.md5sum
 e1cec95a422396bf9e7bb1bec457ed0a  BrowserApp-201001.tar.gz
 ~$ sudo md5sum /opt/vmfs/BrowserApp-201001.tar.gz
 e1cec95a422396bf9e7bb1bec457ed0a  /opt/vmfs/BrowserApp-201001.tar.gz

Sure enough they match. I’ve tested other files and so far things look very good.

So far the driver is read only, so i cannot directly start a guest via vmplayer (which you should not do anyways), but it does give me an easy means to copy a file from the vmfs partition without having to obtain an ESX bootable CD.
What does that mean? Well it does mean that I can hook up a disk (or array) to just about any motherboard – HCL or not – and get at my virtual machines. Other possible uses are mounting your linux hosted iSCSI array from within linux. Using a linux live CD to copy your VMs to an external USB disk without having to jump through hoops.

This is a very nice tool to have, well done!

4 comments

1 ping

Skip to comment form

  1. Jason Ruiz

    Would be interesting to see this built into the kernel with write ability, would make things easier for copying to iSCSI VMFS datastores for Linux users.

  2. Ulli Hankeln

    Thanks for the test – Wil.
    Looks like this is easier to use then the Fvmfs Java driver http://code.google.com/p/vmfs/

    Did you copy large amounts of data yet ? – would like to know which one of the two options is faster – I would expect the fuse one to be faster …

    Anyway – this is a nice addition to MOA ;-)

    Ulli

  3. Wil van Antwerpen

    Hi Ulli,

    Thanks. Speed seems to be reasonable. On my crappy test rig, copying data from an old local SATA I disk hosting vmfs storage to a fake RAID I ext3 storage goes at around 26Mb/sec for a 1.5GB file and at 28Mb/sec for a 5GB file..
    It’s not spectacular speed, but the machine is not a real performance beast either.

    For comparison I copied a 677MB file from an ext3 partition on local PATA and that went at 32Mb/sec. Another comparison was copying some larger files from a SATA II based RAID I ntfs partition and then the copying went at a speed of 61 Mb/sec.
    So with this very unscientific approach I’d say that the speed is fairly good and that the somewhat slow copying speed is mostly due to the crappy SATA I drive hosting the local vmfs storage.

  4. Ulli Hankeln

    Wil – you mentioned ” … so i cannot directly start a guest via vmplayer”

    I am not sure if that is the whole story – I am sure it can be done – but it is quite tricky ;-)
    I’ll test with MOA and let you know

    Ulli

  1. Tweets that mention Using linux vmfs-tools package to access virtual machines | PlanetVM -- Topsy.com

    [...] This post was mentioned on Twitter by tom_howarth and PlanetVM Net, Wil van Antwerpen. Wil van Antwerpen said: I just posted: Using linux vmfs-tools package at http://planetvm.net/blog/?p=1592 [...]

Comments have been disabled.