如何从 dmg 文件中提取 .hfs 分区

如何从 dmg 文件中提取 .hfs 分区

我有一个 macOS dmg 文件。BaseSystem.dmg它是压缩的并且包含各种 hfs 分区。

# file BaseSystem.dmg 
BaseSystem.dmg: zlib compressed data

我想做的事
我想提取4.hfs分区文件。但我做不到。
在 Windows 上可以使用启动磁盘实用程序工具作为演示在这里

这是我尝试过的
如果我像这样使用 dmg2img……

flex@flex-ubuntu:~/Documents/MacOS$ dmg2img BaseSystem.dmg 

dmg2img v1.6.7 (c) vu1tur ([email protected])

BaseSystem.dmg --> BaseSystem.img


decompressing:
opening partition 0 ...             100.00%  ok
opening partition 1 ...             100.00%  ok
opening partition 2 ...             100.00%  ok
opening partition 3 ...             100.00%  ok
opening partition 4 ...             100.00%  ok
opening partition 5 ...             100.00%  ok
opening partition 6 ...             100.00%  ok
opening partition 7 ...             100.00%  ok

Archive successfully decompressed as BaseSystem.img

如果我现在尝试安装BaseSystem.img..

$ sudo mount -o loop -t hfsplus BaseSystem.img /mnt/macimage
mount: /mnt/macimage: wrong fs type, bad option, bad superblock on /dev/loop7, missing codepage or helper program, or other error.

因此该命令不会挂载它。此命令返回单个环回设备:
# sudo losetup -P -f --show BaseSystem.img
我可以像这样挂载它:
# sudo mount /dev/loop8p1 /mnt/macimage/

但我想要的只是提取 4.hfs 分区文件?!

BaseSystem.img如果我看一下...的属性

# file BaseSystem.img
BaseSystem.img: DOS/MBR boot sector; partition 1 : ID=0xee, start-CHS (0x3ff,254,63), end-CHS (0x3ff,254,63), startsector 1, 4176871 sectors, extended partition table (last)

从 Ubuntu 终端: # 7z l BaseSystem.dmg我得到...

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_GB.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs Intel(R) Core(TM)

Scanning the drive for archives:
1 file, 498625205 bytes (476 MiB)

Listing archive: BaseSystem.dmg

--
Path = BaseSystem.dmg
Type = Dmg
Physical Size = 498625205
Method = Copy Zero2 ZLIB CRC
Blocks = 594
----
Path = 4.hfs
Size = 2004299776
Packed Size = 498579443
Comment = disk image (Apple_HFS : 4)
Method = Copy Zero2 ZLIB CRC
--
Path = 4.hfs
Type = HFS
Physical Size = 2004299776
Method = HFS+
Cluster Size = 4096
Free Space = 678445056
Created = 2020-10-30 08:13:26
Modified = 2020-10-30 16:31:38

我如何提取只是文件4.hfs

当我运行此命令时: # 7z x BaseSystem.dmg它会提取整个 dmg 文件以提供 dmg 文件中所有文件的目录树。但我只想从 dmg 文件中提取单个文件:4.hfs

如果我运行这个命令:7z x BaseSystem.dmg 4.hfs我会得到......

7-Zip [64] 16.02 : Copyright (c) 1999-2016 Igor Pavlov : 2016-05-21
p7zip Version 16.02 (locale=en_GB.UTF-8,Utf16=on,HugeFiles=on,64 bits,8 CPUs Intel(R) Core(TM)

Scanning the drive for archives:
1 file, 498625205 bytes (476 MiB)

Extracting archive: BaseSystem.dmg
--            
Path = BaseSystem.dmg
Type = Dmg
Physical Size = 498625205
Method = Copy Zero2 ZLIB CRC
Blocks = 594
----
Path = 4.hfs
Size = 2004299776
Packed Size = 498579443
Comment = disk image (Apple_HFS : 4)
Method = Copy Zero2 ZLIB CRC
--
Path = 4.hfs
Type = HFS
Physical Size = 2004299776
Method = HFS+
Cluster Size = 4096
Free Space = 678445056
Created = 2020-10-30 08:13:26
Modified = 2020-10-30 16:31:38


No files to process
Everything is Ok

Files: 0
Size:       0
Compressed: 498625205

4.hfs但是,我期望出现的文件夹中没有任何输出。

我做错了什么?在 Linux 上可能行不通吗?

答案1

我发现dmg2img并且7z可以从文件中提取一个分区dmg

使用dmg2img我们可以看到 dmg 文件的内容:

# dmg2img -l BaseSystem.dmg 

dmg2img v1.6.7 (c) vu1tur ([email protected])

BaseSystem.dmg --> (partition list)

partition 0: Protective Master Boot Record (MBR : 0)
partition 1: GPT Header (Primary GPT Header : 1)
partition 2: GPT Partition Data (Primary GPT Table : 2)
partition 3:  (Apple_Free : 3)
partition 4: disk image (Apple_HFS : 4)
partition 5:  (Apple_Free : 5)
partition 6: GPT Partition Data (Backup GPT Table : 6)
partition 7: GPT Header (Backup GPT Header : 7)

使用 dmg2img v1.6.7

此命令提取4.hfs分区:

# dmg2img -p 4 -i BaseSystem.dmg -o 4.hfs

使用 7z

在 7-Zip [64] 9.20 中您可以使用以下命令:

7z e BaseSystem.dmg 4.hfs

在 7-Zip [64] 16.02 中您需要使用此命令:

7z e -t* BaseSystem.dmg 4.hfs

-t*必需的,否则在此版本的 7z 中它不会仅提取到一层深度,而是会将所有内容提取到文件和文件夹中。

相关内容