挂载VirtualBox驱动器映像(vdi)?
是否可以安装VirtualBox驱动器映像(.vdi),以便可以在Nautilus等中查看内容?
我有一个Windows 2000 .vdi从VirtualBox 2.x升级到3.1.6后将无法启动(“无法访问启动设备”)。 我相信IDE驱动器的详细信息已经更改,我需要做的就是访问内部驱动器映像并编辑Windows boot.ini
以指向新位置。
您可以转换为标准图像,然后安装它。
VBoxManage clonehd --format RAW ubuntu.vdi ubuntu.img
然后
mount -t ext3 -o loop,rw ./ubuntu.img /mnt
在这种情况下,您需要知道文件系统的类型, ext3
。 安装完成后,使用您选择的编辑器进入并编辑。 不要将/mnt
位置内的文件与正在运行的主机混淆,否则会很糟糕。
要查看有关VDI文件的详细信息,请运行: VBoxManage showhdinfo ubuntu.vdi
。
来源: [已解决]与档案管理员打开.vdi? – ubuntuforums.org
使用qemu-nbd
,该过程在serverfault和本博客中进行了解释。
基本上,如果需要,你必须安装qemu
:
sudo apt-get install qemu
然后你需要加载网络块设备模块:
sudo rmmod nbd sudo modprobe nbd max_part=16
将.vdi图像附加到刚刚创建的nbd之一:
sudo qemu-nbd -c /dev/nbd0 drive.vdi
现在,您将获得一个/ dev / nbd0块设备,以及几个/ dev / nbd0p *分区设备节点。
sudo mount /dev/nbd0p1 /mnt
完成后,卸载所有内容并断开设备连接:
sudo qemu-nbd -d /dev/nbd0
看起来vdfuse是您正在寻找的工具。 它位于Ubuntu存储库中。 如果你想自己编译(2010年源代码),你也可以这样做 。
然而对于我们大多数人来说,它归结为一个简单的:
sudo apt-get install virtualbox-fuse
它似乎现在也支持动态vdi。
要在/mnt
目录中安装.vdi
文件,请使用以下命令:
sudo vdfuse -a -f /path-to-vdi-file /mnt
整个磁盘将安装分区Partition1
, Partition2
命名格式。 然后这些文件可以循环安装。 例如,
sudo mount -o loop /mnt/Parition1 /mountpoint
将磁盘设置为另一个虚拟操作系统的辅助主服务器,然后启动到此(虚拟)操作系统,您可以安装它。
步骤1:假设您已在虚拟框中安装了虚拟操作系统(例如Ubuntu 16.04),请从该虚拟操作系统的设置添加新存储。
第2步:浏览您要访问的Vdi文件并选择它。
第3步:登录虚拟操作系统。
步骤4:虚拟磁盘可能在操作系统内可用。 如果没有,请执行步骤5
步骤5:在虚拟操作系统内,使用Gparted并检查磁盘。 并确保磁盘的类型可由虚拟操作系统访问。 如果不是,您可能需要编辑磁盘,但之后您将丢失现有内容。
我没有测试自己,但似乎有一个保险丝模块来安装它们( vfduse
),请查看以下页面:
- HOWTO:在主机上安装任何与VBox兼容的磁盘映像
请注意,使用它进行写访问是有风险的。
用法:
$ ./vdfuse-v -h USAGE: ./vdfuse [options] -f image-file mountpoint -h help -r readonly -t specify type (VDI, VMDK, VHD, or raw; default: auto) -f VDimage file -a allow all users to read disk -w allow all users to read and write to disk -g run in foreground -v verbose -d debug
要使用其文件名直接挂载图像:
$ ./vdfuse-v -f image.vdi /mnt/vdi $ mount -o loop /mnt/vdi/Partition1 /mnt/WindowsXP
要挂载计算机磁盘(包括快照):
$ ./vdautomount- -p /path/to/vdfuse WinXP /mnt/vdi $ mount -o loop /mnt/vdi/Partition1 /mnt/WindowsXP
不是你要求的,但如果只是从文件中删除文件 ,你想要一个非常快速的解决方案 :
- 在主机上运行ssh服务器(
apt-get install openssh-server && service ssh restart
) - 使用VirtualBox从现有vdi文件构建虚拟机,然后启动该虚拟机。 (我在构建VM时只保留了默认的网络适配器(NAT)。)
- 在虚拟机中,sftp到您的主机。 (
sftp hostuser@hostip
) - 在sftp会话中,根据需要
put
尽可能多的文件put
主机。
正如上面提到的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)实际上,如果文件系统在resize后变脏,这对我来说不起作用。 在这种情况下,我进一步这样做:
dd if=ubuntu.img of=ubuntu.disk bs=512 skip=16775168 count=12092416 e2fsck ubuntu.disk mount ubuntu.disk /mnt