分页: 1 / 5
VirtualBox从USB设备启动方法
发表于 : 2008-09-21 23:54
由 muzuiget
在
VirtualBox虚拟机中按F12的启动菜单中是没有从USB启动的,一直都找不到从USB设备启动方法,也有人说VirtualBox不支持USB设备启动,那是我搜中文的结果。把闪盘装上Linux都是在Vmware下测试的,Vmware下是把闪盘当成SCSI硬盘挂载的。我想这点应该VirtualBox也行啊。
我Google一下英文“virtualbox usb boot”(中文我得把“virtualbox”、“u盘”、“usb”、“闪盘”、“优盘”、“随身碟”、“引导”、“启动”、“开机”混搭使用,而还是一大堆无关结果,所以翻译叫法还是统一点好),
结果第一条就找到了,虽然没写具体怎么做,至少老外说行,有这么一行
It is not passible directly but it is possible indirectly. Configure your USB drive as a raw disk in VirtualBox (page 105 of the manual). Then the guest will see your USB drive as a IDE drive and will be able to boot on it.
VirtualBox的确不支持USB设备直接启动,但能把USB设备当成硬盘间接启动,“raw disk”,看起来原理跟Vmware一样,把它当成硬盘挂就行了。至于那个“page 105 of the manual”,我已经升级到VirtualBox 2.0.2,手册是CHM格式没有页码,还好找到了,是在“9.9. Using a raw host hard disk from a guest”这一节,讲解的非常详细。这次又是STFW和RTFM发挥了功效。
步骤如下
- Ubuntu软件库里那个VirtualBox OSE版是不能支持USB设备的,我用的是从官方下那个,并按这个帖子搞定了启动虚拟机USB出错那个问题。不过这里是把闪盘当成硬盘用,我想用OSE也应该行,因为支持USB是Ubuntu(当成硬盘)而不是VirtualBox,所以用OSE或许会成功,不过我懒得测试,有谁成功告诉一声。3楼caozhzh测试过,1.5.6是不行的,第3步那个命令没有创建虚拟磁盘功能,7楼的wjjs测试新版的2.0.4就行。
- 当前必须属于“vboxusers”组,运行
代码: 全选
sudo usermod -G vboxusers -a `whoami`
然后重新登录(注一)。
- 运行下面那个命令为闪盘添加访问权限,之前我老是提示没权限,
代码: 全选
sudo chmod o+rw /dev/sdc
我有2个硬盘,所以闪盘就是“/dev/sdc”,如果不确定的话就用“df”命令查看。因为每次拔出闪盘后,“sdc”就会消失了,插回去,又出现,所以还要重新设置权限,重新运行命令,比较常用的话就添加一个alias
- 然后就为闪盘建立一个虚拟硬盘镜像,其中参数“filename”后的路径就是虚拟硬盘镜像的保存位置,我这里用默认的 “~/.VirtualBox/VDI/”,手册里说路径一定要用绝对路径。创建出来vmdk文件只有几百字节而已,不需要担心空间,参数后 “rawdisk”就是你的闪盘设备路径,
代码: 全选
VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/VDI/UsbDisk.vmdk -rawdisk /dev/sdc -register
运行后出现
代码: 全选
VirtualBox Command Line Management Interface Version 2.0.2
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
RAW host disk access VMDK file /home/yourname/.VirtualBox/VDI/UsbDisk.vmdk created successfully.
表示创建成功了。
- 然后就启动VirtualBox,在需要测试的虚拟机设置里的“硬盘”一页,换成刚才那个vmdk文件,如果不是建立在“~/.VirtualBox/VDI/”的话要用虚拟介质管理器注册一下。
- 最后把硬盘设置成优先启动就搞定啦,成功启动了我闪盘里的Grub4DOS,切换启动项VirtualBox比用Vmware还要简单,不需要在虚拟机里的BIOS切换。
我这里是整个闪盘挂载,其实也可以挂载单个或几个分区,也可以直接挂载真实硬盘上的XP,参考这帖
《Boot an existing XP (Physical HD) install with VirtualBox》,也可以为建立的虚拟硬盘镜像自定义MBR,方法看手册有关章节吧。
注一:
原来这步我是这样做的,运行
代码: 全选
sudo usermod -G disk,vboxusers -a `whoami`
然后重新登录生效,考虑到把当前用户添加到“disk”组会危险,因为“/dev/sdc”属于“disk”组,格式化“mkfs”之类命令就不用加“sudo”运行了。所以用第3步的方法代替,临时加上读写权限给“/dev/sdc”,每次运行一次添加权限总比添加到“disk”组好。
Re: VirtualBox从USB设备启动方法
发表于 : 2008-09-22 12:49
由 想入非非
谢谢你的教程。。。
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-06 23:10
由 caozhzh
感谢楼主发帖。
我在1.5.6_ose里面试了一下,出现下列问题:
VirtualBox Command Line Management Interface Version 1.5.6_OSE
(C) 2005-2008 innotek GmbH
All rights reserved.
Usage: VBoxManage internalcommands <command> [command arguments]
Commands:
loadsyms <vmname>|<uuid> <symfile> [delta] [module] [module address]
This will instruct DBGF to load the given symbolfile
during initialization.
unloadsyms <vmname>|<uuid> <symfile>
Removes <symfile> from the list of symbol files that
should be loaded during DBF initialization.
setvdiuuid <filepath>
Assigns a new UUID to the given VDI file. This way, multiple copies
of VDI containers can be registered.
WARNING: This is a development tool and shall only be used to analyse
problems. It is completely unsupported and will change in
incompatible ways without warning.
Syntax error: Invalid command 'createrawvmdk'
搜索了一下,发现是这个问题:
I had the same problem on debian/lenny.
After searching the net, I found that the problem is, that the createrawvmdk command is not avaliable in the open source edition.
看来ose还是不行。
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-06 23:49
由 muzuiget
caozhzh 写了:感谢楼主发帖。
我在1.5.6_ose里面试了一下,出现下列问题:
VirtualBox Command Line Management Interface Version 1.5.6_OSE
(C) 2005-2008 innotek GmbH
All rights reserved.
Usage: VBoxManage internalcommands <command> [command arguments]
Commands:
loadsyms <vmname>|<uuid> <symfile> [delta] [module] [module address]
This will instruct DBGF to load the given symbolfile
during initialization.
unloadsyms <vmname>|<uuid> <symfile>
Removes <symfile> from the list of symbol files that
should be loaded during DBF initialization.
setvdiuuid <filepath>
Assigns a new UUID to the given VDI file. This way, multiple copies
of VDI containers can be registered.
WARNING: This is a development tool and shall only be used to analyse
problems. It is completely unsupported and will change in
incompatible ways without warning.
Syntax error: Invalid command 'createrawvmdk'
搜索了一下,发现是这个问题:
I had the same problem on debian/lenny.
After searching the net, I found that the problem is, that the createrawvmdk command is not avaliable in the open source edition.
看来ose还是不行。
代码: 全选
Syntax error: Invalid command 'createrawvmdk'
看来是没有createrawvmdk这个参数,谢谢你的测试。
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-09 23:36
由 caozhzh
不必客气,呵呵
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-28 18:28
由 uranus0206
$ VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/VDI/UsbDisk.vmdk -rawdisk /dev/sdb1 -register
VirtualBox Command Line Management Interface Version 2.0.4
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
Error while creating the raw disk VMDK: VERR_FILE_NOT_FOUND
The raw disk vmdk file was not created
不行耶!!!!!!!!
後來用絕對路徑才可以
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-29 15:44
由 wjjs
muzuiget 写了:在
VirtualBox虚拟机中按F12的启动菜单中是没有从USB启动的,一直都找不到从USB设备启动方法,也有人说VirtualBox不支持USB设备启动,那是我搜中文的结果。把闪盘装上Linux都是在Vmware下测试的,Vmware下是把闪盘当成SCSI硬盘挂载的。我想这点应该VirtualBox也行啊。
我Google一下英文“virtualbox usb boot”(中文我得把“virtualbox”、“u盘”、“usb”、“闪盘”、“优盘”、“随身碟”、“引导”、“启动”、“开机”混搭使用,而还是一大堆无关结果,所以翻译叫法还是统一点好),
结果第一条就找到了,虽然没写具体怎么做,至少老外说行,有这么一行
It is not passible directly but it is possible indirectly. Configure your USB drive as a raw disk in VirtualBox (page 105 of the manual). Then the guest will see your USB drive as a IDE drive and will be able to boot on it.
VirtualBox的确不支持USB设备直接启动,但能把USB设备当成硬盘间接启动,“raw disk”,看起来原理跟Vmware一样,把它当成硬盘挂就行了。至于那个“page 105 of the manual”,我已经升级到VirtualBox 2.0.2,手册是CHM格式没有页码,还好找到了,是在“9.9. Using a raw host hard disk from a guest”这一节,讲解的非常详细。这次又是STFW和RTFM发挥了功效。
步骤如下
- Ubuntu软件库里那个VirtualBox OSE版是不能支持USB设备的,我用的是从官方下那个,并按这个帖子搞定了启动虚拟机USB出错那个问题。不过这里是把闪盘当成硬盘用,我想用OSE也应该行,因为支持USB是Ubuntu(当成硬盘)而不是VirtualBox,所以用OSE或许会成功,不过我懒得测试,有谁成功告诉一声。3楼caozhzh测试过,是不行的,第3步那个命令没有创建虚拟磁盘功能
- 当前必须属于“vboxusers”组,运行
代码: 全选
sudo usermod -G vboxusers -a `whoami`
然后重新登录(注一)。
- 运行下面那个命令为闪盘添加访问权限,之前我老是提示没权限,
代码: 全选
sudo chmod o+rw /dev/sdc
我有2个硬盘,所以闪盘就是“/dev/sdc”,如果不确定的话就用“df”命令查看。因为每次拔出闪盘后,“sdc”就会消失了,插回去,又出现,所以还要重新设置权限,重新运行命令,比较常用的话就添加一个alias
- 然后就为闪盘建立一个虚拟硬盘镜像,其中参数“filename”后的路径就是虚拟硬盘镜像的保存位置,我这里用默认的 “~/.VirtualBox/VDI/”,手册里说路径一定要用绝对路径。创建出来vmdk文件只有几百字节而已,不需要担心空间,参数后 “rawdisk”就是你的闪盘设备路径,
代码: 全选
VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/VDI/UsbDisk.vmdk -rawdisk /dev/sdc -register
运行后出现
代码: 全选
VirtualBox Command Line Management Interface Version 2.0.2
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
RAW host disk access VMDK file /home/yourname/.VirtualBox/VDI/UsbDisk.vmdk created successfully.
表示创建成功了。
- 然后就启动VirtualBox,在需要测试的虚拟机设置里的“硬盘”一页,换成刚才那个vmdk文件,如果不是建立在“~/.VirtualBox/VDI/”的话要用虚拟介质管理器注册一下。
- 最后把硬盘设置成优先启动就搞定啦,成功启动了我闪盘里的Grub4DOS,切换启动项VirtualBox比用Vmware还要简单,不需要在虚拟机里的BIOS切换。
我这里是整个闪盘挂载,其实也可以挂载单个或几个分区,也可以直接挂载真实硬盘上的XP,参考这帖
《Boot an existing XP (Physical HD) install with VirtualBox》,也可以为建立的虚拟硬盘镜像自定义MBR,方法看手册有关章节吧。
注一:
原来这步我是这样做的,运行
代码: 全选
sudo usermod -G disk,vboxusers -a `whoami`
然后重新登录生效,考虑到把当前用户添加到“disk”组会危险,因为“/dev/sdc”属于“disk”组,格式化“mkfs”之类命令就不用加“sudo”运行了。所以用第3步的方法代替,临时加上读写权限给“/dev/sdc”,每次运行一次添加权限总比添加到“disk”组好。
谢谢,成功。
用于ub 8.10rc 虚拟机vbox2.04加载wxp识别usb设备
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-29 15:46
由 wjjs
另,用的就是
代码: 全选
Ubuntu软件库里那个VirtualBox OSE版
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-29 15:55
由 wjjs
代码: 全选
feng@feng-laptop:~/桌面$ sudo usermod -G vboxusers -a `whoami`
[sudo] password for feng:
feng@feng-laptop:~/桌面$ sudo chmod o+rw /dev/sdc
feng@feng-laptop:~/桌面$ VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/VDI/UsbDisk.vmdk -rawdisk /dev/sdc -register
VirtualBox Command Line Management Interface Version 2.0.4_OSE
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
RAW host disk access VMDK file /home/feng/.VirtualBox/VDI/UsbDisk.vmdk created successfully.
feng@feng-laptop:~/桌面$
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-29 15:58
由 wjjs
Re: VirtualBox从USB设备启动方法
发表于 : 2008-10-30 21:12
由 muzuiget
wjjs 写了:代码: 全选
feng@feng-laptop:~/桌面$ sudo usermod -G vboxusers -a `whoami`
[sudo] password for feng:
feng@feng-laptop:~/桌面$ sudo chmod o+rw /dev/sdc
feng@feng-laptop:~/桌面$ VBoxManage internalcommands createrawvmdk -filename ~/.VirtualBox/VDI/UsbDisk.vmdk -rawdisk /dev/sdc -register
VirtualBox Command Line Management Interface Version 2.0.4_OSE
(C) 2005-2008 Sun Microsystems, Inc.
All rights reserved.
RAW host disk access VMDK file /home/feng/.VirtualBox/VDI/UsbDisk.vmdk created successfully.
feng@feng-laptop:~/桌面$
1.5.6的OSE不行,2.0.4的OSE却行,Sun倒挺大方的,谢谢你的测试。
Re: VirtualBox从USB设备启动方法
发表于 : 2008-11-09 19:01
由 gjm33
真的把U盘挂个去了,就是不知道工行的U盾是不是也能这样用呢
Re: VirtualBox从USB设备启动方法
发表于 : 2008-11-09 19:06
由 gjm33
我原来是sdb的,把U盘拨下后再插上去就成了sdc了,然后就用不了,真是奇怪了
Re: VirtualBox从USB设备启动方法
发表于 : 2008-11-17 19:58
由 20youyou08
很感谢分享!
楼主辛苦
Re: VirtualBox从USB设备启动方法
发表于 : 2009-02-03 23:52
由 出岫之云
需要这么麻烦吗?我移动硬盘上的ubuntu就是在vbox中直接装上去的啊。在vbox的虚拟电脑的USB设置中挂上移动硬盘,然后挂上ubuntu安装盘的ISO文件到光驱,从此光驱启动安装ubuntu,安装过程中可以直接选择将系统安装到挂上的移动硬盘中啊。记得当时的vbox版本好像是2.0.4吧,另外好像我没为虚拟电脑建虚拟硬盘,现在记得不太清楚了。