-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resize partitions in a disk image. #26
Conversation
Hello @reynir |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good. Besides my one comment could you as well check that the resize doesn't result in the partitions overlapping before writing the new MBR header?
Sorry for the long wait - I was on Easter holiday.
While making the new MBR header, we have a check already in the Mbr.make constructor that checks if the partitions overlap. If the partitions overlap, it will fail without trying to write the new MBR header. The MBR header is only overwritten if the new MBR header is created successfully. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
While making the new MBR header, we have a check already in the Mbr.make constructor that checks if the partitions overlap.
Nice. In that case it would be nice to write a comment on this.
Thanks! I pushed a small change to the command help text. |
CHANGES: * Add optional argument `?disk_signature` to `Mbr.make` (@Burnleydev1, review by @reynir, mirage/ocaml-mbr#19) * Make the partition type a required argument to `Mbr.Partition.make` and rename it `~partition_type` (@AryanGodara, review by @reynir, mirage/ocaml-mbr#20) * Add tools for inspecting and modifying MBR, and reading/writing data to partitions. The command line tools are not installed as part of the opam package. The tools are `bin/mbr_inspect.exe`, `bin/read_partition.exe`, `bin/resize_partition.exe` and `bin/write_partition.exe`. (@PizieDust, review by @reynir, mirage/ocaml-mbr#22, mirage/ocaml-mbr#23, mirage/ocaml-mbr#24, mirage/ocaml-mbr#26) * Remove dependency on `ppx_cstruct` (@reynir, mirage/ocaml-mbr#27)
amazing. thank you |
part of #14
Resizing partitions in a disk image
Outline
This PR introduces a new binary
resize_partition
which resizes a partition to a new size.We are using the
cmdliner
package to read arguments from the command line. It also provides a helpful --help flag which can displays a user manual.Basically we read in a disk image,
unmarshal
it's MBR header to get the partition table, grab the specific partition we want to resize. After getting this partition, we calculate a newend_sector
and create a new partition changing only thisend_sector
. Then we swap this new partition with it's counterpart in the original partition table and create a newmbr
header with the updated partition table. The newmbr
header is then written back to the disk image, overwriting just the MBR header.Usage
After building, the command can be called with:
Outputs
Read initial disk image
Resize 3rd partition
Verify 3rd partition has been resized
Resizing a partition which may overlap
cc @reynir