Index: trunk/src/VBox/Runtime/common/dvm/dvm.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dvm/dvm.cpp	(revision 41094)
+++ trunk/src/VBox/Runtime/common/dvm/dvm.cpp	(revision 41549)
@@ -469,5 +469,4 @@
 {
     int rc = VINF_SUCCESS;
-    bool fAllocated = false;
     PRTDVMINTERNAL       pThis = hVolMgr;
     AssertPtrReturn(pThis, VERR_INVALID_HANDLE);
@@ -478,57 +477,72 @@
                  VERR_INVALID_PARAMETER);
 
-    while (   cb > 0
-           && !fAllocated)
-    {
-        PRTDVMVOLUMEINTERNAL pVol;
-        bool fVolFound = false;
-        uint64_t cbIntersect;
-        uint64_t offVol;
-
-        /*
-         * Search through all volumes. It is not possible to
-         * get all start sectors and sizes of all volumes here
-         * because volumes can be scattered around the disk for certain formats.
-         * Linux LVM is one example, extents of logical volumes don't need to be
-         * contigous on the medium.
-         */
-        RTListForEach(&pThis->VolumeList, pVol, RTDVMVOLUMEINTERNAL, VolumeNode)
+    /* Check whether the range is inuse by the volume manager metadata first. */
+    rc = pThis->pDvmFmtOps->pfnQueryRangeUse(pThis->hVolMgrFmt, off, cb, pfAllocated);
+    if (RT_FAILURE(rc))
+        return rc;
+
+    if (!*pfAllocated)
+    {
+        bool fAllocated = false;
+
+        while (   cb > 0
+               && !fAllocated)
         {
-            bool fIntersect = pThis->pDvmFmtOps->pfnVolumeIsRangeIntersecting(pVol->hVolFmt, off,
-                                                                              cb, &offVol,
-                                                                              &cbIntersect);
-            if (fIntersect)
+            PRTDVMVOLUMEINTERNAL pVol;
+            bool fVolFound = false;
+            uint64_t cbIntersect;
+            uint64_t offVol;
+
+            /*
+             * Search through all volumes. It is not possible to
+             * get all start sectors and sizes of all volumes here
+             * because volumes can be scattered around the disk for certain formats.
+             * Linux LVM is one example, extents of logical volumes don't need to be
+             * contigous on the medium.
+             */
+            RTListForEach(&pThis->VolumeList, pVol, RTDVMVOLUMEINTERNAL, VolumeNode)
             {
-                fVolFound = true;
-                if (pVol->pfnQueryBlockStatus)
+                bool fIntersect = pThis->pDvmFmtOps->pfnVolumeIsRangeIntersecting(pVol->hVolFmt, off,
+                                                                                  cb, &offVol,
+                                                                                  &cbIntersect);
+                if (fIntersect)
                 {
-                    bool fVolAllocated = true;
-
-                    rc = pVol->pfnQueryBlockStatus(pVol->pvUser, offVol, cbIntersect,
-                                                   &fVolAllocated);
-                    if (RT_FAILURE(rc))
-                        break;
+                    fVolFound = true;
+                    if (pVol->pfnQueryBlockStatus)
+                    {
+                        bool fVolAllocated = true;
+
+                        rc = pVol->pfnQueryBlockStatus(pVol->pvUser, offVol, cbIntersect,
+                                                       &fVolAllocated);
+                        if (RT_FAILURE(rc))
+                            break;
+                        else if (fVolAllocated)
+                        {
+                            fAllocated = true;
+                            break;
+                        }
+                    }
+                    else if (!(pThis->fFlags & DVM_FLAGS_NO_STATUS_CALLBACK_MARK_AS_UNUSED))
+                        fAllocated = true;
+                    /* else, flag is set, continue. */
+
+                    cb  -= cbIntersect;
+                    off += cbIntersect;
+                    break;
                 }
-                else if (!(pThis->fFlags & DVM_FLAGS_NO_STATUS_CALLBACK_MARK_AS_UNUSED))
+            }
+
+            if (!fVolFound)
+            {
+                if (pThis->fFlags & DVM_FLAGS_UNUSED_SPACE_MARK_AS_USED)
                     fAllocated = true;
-                /* else, flag is set, continue. */
-
-                cb  -= cbIntersect;
-                off += cbIntersect;
-                break;
+
+                cb  -= pThis->DvmDisk.cbSector;
+                off += pThis->DvmDisk.cbSector;
             }
         }
 
-        if (!fVolFound)
-        {
-            if (pThis->fFlags & DVM_FLAGS_UNUSED_SPACE_MARK_AS_USED)
-                fAllocated = true;
-
-            cb  -= pThis->DvmDisk.cbSector;
-            off += pThis->DvmDisk.cbSector;
-        }
-    }
-
-    *pfAllocated = fAllocated;
+        *pfAllocated = fAllocated;
+    }
 
     return rc;
