Partition range operations

feclora’s whole-disk image format stores the raw disk payload and an associated sfdisk partition-table snapshot. A partition can therefore be selected from an existing whole-disk image without first restoring the entire disk.

Implemented core

src/feclora/storage/partition_range.py provides:

Disk-image extraction workflow now integrated

The extracted raw artifact is retained in the image repository as a separately manifested image. It is not automatically deleted after restore, allowing audit/retry but consuming repository space.

Remaining integration and validation

The remaining caller responsibilities are:

  1. Load and authenticate the image manifest and verify the whole-disk image digest before trusting its partition table.
  2. Obtain the actual logical sector size and validate it against image metadata.
  3. Present the partition list and require independent local target selection.
  4. Run the existing mounted/root/system-device protections and destructive confirmation before opening the target.
  5. Ensure the selected destination partition is large enough and compatible with the source partition’s filesystem/content.
  6. Read the destination back and compare SHA-256 before recording success.

Partition-to-partition cloning can reuse the same bounded copier with source offset zero and the source partition’s exact byte length. Whole-disk-image-to-partition restore uses the selected partition’s offset and length from the validated partition table. The code must never infer a destination from a remote image or remote host.

Direct partition cloning

src/feclora/storage/partition_clone.py implements offline partition-to-partition cloning. It independently inspects both partition geometries, requires equal logical sector sizes and a destination at least as large as the source, rejects partitions sharing a physical backing disk, applies the existing fail-closed mounted/root/busy-device checks, streams the exact source partition byte count through bounded dd pipes, and reads the destination range back for SHA-256 comparison. The Local rescue menu exposes independent source and target selection with an exact ERASE target FROM source confirmation, progress and cancellation. The source is not modified; bytes beyond the source length on a larger destination partition are left unchanged.

Hardware-independent unit tests for partition cloning run as part of make validate using controlled test doubles. They do not write to physical devices; disposable-media acceptance remains an operator task.

Resizing policy

Raw partition-range copying does not resize filesystems. Disk layout planning must be a separate operation. Preserve-layout mode retains partition starts and sizes; proportional growth and selected-partition growth require a previewed, validated sector layout, followed by filesystem-specific growth tools and a final consistency check. EFI, BIOS boot, recovery, swap, LVM and LUKS partitions need explicit policies rather than blind proportional scaling.