如何挂载具有复杂分区结构的原始磁盘映像?

如何挂载具有复杂分区结构的原始磁盘映像?

我有一个由创建的原始磁盘映像救援。由于它的分区结构复杂,我无法安装它。

我首先尝试了losetup端口扫描选项。

# losetup -Pf --show -v silvio-extern.iso 
/dev/loop0

# fdisk -lu /dev/loop0

Disk /dev/loop0: 298,1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x88c8fbd4

Device       Boot Start       End   Sectors   Size Id Type
/dev/loop0p1         63 625137344 625137282 298,1G  7 HPFS/NTFS/exFAT

# fdisk -lu /dev/loop0p1 

Disk /dev/loop0p1: 298,1 GiB, 320070288384 bytes, 625137282 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x444c544e

Device         Boot      Start        End    Sectors  Size Id Type
/dev/loop0p1p1 ?    1768778098 1776409558    7631461  3,7G 6b unknown
/dev/loop0p1p2 ?    1830843506 3225479386 1394635881  665G 75 PC/IX
/dev/loop0p1p3 ?    1718906437 1718909009       2573  1,3M 41 PPC PReP Boot
/dev/loop0p1p4      2827157504 2827210421      52918 25,9M  0 Empty

Partition table entries are not in disk order.

# fdisk -lu /dev/loop0p1p2
fdisk: cannot open /dev/loop0p1p2: No such file or directory

分区大小告诉我我对 /dev/loop0p1p2 感兴趣。

我尝试创建循环设备手册。如果我做对了,我需要一个偏移量Start* Sector size(1830843506 * 512 = 937391875072) 和一个大小限制Sectors* Sector size(1394635881 * 512 = 714053571072)。但它不起作用:

# losetup -o 937391875072 --sizelimit 714053571072 --show -v -f /dev/loop0p1
/dev/loop1

# fdisk -lu /dev/loop1
fdisk: cannot open /dev/loop1: Inappropriate ioctl for device

# mount /dev/loop1 content/
mount: /dev/loop1 is write-protected, mounting read-only
mount: wrong fs type, bad option, bad superblock on /dev/loop1,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.

所以我做了kpartx修改。但结果还是一样:

# kpartx -av silvio-extern.iso 
add map loop0p1 (253:2): 0 625137282 linear /dev/loop0 63

# fdisk -lu /dev/loop0p1

Disk /dev/loop0p1: 298.1 GiB, 320070288384 bytes, 625137282 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x444c544e

Device         Boot      Start        End    Sectors  Size Id Type
/dev/loop0p1p1 ?    1768778098 1776409558    7631461  3.7G 6b unknown
/dev/loop0p1p2 ?    1830843506 3225479386 1394635881  665G 75 PC/IX
/dev/loop0p1p3 ?    1718906437 1718909009       2573  1.3M 41 PPC PReP Boot
/dev/loop0p1p4      2827157504 2827210421      52918 25.9M  0 Empty

Partition table entries are not in disk order.

# fdisk -lu /dev/loop0p1p2
fdisk: cannot open /dev/loop0p1p2: No such file or directory

然后我尝试losetup使用端口扫描选项运行但没有成功:

# losetup -Pf --show -v /dev/loop0p1 
/dev/loop1

# fdisk -lu /dev/loop1

Disk /dev/loop1: 298.1 GiB, 320070288384 bytes, 625137282 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x444c544e

Device       Boot      Start        End    Sectors  Size Id Type
/dev/loop1p1 ?    1768778098 1776409558    7631461  3.7G 6b unknown
/dev/loop1p2 ?    1830843506 3225479386 1394635881  665G 75 PC/IX
/dev/loop1p3 ?    1718906437 1718909009       2573  1.3M 41 PPC PReP Boot
/dev/loop1p4      2827157504 2827210421      52918 25.9M  0 Empty

Partition table entries are not in disk order.

# fdisk -lu /dev/loop1p2
fdisk: cannot open /dev/loop1p2: No such file or directory

kpartx尝试了一下/dev/loop0p1并收到一些错误消息:

# kpartx -av /dev/loop0p1 
device-mapper: reload ioctl on loop0p1p1 failed: Invalid argument
create/reload failed on loop0p1p1
add map loop0p1p1 (0:0): 0 7631461 linear /dev/loop0p1 1768778098
device-mapper: reload ioctl on loop0p1p2 failed: Invalid argument
create/reload failed on loop0p1p2
add map loop0p1p2 (0:0): 0 1394635881 linear /dev/loop0p1 1830843506
device-mapper: reload ioctl on loop0p1p3 failed: Invalid argument
create/reload failed on loop0p1p3
add map loop0p1p3 (0:0): 0 2573 linear /dev/loop0p1 1718906437
device-mapper: reload ioctl on loop0p1p4 failed: Invalid argument
create/reload failed on loop0p1p4
add map loop0p1p4 (0:0): 0 52918 linear /dev/loop0p1 2827157504

只需提一下:Ubuntu 16.04 中的自动挂载与原始磁盘配合良好。

有人知道吗?

我正在尝试使用 Debian 8 挂载磁盘映像。


根据 @Kamil Maciorowski 的建议,我尝试使用选项直接挂载映像文件。当列出内容时,offset这给了我一个:Input/output error

# mount -o offset=$((512*63)) silvio-extern.iso content/
# ls -l content/
ls: reading directory content/: Input/output error
total 0

我已仔细检查了fdisk图像文件的偏移量:

# fdisk -lu silvio-extern.iso 

Disk silvio-extern.iso: 298.1 GiB, 320072933376 bytes, 625142448 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x88c8fbd4

Device             Boot Start       End   Sectors   Size Id Type
silvio-extern.iso1         63 625137344 625137282 298.1G  7 HPFS/NTFS/exFAT

答案1

分区表非常简单:一个位于公共偏移处的 NTFS 分区。

sudo mount -o offset=$((512*63)) silvio-extern.iso /path/to/mountpoint

该命令fdisk -lu /dev/loop0p1读取实际的 NTFS 分区,就像它是带有分区表的磁盘一样(尽管这对我来说似乎很奇怪,因为您已经拥有了/dev/loop0p1kpartx稍后会使用)。在许多此类情况下,fdisk会警告分区表看起来很奇怪,也许选择了错误的设备。

我猜,这里的“内部分区表”还不足以触发警告。但“分区”仍然不按顺序排列,它们是不常见的类型,它们的偏移量和大小没有意义。在我看来,这个“内部分区表”是无效的,这样的分区设置会很奇怪。我认为只有一个 NTFS 分区不应被视为分区设备。您可以使用上述命令挂载它。


请注意,您可能不需要losetup。我认为您fdisk可以很好地读取图像文件:

fdisk -lu silvio-extern.iso

512*63从它的输出中,你可以知道使用命令的偏移量mount(如上所示),完全没有losetup

相关内容