1

We have a Citrix XenServer pool with 3 hosts, using a shared NFS Storage Repository for our VMs.

The SR is hosted on a Windows 2003 Storage Server blade, that was included with our 3000 series HP Blade enclosure.

I've just been having a look over the Storage Server and have noticed the disk containing the NFS share is very fragmented.

I have a few questions.

Is running the standard Windows defrag going to be sufficient to deal with this?

Is anyone else running a similar setup, experienced a similiar problem and what have you done? I'm planning to automate the process, and am wondering if I need to suspend, or shutdown VMs while the defrag is in process.

Why is this occurring, and are there specific things I can do in provisioning new VMs to prevent this from happening?

Any thoughts would be welcomed.

Thanks,

Luke

LukeR
  • 3,086
  • 2
  • 29
  • 25

1 Answers1

4

It should be fine doing a defrag of the drive online, since the Xen disk images are just files like any other. You should try to do this off hours as performance will likely suffer greatly during the defrag.

The reason you're seeing high fragmentation is that VDIs are sparse disk images. Even though you specify a VM has (for example) 100 GB of space allocated, the disk image will initially allocate only a minimal amount of space. It will then grow as needed up to a maximum of the allocated size. The problem with this approach is that if you have a lot of VMs on the same storage device and they're all growing their disks at different times, there is no way the disk image files will be able to be contiguous on disk and thus will become very fragmented.

The solution to this would be to not use sparse images, but unfortunately it seems that as of XenServer 5.0 the only VDI type you can make is sparse.

You have a couple of options I can think of off the bat: * If possible, use raw block devices with the LVM format. I'm not familiar enough with Windows 2003 Storage Server to know if this is possible. If it allows you to make volumes an export them through iSCSI or FC, you're all set. Otherwise you might need to look at changing to some other shared-storage setup or something else. * Preallocate all the disk space in your VHD. Essentially this means just fill up all the available space in the volume before installing your OS. You can boot a Linux LiveCD or something and use dd to write zeros over the whole disk. This will cause XenServer to grow the disk image file to the full maximum size, and hopefully most of it will be contiguous since it is all being done at once.

The fragmentation problem you're seeing is not uncommon for using sparse file based storage for VM's, and is exactly the reason why I prefer to use LUNs on a SAN for VM storage instead.

Kamil Kisiel
  • 11,946
  • 7
  • 46
  • 68