如何在 macOS 上从命令行挂载原始 APFS 文件系统?

如何在 macOS 上从命令行挂载原始 APFS 文件系统?

创建包含 APFS 文件系统的原始图像非常简单:

$ hdiutil create -megabytes 1 -layout NONE -fs apfs -volname unicode unicode.dmg
created: /Users/daniel/test/apfs/unicode.dmg

现在我想将要执行的特定测试的文件放入其中,但似乎无法附加它:

$ hdiutil attach unicode.dmg 
hdiutil: attach failed - no mountable file systems

诊断:

$ hdiutil imageinfo unicode.dmg 
nx_kernel_mount:1366: checkpoint search: largest xid 2, best xid 2 @ 3
nx_kernel_mount:1366: checkpoint search: largest xid 2, best xid 2 @ 3
nx_kernel_mount:1366: checkpoint search: largest xid 2, best xid 2 @ 3
nx_kernel_mount:1366: checkpoint search: largest xid 2, best xid 2 @ 3
nx_kernel_mount:1366: checkpoint search: largest xid 2, best xid 2 @ 3
nx_kernel_mount:1366: checkpoint search: largest xid 2, best xid 2 @ 3
Backing Store Information:
    URL: file:///Users/tester/test/apfs/unicode.dmg
    Name: unicode.dmg
    Class Name: CBSDBackingStore
Class Name: CRawDiskImage
Checksum Type: none
Size Information:
    Total Bytes: 1048576
    Compressed Ratio: 1
    Sector Count: 2048
    Total Non-Empty Bytes: 1048576
    Compressed Bytes: 1048576
    Total Empty Bytes: 0
Format: UDRW
Format Description: raw read/write
Checksum Value: 
Properties:
    Encrypted: false
    Kernel Compatible: true
    Checksummed: false
    Software License Agreement: false
    Partitioned: false
    Compressed: no
Segments:
    0: /Users/tester/test/apfs/unicode.dmg
partitions:
    partition-scheme: none
    block-size: 512
    appendable: false
    partitions:
        0:
            partition-name: whole disk
            partition-start: 0
            partition-synthesized: true
            partition-length: 2048
            partition-hint: unknown partition
            partition-filesystems:
                APFS: Untitled
    burnable: false
Resize limits (per hdiutil resize -limits):
 min     cur     max 
2048    2048    2048

这里的输出似乎不太可靠,因为块大小和卷标是错误的。所以我不确定发生了什么。APFS 是否是那些只在某些特定条件下才会挂载的东西之一?如果是,什么条件?或者有没有办法解决这个问题来挂载我已经拥有的一个映像?

相关内容