let infile, outfile, copy_boot_loader, debug, deletes, dryrun,
expand, expand_content, extra_partition, format, ignores,
let infile, outfile, copy_boot_loader, debug, deletes, dryrun,
expand, expand_content, extra_partition, format, ignores,
quiet, resizes, resizes_force, shrink =
let display_version () =
let g = new G.guestfs () in
quiet, resizes, resizes_force, shrink =
let display_version () =
let g = new G.guestfs () in
"--no-copy-boot-loader", Arg.Clear copy_boot_loader, " Don't copy boot loader";
"-d", Arg.Set debug, " Enable debugging messages";
"--debug", Arg.Set debug, " -\"-";
"--no-copy-boot-loader", Arg.Clear copy_boot_loader, " Don't copy boot loader";
"-d", Arg.Set debug, " Enable debugging messages";
"--debug", Arg.Set debug, " -\"-";
- "--delete", Arg.String (add deletes), "dev Delete partition";
- "--expand", Arg.String set_expand, "dev Expand partition";
+ "--delete", Arg.String (add deletes), "part Delete partition";
+ "--expand", Arg.String set_expand, "part Expand partition";
"--no-expand-content", Arg.Clear expand_content, " Don't expand content";
"--no-extra-partition", Arg.Clear extra_partition, " Don't create extra partition";
"--format", Arg.Set_string format, "format Format of input disk";
"--no-expand-content", Arg.Clear expand_content, " Don't expand content";
"--no-extra-partition", Arg.Clear extra_partition, " Don't create extra partition";
"--format", Arg.Set_string format, "format Format of input disk";
"--lv-expand", Arg.String (add lv_expands), "lv Expand logical volume";
"--LV-expand", Arg.String (add lv_expands), "lv -\"-";
"--lvexpand", Arg.String (add lv_expands), "lv -\"-";
"--lv-expand", Arg.String (add lv_expands), "lv Expand logical volume";
"--LV-expand", Arg.String (add lv_expands), "lv -\"-";
"--lvexpand", Arg.String (add lv_expands), "lv -\"-";
"-n", Arg.Set dryrun, " Don't perform changes";
"--dryrun", Arg.Set dryrun, " -\"-";
"--dry-run", Arg.Set dryrun, " -\"-";
"-n", Arg.Set dryrun, " Don't perform changes";
"--dryrun", Arg.Set dryrun, " -\"-";
"--dry-run", Arg.Set dryrun, " -\"-";
"--output-format", Arg.Set_string format, "format Format of output disk";
"-q", Arg.Set quiet, " Don't print the summary";
"--quiet", Arg.Set quiet, " -\"-";
"--resize", Arg.String (add resizes), "part=size Resize partition";
"--resize-force", Arg.String (add resizes_force), "part=size Forcefully resize partition";
"--output-format", Arg.Set_string format, "format Format of output disk";
"-q", Arg.Set quiet, " Don't print the summary";
"--quiet", Arg.Set quiet, " -\"-";
"--resize", Arg.String (add resizes), "part=size Resize partition";
"--resize-force", Arg.String (add resizes_force), "part=size Forcefully resize partition";
"-V", Arg.Unit display_version, " Display version and exit";
"--version", Arg.Unit display_version, " -\"-";
] in
"-V", Arg.Unit display_version, " Display version and exit";
"--version", Arg.Unit display_version, " -\"-";
] in
let format = match !format with "" -> None | str -> Some str in
let ignores = List.rev !ignores in
let lv_expands = List.rev !lv_expands in
let format = match !format with "" -> None | str -> Some str in
let ignores = List.rev !ignores in
let lv_expands = List.rev !lv_expands in
let output_format = match !output_format with "" -> None | str -> Some str in
let quiet = !quiet in
let resizes = List.rev !resizes in
let output_format = match !output_format with "" -> None | str -> Some str in
let quiet = !quiet in
let resizes = List.rev !resizes in
infile, outfile, copy_boot_loader, debug, deletes, dryrun,
expand, expand_content, extra_partition, format, ignores,
infile, outfile, copy_boot_loader, debug, deletes, dryrun,
expand, expand_content, extra_partition, format, ignores,
quiet, resizes, resizes_force, shrink
quiet, resizes, resizes_force, shrink
(* Update features available in the daemon. *)
ntfs_available := feature_available g [|"ntfsprogs"; "ntfs3g"|];
(* Update features available in the daemon. *)
ntfs_available := feature_available g [|"ntfsprogs"; "ntfs3g"|];
(* These functions tell us if we know how to expand the content of
* a particular partition or LV, and what method to use.
*)
(* These functions tell us if we know how to expand the content of
* a particular partition or LV, and what method to use.
*)
let string_of_expand_content_method = function
| PVResize -> "pvresize"
| Resize2fs -> "resize2fs"
| NTFSResize -> "ntfsresize"
let string_of_expand_content_method = function
| PVResize -> "pvresize"
| Resize2fs -> "resize2fs"
| NTFSResize -> "ntfsresize"
| ContentPV _ -> true
| ContentFS (("ext2"|"ext3"|"ext4"), _) -> true
| ContentFS (("ntfs"), _) when !ntfs_available -> true
| ContentPV _ -> true
| ContentFS (("ext2"|"ext3"|"ext4"), _) -> true
| ContentFS (("ntfs"), _) when !ntfs_available -> true
| ContentPV _ -> PVResize
| ContentFS (("ext2"|"ext3"|"ext4"), _) -> Resize2fs
| ContentFS (("ntfs"), _) when !ntfs_available -> NTFSResize
| ContentPV _ -> PVResize
| ContentFS (("ext2"|"ext3"|"ext4"), _) -> Resize2fs
| ContentFS (("ntfs"), _) when !ntfs_available -> NTFSResize
- | NTFSResize -> g#ntfsresize 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 "/"