我正在尝试使用文件从头开始制作硬盘映像。这包括 MBR、分区表、分区数量等。但我一生都无法让 Linux 挂载我创建的分区。
\n\n编辑:请参阅问题末尾的更新 - 似乎与 vboxsf 有关
\n\n到目前为止,我已经尝试了许多不同的方法,但那些最有效的方法最终都到达了同一个地方。我在下面制作了一个简化版本,应该足以解释我的问题
\n\n使用 dd 生成空文件(或截断速度)
\n\ndd if=/dev/zero of=test.img bs=1M count=150\nRun Code Online (Sandbox Code Playgroud)\n\n制作分区表
\n\nparted -s test.img mklabel gpt\nWarning: The resulting partition is not properly aligned for best performance.\nRun Code Online (Sandbox Code Playgroud)\n\n制作分区
\n\nparted -s test.img -- mkpart logical 0 5M\nparted -s test.img set 1 bios_grub on\nparted -s test.img -- mkpart logical 5M 50M\netc.\nRun Code Online (Sandbox Code Playgroud)\n\n安装为循环设备(加载 max_part=31 的循环模块)
\n\nlosetup /dev/loop0 test.img\nRun Code Online (Sandbox Code Playgroud)\n\nlsblk 来检查
\n\n …filesystems partition loop-device disk-image partition-table