Linux 虚拟机配置文件分为两处。
windows下:
1、用户名/.VirtualBox/
这里面有2个配置文件:
VirtualBox.xml 和 VirtualBox.xml-prev. 后面一个是备份文件, 可以不用管他, 前面一个我们可以看看里面的内容:
<?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="http://www.innotek.de/VirtualBox-settings" version="1.12-windows">
<Global>
<ExtraData>
<ExtraDataItem name="GUI/DetailsPageBoxes" value="general,system,preview,display,storage,audio,network,usb,sharedFolders,description"/>
<ExtraDataItem name="GUI/GroupDefinitions/" value="m=83d5321d-32f6-438b-b81c-3e336ccc1460,m=ef9627ae-2637-4f90-a9e9-1423fbdccbd1"/>
<ExtraDataItem name="GUI/HostScreenSaverDisabled" value="false"/>
<ExtraDataItem name="GUI/Input/AutoCapture" value="true"/>
<ExtraDataItem name="GUI/Input/HostKeyCombination" value="163"/>
<ExtraDataItem name="GUI/LastItemSelected" value="m=xp"/>
<ExtraDataItem name="GUI/LastWindowPosition" value="298,89,770,550"/>
<ExtraDataItem name="GUI/SplitterSizes" value="192,573"/>
<ExtraDataItem name="GUI/SuppressMessages" value="confirmInputCapture"/>
</ExtraData>
<MachineRegistry>
<MachineEntry uuid="{ef9627ae-2637-4f90-a9e9-1423fbdccbd1}" src="D:\VirtualBox VMs\xp\xp.vbox"/>
<MachineEntry uuid="{55a1a18a-0cb6-4238-bcdb-2df5d647e255}" src="D:\VirtualBox VMs\centos\centos.vbox"/>
</MachineRegistry>
<MediaRegistry>
<HardDisks/>
<DVDImages/>
<FloppyImages/>
</MediaRegistry>
<NetserviceRegistry>
<DHCPServers>
<DHCPServer networkName="HostInterfaceNetworking-VirtualBox Host-Only Ethernet Adapter" IPAddress="192.168.56.100" networkMask="255.255.255.0" lowerIP="192.168.56.101" upperIP="192.168.56.254" enabled="1"/>
</DHCPServers>
</NetserviceRegistry>
<SystemProperties defaultMachineFolder="D:\VirtualBox VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/>
<USBDeviceFilters/>
</Global>
</VirtualBox>
注意此处定义虚拟机文件uuid及所在位置:
<MachineRegistry>
<MachineEntry uuid="{ef9627ae-2637-4f90-a9e9-1423fbdccbd1}" src="D:\VirtualBox VMs\xp\xp.vbox"/>
<MachineEntry uuid="{55a1a18a-0cb6-4238-bcdb-2df5d647e255}" src="D:\VirtualBox VMs\centos\centos.vbox"/>
</MachineRegistry>
其中uuid来自于src对应文件.vbox里面的:
<Machine uuid="{55a1a18a-0cb6-4238-bcdb-2df5d647e255}" name="centos" OSType="RedHat" snapshotFolder="Snapshots" lastStateChange="2015-12-02T14:16:08Z">
如果不小心重新重新安装VirtualBox或者删除了VirtualBox的配置文件,只要虚拟机没有删除(如.vbox、.vdi文件),可以 重新安装虚拟机后仿照MachineRegistry里MachineEntry添加一行。注意uuid不错,必须和.vbox里的一致。
2、虚拟机目录里的.vbox文件
这是个文本文件,可以直接编辑。例如:
<?xml version="1.0"?>
<!--
** DO NOT EDIT THIS FILE.
** If you make changes to this file while any VirtualBox related application
** is running, your changes will be overwritten later, without taking effect.
** Use VBoxManage or the VirtualBox Manager GUI to make changes.
-->
<VirtualBox xmlns="http://www.innotek.de/VirtualBox-settings" version="1.15-windows">
<Machine uuid="{55a1a18a-0cb6-4238-bcdb-2df5d647e255}" name="centos" OSType="RedHat" snapshotFolder="Snapshots" lastStateChange="2015-12-02T14:16:08Z">
<MediaRegistry>
<HardDisks>
<HardDisk uuid="{e1e7ffe5-9b7c-4c94-932f-72b4810a274f}" location="centos-disk2_1.vmdk" format="VMDK" type="Normal"/>
<HardDisk uuid="{b914d8b0-b772-427b-a840-cadc1cf0391a}" location="data.vdi" format="VDI" type="Normal"/>
</HardDisks>
<DVDImages/>
<FloppyImages/>
</MediaRegistry>
<ExtraData>
<ExtraDataItem name="GUI/LastCloseAction" value="PowerOff"/>
<ExtraDataItem name="GUI/LastGuestSizeHint" value="720,400"/>
<ExtraDataItem name="GUI/LastNormalWindowPosition" value="8,30,720,445"/>
<ExtraDataItem name="GUI/RestrictedRuntimeDevicesMenuActions" value="HardDrives"/>
<ExtraDataItem name="GUI/RestrictedRuntimeMachineMenuActions" value="SaveState,PowerOff"/>
<ExtraDataItem name="GUI/StatusBar/IndicatorOrder" value="HardDisks,OpticalDisks,FloppyDisks,Network,USB,SharedFolders,Display,VideoCapture,Features,Mouse,Keyboard"/>
</ExtraData>
<Hardware version="2">
<CPU count="1" hotplug="false">
<HardwareVirtEx enabled="true"/>
<HardwareVirtExNestedPaging enabled="true"/>
<HardwareVirtExVPID enabled="true"/>
<HardwareVirtExUX enabled="true"/>
<PAE enabled="true"/>
<HardwareVirtExLargePages enabled="true"/>
<HardwareVirtForce enabled="false"/>
</CPU>
<Memory RAMSize="512" PageFusion="false"/>
<HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/>
<HPET enabled="false"/>
<Chipset type="PIIX3"/>
<Boot>
<Order position="1" device="HardDisk"/>
<Order position="2" device="DVD"/>
<Order position="3" device="None"/>
<Order position="4" device="None"/>
</Boot>
<Display VRAMSize="12" monitorCount="1" accelerate3D="false" accelerate2DVideo="false"/>
<VideoCapture enabled="false" screens="18446744073709551615" horzRes="1024" vertRes="768" rate="512" fps="25" maxTime="0" maxSize="0"/>
<RemoteDisplay enabled="false" authType="Null" authTimeout="5000"/>
<BIOS>
<ACPI enabled="true"/>
<IOAPIC enabled="false"/>
<Logo fadeIn="true" fadeOut="true" displayTime="0"/>
<BootMenu mode="MessageAndMenu"/>
<TimeOffset value="0"/>
<PXEDebug enabled="false"/>
</BIOS>
<USB>
<Controllers>
<Controller name="OHCI" type="OHCI"/>
<Controller name="EHCI" type="EHCI"/>
</Controllers>
<DeviceFilters/>
</USB>
<Network>
<Adapter slot="0" enabled="true" MACAddress="080027F9C460" cable="true" speed="0" type="82540EM">
<DisabledModes>
<InternalNetwork name="intnet"/>
<NATNetwork name="NatNetwork"/>
</DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</Adapter>
<Adapter slot="1" enabled="true" MACAddress="080027597536" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
<InternalNetwork name="intnet"/>
<NATNetwork name="NatNetwork"/>
</DisabledModes>
<BridgedInterface name="Microsoft Loopback Adapter"/>
</Adapter>
<Adapter slot="2" enabled="true" MACAddress="080027E33818" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
<InternalNetwork name="intnet"/>
<NATNetwork name="NatNetwork"/>
</DisabledModes>
<BridgedInterface name="Broadcom 802.11n 网络适配器"/>
</Adapter>
<Adapter slot="3" enabled="false" MACAddress="08002724B024" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="4" enabled="false" MACAddress="0800275ACDE2" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="5" enabled="false" MACAddress="080027715437" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="6" enabled="false" MACAddress="08002733EDEE" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
<Adapter slot="7" enabled="false" MACAddress="080027B318D4" cable="true" speed="0" type="82540EM">
<DisabledModes>
<NAT>
<DNS pass-domain="true" use-proxy="false" use-host-resolver="false"/>
<Alias logging="false" proxy-only="false" use-same-ports="false"/>
</NAT>
</DisabledModes>
</Adapter>
</Network>
<UART>
<Port slot="0" enabled="false" IOBase="0x3f8" IRQ="4" hostMode="Disconnected"/>
<Port slot="1" enabled="false" IOBase="0x2f8" IRQ="3" hostMode="Disconnected"/>
</UART>
<LPT>
<Port slot="0" enabled="false" IOBase="0x378" IRQ="7"/>
<Port slot="1" enabled="false" IOBase="0x378" IRQ="7"/>
</LPT>
<AudioAdapter controller="AC97" driver="DirectSound" enabled="true"/>
<RTC localOrUTC="UTC"/>
<SharedFolders/>
<Clipboard mode="Disabled"/>
<DragAndDrop mode="Disabled"/>
<IO>
<IoCache enabled="true" size="5"/>
<BandwidthGroups/>
</IO>
<HostPci>
<Devices/>
</HostPci>
<EmulatedUSB>
<CardReader enabled="false"/>
</EmulatedUSB>
<Guest memoryBalloonSize="0"/>
<GuestProperties>
<GuestProperty name="/VirtualBox/HostInfo/GUI/LanguageID" value="zh_CN" timestamp="1449065768536626000" flags=""/>
</GuestProperties>
</Hardware>
<StorageControllers>
<StorageController name="IDE" type="PIIX4" PortCount="2" useHostIOCache="true" Bootable="true">
<AttachedDevice passthrough="false" type="DVD" hotpluggable="false" port="1" device="0"/>
</StorageController>
<StorageController name="SATA" type="AHCI" PortCount="2" useHostIOCache="false" Bootable="true" IDE0MasterEmulationPort="0" IDE0SlaveEmulationPort="1" IDE1MasterEmulationPort="2" IDE1SlaveEmulationPort="3">
<AttachedDevice type="HardDisk" hotpluggable="true" port="0" device="0">
<Image uuid="{e1e7ffe5-9b7c-4c94-932f-72b4810a274f}"/>
</AttachedDevice>
<AttachedDevice type="HardDisk" hotpluggable="false" port="1" device="0">
<Image uuid="{b914d8b0-b772-427b-a840-cadc1cf0391a}"/>
</AttachedDevice>
</StorageController>
</StorageControllers>
</Machine>
</VirtualBox>
以直接修改这个文件, 但是文件注释告诉我们不要手动修改. 所以还是老老实实用程序或者通过界面修改吧。