正如Vojtech Trefny上面提到的,
1)首先将您的VDI转换为IMG格式。
VBoxManage clonehd --format RAW ubuntu.vdi ubuntu.img
2) 然后挂载IMG
mount -t ext3 -o loop,rw ./ubuntu.img /mnt
3) 然而,当我收到这个错误信息时:
mount: wrong fs type, bad option, bad superblock on /dev/loop0,
missing codepage or helper program, or other error
In some cases useful info is found in syslog - try
dmesg | tail or so
而且dmesg说:
[3105578.013671] EXT4-fs (loop0): VFS: Can't find ext3 filesystem
你需要检查.img文件的分区结构。
fdisk -l ubuntu.img
Disk ubuntu.img: 21.0 GB, 20971520000 bytes
255 heads, 63 sectors/track, 2549 cylinders, total 40960000 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
Disk identifier: 0xf45bc910
Device Boot Start End Blocks Id System
ubuntu.img1 * 2048 12582911 6290432 83 Linux
ubuntu.img2 12584958 16775167 2095105 5 Extended
ubuntu.img3 16775168 40959999 12092416 83 Linux
ubuntu.img5 12584960 16775167 2095104 82 Linux swap / Solaris
4) 如您所见,主分区从字节16775168开始。然而,请注意扇区大小为512字节,因此您需要将结果16775168 x 512 = 8588886016乘以,以便正确设置挂载偏移量。
mount -t ext3 -o loop,rw,offset=8588886016 ./ubuntu.img /mnt
5) 实际上,在文件系统调整大小后出现脏数据的情况下,这个方法对我并没有起作用。在这种情况下,我进一步进行了以下操作:
dd if=ubuntu.img of=ubuntu.disk bs=512 skip=16775168 count=12092416
e2fsck ubuntu.disk
mount ubuntu.disk /mnt