[Libguestfs] [PATCH 2/2] v2v: Add -o discard option when fstrimming.

Richard W.M. Jones rjones at redhat.com
Fri Aug 12 09:37:30 UTC 2016


This *may* be required by some filesystems in order for fstrim to
work.  I'm not actually sure if this is true, but it's what
virt-sparsify --in-place does, and that utility has been tested a lot
more in regards to trimming.
---
 v2v/v2v.ml | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/v2v/v2v.ml b/v2v/v2v.ml
index 8365aae..8ae3dec 100644
--- a/v2v/v2v.ml
+++ b/v2v/v2v.ml
@@ -393,7 +393,10 @@ and do_fstrim g inspect =
   List.iter (
     fun dev ->
       g#umount_all ();
-      let mounted = try g#mount dev "/"; true with G.Error _ -> false in
+      let mounted =
+        try g#mount_options "discard" dev "/"; true
+        with G.Error _ -> false in
+
       if mounted then (
         try g#fstrim "/"
         with G.Error msg ->
-- 
2.7.4




More information about the Libguestfs mailing list