summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--resize/resize.ml18
-rw-r--r--resize/virt-resize.pod11
2 files changed, 24 insertions, 5 deletions
diff --git a/resize/resize.ml b/resize/resize.ml
index 8e7057c6..d4455eb2 100644
--- a/resize/resize.ml
+++ b/resize/resize.ml
@@ -144,8 +144,9 @@ read the man page virt-resize(1).
lv_expands, ntfsresize_force, output_format,
quiet, resizes, resizes_force, shrink
-(* Default to true, since NTFS support is usually available. *)
+(* Default to true, since NTFS and btrfs support are usually available. *)
let ntfs_available = ref true
+let btrfs_available = ref true
(* Add in and out disks to the handle and launch. *)
let connect_both_disks () =
@@ -163,6 +164,7 @@ let connect_both_disks () =
(* Update features available in the daemon. *)
ntfs_available := feature_available g [|"ntfsprogs"; "ntfs3g"|];
+ btrfs_available := feature_available g [|"btrfs"|];
g
@@ -373,12 +375,14 @@ let lvs =
(* These functions tell us if we know how to expand the content of
* a particular partition or LV, and what method to use.
*)
-type expand_content_method = PVResize | Resize2fs | NTFSResize
+type expand_content_method =
+ | PVResize | Resize2fs | NTFSResize | BtrfsFilesystemResize
let string_of_expand_content_method = function
| PVResize -> "pvresize"
| Resize2fs -> "resize2fs"
| NTFSResize -> "ntfsresize"
+ | BtrfsFilesystemResize -> "btrfs-filesystem-resize"
let can_expand_content =
if expand_content then
@@ -387,6 +391,7 @@ let can_expand_content =
| ContentPV _ -> true
| ContentFS (("ext2"|"ext3"|"ext4"), _) -> true
| ContentFS (("ntfs"), _) when !ntfs_available -> true
+ | ContentFS (("btrfs"), _) when !btrfs_available -> true
| ContentFS (_, _) -> false
else
fun _ -> false
@@ -398,6 +403,7 @@ let expand_content_method =
| ContentPV _ -> PVResize
| ContentFS (("ext2"|"ext3"|"ext4"), _) -> Resize2fs
| ContentFS (("ntfs"), _) when !ntfs_available -> NTFSResize
+ | ContentFS (("btrfs"), _) when !btrfs_available -> BtrfsFilesystemResize
| ContentFS (_, _) -> assert false
else
fun _ -> assert false
@@ -920,6 +926,14 @@ let () =
g#e2fsck_f target;
g#resize2fs target
| NTFSResize -> g#ntfsresize_opts ~force:ntfsresize_force target
+ | BtrfsFilesystemResize ->
+ (* Complicated ... Btrfs forces us to mount the filesystem
+ * in order to resize it.
+ *)
+ assert (Array.length (g#mounts ()) = 0);
+ g#mount_options "" target "/";
+ g#btrfs_filesystem_resize "/";
+ g#umount "/"
in
(* Expand partition content as required. *)
diff --git a/resize/virt-resize.pod b/resize/virt-resize.pod
index 6a93e468..a071110b 100644
--- a/resize/virt-resize.pod
+++ b/resize/virt-resize.pod
@@ -133,9 +133,9 @@ 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)> or L<ntfsresize(8)>. However virt-resize does not
-know how to resize some filesystems, so you would have to online
-resize them after booting the guest.
+L<resize2fs(8)>, L<ntfsresize(8)> or L<btrfs(8)>. However virt-resize
+does not know how to resize some filesystems, so you would have to
+online resize them after booting the guest.
Other options are covered below.
@@ -274,6 +274,10 @@ LVM PVs (physical volumes). virt-resize does not usually resize
anything inside the PV, but see the I<--LV-expand> option. The user
could also resize LVs as desired after boot.
+=item *
+
+Btrfs filesystems, if libguestfs was compiled with support for btrfs.
+
=back
Note that you cannot use I<--expand> and I<--shrink> together.
@@ -530,6 +534,7 @@ L<pvresize(8)>,
L<lvresize(8)>,
L<resize2fs(8)>,
L<ntfsresize(8)>,
+L<btrfs(8)>,
L<virsh(1)>,
L<parted(8)>,
L<truncate(1)>,