UsbLinuxPartitionManager
Ensures a labeled data partition exists on the USB boot disk at runtime. USB sticks are flashed by Rufus producing a 2-partition layout (FAT32 ESP + NTFS). This class creates a new partition by shrinking the largest (NTFS data) partition and formatting the freed space with the requested filesystem and label, optionally assigning a drive letter. Windows equivalent of BootISOGrub2.PrepareUsbIsoPartition (Linux side).
public static class UsbLinuxPartitionManager
1. Methods
1.1. EnsureUsbDataPartition(ISystemHost, IDisk, DataSize, string, string, bool)
Ensures a partition with the given label exists on the USB disk, formatted with fileSystem. Idempotent: if the partition already exists, its drive letter (if requested) is re-assigned and returned without touching the disk layout.
public static char? EnsureUsbDataPartition(ISystemHost host, IDisk usbDisk, DataSize requiredSize, string label, string fileSystem, bool assignDriveLetter)
| Name | Type | Description |
|---|---|---|
host |
ISystemHost |
System host for logging and disk refresh. |
usbDisk |
IDisk |
The USB disk to modify (resolved by caller via drive letter match). |
requiredSize |
DataSize |
Size to carve out of the largest partition. |
label |
string |
Volume label for the new partition (e.g. |
fileSystem |
string |
Filesystem to format with ( |
assignDriveLetter |
bool |
If |
Returns: char? — The assigned drive letter if assignDriveLetter is true, otherwise null.