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 () =
(* Update features available in the daemon. *)
ntfs_available := feature_available g [|"ntfsprogs"; "ntfs3g"|];
+ btrfs_available := feature_available g [|"btrfs"|];
g
(* 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
| ContentPV _ -> true
| ContentFS (("ext2"|"ext3"|"ext4"), _) -> true
| ContentFS (("ntfs"), _) when !ntfs_available -> true
+ | ContentFS (("btrfs"), _) when !btrfs_available -> true
| ContentFS (_, _) -> false
else
fun _ -> false
| 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
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. *)
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.
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.
L<lvresize(8)>,
L<resize2fs(8)>,
L<ntfsresize(8)>,
+L<btrfs(8)>,
L<virsh(1)>,
L<parted(8)>,
L<truncate(1)>,