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.
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:
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
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.
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
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.
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
~$ sudo md5sum /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!