英文:
Create bootable disk with large FAT32 partition from C#
问题
-
创建一个可引导的磁盘,例如虚拟磁盘或SD卡,使用C#代码来格式化为FAT32文件系统时,会遇到两个问题:
-
使用标准的Windows工具format.exe、diskpart.exe或PowerShell来格式化FAT32分区仅限于32 GB。
-
所有这些命令都会失败,并显示"分区太大"的错误。
=> 有没有办法以编程方式创建一个大型的FAT32分区?我知道有像Rufus或AOMEI这样的应用程序可以做到。这意味着理论上是可行的。
-
-
我使用命令行工具BootSect.exe来使磁盘在BIOS系统上可引导:
这个工具似乎只能在命令行中使用。从C#应用程序调用时,BootSect.exe无法在运行时使用。
=> 有没有办法从C#应用程序中调用BootSect.exe?
谢谢您的回复。
最好的祝愿
Igor
英文:
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
答案1
得分: 1
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 it's 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 a lack of CLI tools for Windows for this task.
英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论