Linux怎么有两个vmdk文件,「Linux」- 挂载 VMDK 文件

「Linux」- 挂载 VMDK 文件

更新日期:2020年09月11日

@IGNORECHANGE

下面介绍两种方法是类似的,只是使用的工具不同。

方法一,使用 vmdkmount 命令(推荐)

第一步、vmdkmount

安装 libvmdk 工具:

apt-get install libvmdk-utils

使用 vmdkmount 进行挂载:

vmdkmount Win7_64/Win7_64.vmdk /mnt/vmdk/

挂载后,在 /mnt/vmdk 下生成了 vmdk1 文件;

第二步、计算偏移量

使用 mmls 命令,该命令属于 sleuthkit 软件包。

对 vmdk1 文件执行如下操作,查看扇区分布:

mmls vmdk1

会得到类似下面的输出:

# DOS Partition Table

# Offset Sector: 0

# Units are in 512-byte sectors

#

# Slot Start End Length Description

# 000: Meta 0000000000 0000000000 0000000001 Primary Table (#0)

# 001: ------- 0000000000 0000002047 0000002048 Unallocated

# 002: 000:000 0000002048 0000206847 0000204800 NTFS / exFAT (0x07)

# 003: 000:001 0000206848 0220198911 0219992064 NTFS / exFAT (0x07)

# 004: ------- 0220198912 0220200959 0000002048 Unallocated

计算偏移量:

echo 512*206848 | bc

# 输出:105906176

# 其实,用 fdisk 查看也是可以的;

第三步、mount

# 执行挂载操作;

mount -o ro,offset=105906176 /mnt/vmdk/vmdk1 /mnt/vmdk1

# 到此挂在成功,移步到/mnt/vmdk1目录下查看内容;

error log

# 日期:02/27/2017

# VirtualBox + Debian8,我挂载时候出现了一个错误:“vmdk write access unavailable, cannot proceed”,其实我也不是很懂,下面命令解决了我的问题:

mount -t ext4 -o loop,ro,noexec,noload,offset=1048576 /mnt/vmdk/vmdk1 /mnt/vmdk1/

# 日期:03/01/2017

# 今天我挂载了 virtualbox + ubuntu 10.10 amd64 的 VMDK 文件,并没有出现上述错误;

# 从虚拟机里看文件系统是 Ext4 格式;

方法二、使用 afflib-tools 工具包

Install afflib-tools

apt-get install afflib-tools

affuse /path/file.vmdk /mnt/vmdk

Check sector size

# fdisk -l /mnt/vmdk/file.vmdk.raw

Disk file.vmdk.raw: 20 GiB, 21474836480 bytes, 41943040 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: 0x000da525

Device Boot Start End Sectors Size Id Type

/mnt/vmdk/file.vmdk.raw1 * 2048 41943039 41940992 20G 83 Linux

Multiply sectorsize and startsector. In example it would be 2048*512

echo 2048*512 | bc

# 输出 1048576

Mount using that offset

mount -o ro,loop,offset=1048576 /mnt/vmdk/file.raw /mnt/vmdisk

TODO 完善VMDK文件的挂载