I'm trying to create a bootable disk, e.g. a virtual disk or SD card, with the FAT32 file system from a C# code. It fails on two reasons:
- Formatting FAT32 partition with the standard windows tools format.exe or diskpart.exe as well with the PowerShell is only possible up to 32 GB.
Diskpart.exe:
create vdisk file=<path to vdisk file> maximum=33000
attach vdisk
create part primary
format quick fs=fat32
active
assign letter=<available drive letter>
Format.exe:
Format /FS:FAT32 <disk drive letter>
Powershell:
Format-Volume -DriveLetter <disk drive letter> -FileSystem FAT32
All these commands failed with the error "partition is too big"
=> Is there a way to create a large FAT32 partition programmatically? I know, there are applications like Rufus or AOMEI, which can do it. So this means, it is some how possible.
- I use the command line tool BootSect.exe to make the disk bootable on the BIOS systems:
System.Diagnostics.Process.Start("cmd.exe", "bootsect.exe /nt60 <disk drive letter> /mbr");
This tool seems however to be available only on command line. When calling from the C# application, the tool BootSect.exe is not available for runtime.
=> Is there a way to call the BootSect.exe from the C# application?
Thank you for any reply.
Best regards Igor
You can't. In Windows format you can't specify Allocation Unit large enough to cross 32GB limit because one backend developer had to quickly make temporary UI. And as we all know temporary solutions are most permanent.
You can theoretically override Allocation Unit Size but it requires full format, which is not supported on virtual disk you are testing with. Override trick also doesn't seem to work on Windows 11.
Windows solution is to just use exFAT, but its will likely cause fun problems for bootable drives so your mileage may vary.
Best CLI solution might actually be "just use Linux" or multi-partition drive, as there is lack of CLI tools for Windows for this task.