Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.



share|improve this question
up vote 4 down vote accepted

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.

share|improve this answer
Great answer! Thanks for taking the time. – LukeR Jul 23 '09 at 1:40

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.