[Libguestfs] [PATCH v2 2/2] resize: expand f2fs partitions

Pino Toscano ptoscano at redhat.com
Thu Apr 12 14:25:50 UTC 2018


Use resize.f2fs (via f2fs_expand) to expand f2fs filesystems, if
available.
---
 resize/resize.ml       | 12 ++++++++++--
 resize/virt-resize.pod | 10 ++++++++--
 2 files changed, 18 insertions(+), 4 deletions(-)

diff --git a/resize/resize.ml b/resize/resize.ml
index 1a21e4dff..8e4bb1b16 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -136,7 +136,7 @@ let debug_logvol lv =
 
 type expand_content_method =
   | PVResize | Resize2fs | NTFSResize | BtrfsFilesystemResize | XFSGrowFS
-  | Mkswap
+  | Mkswap | ResizeF2fs
 
 let string_of_expand_content_method = function
   | PVResize -> s_"pvresize"
@@ -145,6 +145,7 @@ let string_of_expand_content_method = function
   | BtrfsFilesystemResize -> s_"btrfs-filesystem-resize"
   | XFSGrowFS -> s_"xfs_growfs"
   | Mkswap -> s_"mkswap"
+  | ResizeF2fs -> s_"resize.f2fs"
 
 type unknown_filesystems_mode =
   | UnknownFsIgnore
@@ -295,6 +296,8 @@ read the man page virt-resize(1).
         printf "btrfs\n";
       if g#feature_available [| "xfs" |] then
         printf "xfs\n";
+      if g#feature_available [| "f2fs" |] then
+        printf "f2fs\n";
       exit 0
     );
 
@@ -331,10 +334,11 @@ read the man page virt-resize(1).
     lv_expands, machine_readable, ntfsresize_force, output_format,
     resizes, resizes_force, shrink, sparse, unknown_fs_mode in
 
-  (* Default to true, since NTFS/btrfs/XFS support are usually available. *)
+  (* Default to true, since NTFS/btrfs/XFS/f2fs support are usually available. *)
   let ntfs_available = ref true in
   let btrfs_available = ref true in
   let xfs_available = ref true in
+  let f2fs_available = ref true in
 
   (* Add a drive to an handle using the elements of the URI,
    * and few additional parameters.
@@ -364,6 +368,7 @@ read the man page virt-resize(1).
     ntfs_available := g#feature_available [|"ntfsprogs"; "ntfs3g"|];
     btrfs_available := g#feature_available [|"btrfs"|];
     xfs_available := g#feature_available [|"xfs"|];
+    f2fs_available := g#feature_available [|"f2fs"|];
 
     g
   in
@@ -585,6 +590,7 @@ read the man page virt-resize(1).
       | ContentFS (("ntfs"), _) when !ntfs_available -> true
       | ContentFS (("btrfs"), _) when !btrfs_available -> true
       | ContentFS (("xfs"), _) when !xfs_available -> true
+      | ContentFS (("f2fs"), _) when !f2fs_available -> true
       | ContentFS _ -> false
       | ContentExtendedPartition -> false
       | ContentSwap -> true
@@ -600,6 +606,7 @@ read the man page virt-resize(1).
       | ContentFS (("ntfs"), _) when !ntfs_available -> NTFSResize
       | ContentFS (("btrfs"), _) when !btrfs_available -> BtrfsFilesystemResize
       | ContentFS (("xfs"), _) when !xfs_available -> XFSGrowFS
+      | ContentFS (("f2fs"), _) when !f2fs_available -> ResizeF2fs
       | ContentFS _ -> assert false
       | ContentExtendedPartition -> assert false
       | ContentSwap -> Mkswap
@@ -1368,6 +1375,7 @@ read the man page virt-resize(1).
         if new_uuid <> orig_uuid then
           warning (f_"UUID in swap partition %s changed from ‘%s’ to ‘%s’")
             target orig_uuid new_uuid;
+      | ResizeF2fs -> g#f2fs_expand target
     in
 
     (* Expand partition content as required. *)
diff --git a/resize/virt-resize.pod b/resize/virt-resize.pod
index f6aeb5706..720318c4d 100644
--- a/resize/virt-resize.pod
+++ b/resize/virt-resize.pod
@@ -156,7 +156,8 @@ to fill the rest of the available space:
 If the expanded partition in the image contains a filesystem or LVM
 PV, then if virt-resize knows how, it will resize the contents, the
 equivalent of calling a command such as L<pvresize(8)>,
-L<resize2fs(8)>, L<ntfsresize(8)>, L<btrfs(8)> or L<xfs_growfs(8)>.
+L<resize2fs(8)>, L<ntfsresize(8)>, L<btrfs(8)>, L<xfs_growfs(8)>,
+or L<resize.f2fs(8)>.
 However virt-resize does not know how to resize some filesystems, so
 you would have to online resize them after booting the guest.
 
@@ -407,6 +408,10 @@ Please note that libguestfs I<destroys> the existing swap content
 by recreating it with C<mkswap>, so this should not be used when
 the guest is suspended.
 
+=item *
+
+f2fs filesystems, if libguestfs was compiled with support for f2fs.
+
 =back
 
 Note that you cannot use I<--expand> and I<--shrink> together.
@@ -775,7 +780,7 @@ This may be due to either of the following:
 
 There corresponding filesystem is not available in libguestfs,
 because there is no proper package in the host with utilities for it.
-This is usually the case for C<btrfs>, C<ntfs>, and C<xfs>
+This is usually the case for C<btrfs>, C<ntfs>, C<xfs>, and C<f2fs>
 filesystems.
 
 Check the results of:
@@ -842,6 +847,7 @@ L<resize2fs(8)>,
 L<ntfsresize(8)>,
 L<btrfs(8)>,
 L<xfs_growfs(8)>,
+L<resize.f2fs(8)>,
 L<virsh(1)>,
 L<parted(8)>,
 L<truncate(1)>,
-- 
2.14.3




More information about the Libguestfs mailing list