Partition Move & Resize Engine¶
Moving or resizing a partition requires careful coordination between filesystem dimensions and low-level partition table boundaries. fparted enforces mathematical sequencing for all geometry transitions.
🔄 Shrink vs Grow Execution Ordering¶
To prevent data corruption, operations follow opposite ordering depending on whether the partition is shrinking or growing:
flowchart TD
subgraph Shrink Flow
S1[1. Unmount Target] --> S2[2. Check Filesystem: e2fsck]
S2 --> S3[3. Shrink Filesystem: resize2fs]
S3 --> S4[4. Shrink Partition Boundary: parted resizepart]
end
subgraph Grow Flow
G1[1. Grow Partition Boundary: parted resizepart] --> G2[2. Grow Filesystem: resize2fs / resize.f2fs]
G2 --> G3[3. Verify Filesystem Integrity]
end
[!IMPORTANT] If a partition boundary were shrunk before the filesystem inside it, the filesystem's metadata and trailing data blocks would be instantly truncated and lost.
fpartedguarantees thatresize2fsalways precedesparted resizepartduring shrink operations.
🔀 Three-Case Move Algorithm¶
Moving a partition involves one of three geometric cases:
Case 1: Non-Overlapping Move¶
When new boundaries do not intersect old boundaries:
1. Create a temporary target partition at the new location (mkpart).
2. Smart copy filesystem data (e2image -ra -p for ext4, or dd conv=fsync for raw blocks).
3. Remove the old partition entry (rm).
Case 2: Overlapping Left Move (newStart < oldStart)¶
When shifting a partition toward the beginning of the disk:
1. Expand the partition rightwards/leftwards to encompass both ranges (resizepart).
2. Copy blocks in forward direction (skip=oldStart seek=newStart conv=notrunc).
3. Truncate trailing sectors to match the final size.
Case 3: Overlapping Right Move (newStart > oldStart)¶
When shifting a partition toward the end of the disk:
1. Expand the partition boundary rightwards (resizepart).
2. Copy blocks in reverse order to prevent source data overwrite.
3. Adjust final start/end boundaries and verify with e2fsck.