VirtualBox 虚拟磁盘的UUID修改


个人测试环境,想构建一套Standby RAC环境,不想再重复去安装系统浪费时间,直接复制之前安装RAC前的一套VirtualBox的虚拟环境,不过打开时报错:

未能打开位于 Z:\Vbox\StandbyRAC_ENV\11.2.0.4RAC1\11.2.0.4RAC1.vdi 的虚拟电脑。
Trying to open a VM config 'Z:/Vbox/11.2.0.4RAC_ENV/installed/11.2.0.4RAC1/11.2.0.4RAC1.vbox' which has the same UUID as an existing virtual machine.

很明显,从报错可以看到,virtual box不允许有相同的UUID。那么是否可以修改这个UUID呢?
答案是肯定的,而且非常方便:

直接使用VBoxManage程序来修改UUID即可:

C:\Users\Mcdull>VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4RAC1\11.2.0.4RAC1.vdi"
'VBoxManage' 不是内部或外部命令,也不是可运行的程序或批处理文件。

C:\Users\Mcdull>d:

D:\>cd D:\Program Files\Oracle\VirtualBox

D:\Program Files\Oracle\VirtualBox>VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4RAC1\11.2.0.4RAC1.vdi"
UUID changed to: 6fd90da6-77f5-400e-9cd6-f0ae982562a5

D:\Program Files\Oracle\VirtualBox>

同样,RAC环境用到的所有磁盘对应的vdi文件都需要重新修改:

--本地磁盘
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4RAC1\11.2.0.4RAC1.vdi"
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4RAC2\11.2.0.4RAC2.vdi"

--共享磁盘
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4_storage\NewVirtualDisk1.vdi"
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4_storage\NewVirtualDisk2.vdi"
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4_storage\NewVirtualDisk3.vdi"
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4_storage\NewVirtualDisk4.vdi"
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4_storage\NewVirtualDisk5.vdi"
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4_storage\NewVirtualDisk6.vdi"
VBoxManage internalcommands sethduuid "Z:\Vbox\StandbyRAC_ENV\11.2.0.4_storage\NewVirtualDisk7.vdi"

此外,为了和之前的环境在“虚拟介质管理”容易区分,比如可以考虑把这些盘的名字修改一下:

rename 11.2.0.4RAC1.vdi 11gStandbyRAC1.vdi
rename 11.2.0.4RAC2.vdi 11gStandbyRAC2.vdi
rename NewVirtualDisk1.vdi StandbyNewVirtualDisk1.vdi
rename NewVirtualDisk2.vdi StandbyNewVirtualDisk2.vdi
rename NewVirtualDisk3.vdi StandbyNewVirtualDisk3.vdi
rename NewVirtualDisk4.vdi StandbyNewVirtualDisk4.vdi
rename NewVirtualDisk5.vdi StandbyNewVirtualDisk5.vdi
rename NewVirtualDisk6.vdi StandbyNewVirtualDisk6.vdi
rename NewVirtualDisk7.vdi StandbyNewVirtualDisk7.vdi

最后,说明下,如果是一个虚拟环境克隆出来的,UUID自动会变化,也就不会有这个UUID的问题。个人还是习惯于直接复制之前的模板环境~