Index: trunk/src/VBox/Runtime/common/dvm/dvmbsdlabel.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dvm/dvmbsdlabel.cpp	(revision 41094)
+++ trunk/src/VBox/Runtime/common/dvm/dvmbsdlabel.cpp	(revision 41549)
@@ -343,4 +343,18 @@
 }
 
+static DECLCALLBACK(int) rtDvmFmtBsdLblQueryRangeUse(RTDVMFMT hVolMgrFmt,
+                                                     uint64_t off, uint64_t cbRange,
+                                                     bool *pfUsed)
+{
+    PRTDVMFMTINTERNAL pThis = hVolMgrFmt;
+
+    if (off <= RTDVM_BSDLBL_LBA2BYTE(1, pThis->pDisk))
+        *pfUsed = true;
+    else
+        *pfUsed = false;
+
+    return VINF_SUCCESS;
+}
+
 DECLCALLBACK(uint32_t) rtDvmFmtBsdLblGetValidVolumes(RTDVMFMT hVolMgrFmt)
 {
@@ -513,4 +527,6 @@
     /* pfnClose */
     rtDvmFmtBsdLblClose,
+    /* pfnQueryRangeUse */
+    rtDvmFmtBsdLblQueryRangeUse,
     /* pfnGetValidVolumes */
     rtDvmFmtBsdLblGetValidVolumes,
Index: trunk/src/VBox/Runtime/common/dvm/dvmgpt.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dvm/dvmgpt.cpp	(revision 41094)
+++ trunk/src/VBox/Runtime/common/dvm/dvmgpt.cpp	(revision 41549)
@@ -342,4 +342,18 @@
 }
 
+static DECLCALLBACK(int) rtDvmFmtGptQueryRangeUse(RTDVMFMT hVolMgrFmt,
+                                                  uint64_t off, uint64_t cbRange,
+                                                  bool *pfUsed)
+{
+    PRTDVMFMTINTERNAL pThis = hVolMgrFmt;
+
+    if (off < 33*pThis->pDisk->cbSector)
+        *pfUsed = true;
+    else
+        *pfUsed = false;
+
+    return VINF_SUCCESS;
+}
+
 static DECLCALLBACK(uint32_t) rtDvmFmtGptGetValidVolumes(RTDVMFMT hVolMgrFmt)
 {
@@ -531,4 +545,6 @@
     /* pfnClose */
     rtDvmFmtGptClose,
+    /* pfnQueryRangeUse */
+    rtDvmFmtGptQueryRangeUse,
     /* pfnGetValidVolumes */
     rtDvmFmtGptGetValidVolumes,
Index: trunk/src/VBox/Runtime/common/dvm/dvmmbr.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dvm/dvmmbr.cpp	(revision 41094)
+++ trunk/src/VBox/Runtime/common/dvm/dvmmbr.cpp	(revision 41549)
@@ -212,4 +212,19 @@
 }
 
+static DECLCALLBACK(int) rtDvmFmtMbrQueryRangeUse(RTDVMFMT hVolMgrFmt,
+                                                  uint64_t off, uint64_t cbRange,
+                                                  bool *pfUsed)
+{
+    PRTDVMFMTINTERNAL pThis = hVolMgrFmt;
+
+    /* MBR uses the first sector only. */
+    if (off < 512)
+        *pfUsed = true;
+    else
+        *pfUsed = false;
+
+    return VINF_SUCCESS;
+}
+
 static DECLCALLBACK(uint32_t) rtDvmFmtMbrGetValidVolumes(RTDVMFMT hVolMgrFmt)
 {
@@ -399,4 +414,6 @@
     /* pfnClose */
     rtDvmFmtMbrClose,
+    /* pfnQueryRangeUse */
+    rtDvmFmtMbrQueryRangeUse,
     /* pfnGetValidVolumes */
     rtDvmFmtMbrGetValidVolumes,
Index: trunk/src/VBox/Runtime/common/dvm/dvmvfs.cpp
===================================================================
--- trunk/src/VBox/Runtime/common/dvm/dvmvfs.cpp	(revision 41094)
+++ trunk/src/VBox/Runtime/common/dvm/dvmvfs.cpp	(revision 41549)
@@ -93,5 +93,4 @@
 
     Assert(pSgBuf->cSegs == 1);
-    Assert(off < 0);
     NOREF(fBlocking);
 
@@ -149,5 +148,4 @@
 
     Assert(pSgBuf->cSegs == 1);
-    Assert(off < 0);
     NOREF(fBlocking);
 
