2

I'm using sparse raw image files for guest VMs and OCFS2 on the host (local-only, not clustered) for the reflink feature. I understand from Googling around that OCFS2 is one of the filesystems that can punch holes back into sparse files.

If I understand correctly, it may be possible (and apparently can be achieved with XFS) to combine this feature with TRIM/discard support in the guest machines so that when files in the guest are deleted, space on the host is automatically reclaimed. However despite much experimentation, I haven't been able to demonstrate this working.

Is this possible, and if it depends on versions of the kernel and/or QEMU, what are the minimum versions I need? Also have I missed anything with the configuration? I've:

  • mounted the (ext4) guest filesystem with the discard option in /etc/fstab
  • tried the current beta of Debian Wheezy for host and guest, and CentOS 6.2 for host
  • tried running fstrim on the guest (I get FITRIM ioctl failed: Operation not supported—but I'm not 100% sure if this is relevent)
  • tried bus=ide and bus=virtio (with CentOS 6.2 host)
0

1 Answer 1

3

You should be able to recover space by using virtio-scsi devices and specifying discard=unmap in the libvirt definition for the disk.

I haven't tried this in CentOS/RHEL but I did get this to work in later versions of Fedora. I wrote a blog post about it.

I would say to give it a try and see if it works.

1
  • I won't be able to test exactly as I've moved away from raw files (I'm using qed now), but thanks.
    – user12810
    Jul 25, 2013 at 20:32

You must log in to answer this question.