之前我安装了VirtualBox 来跑 Linux 虚拟机, 开始设置的时候设了 4G 内存, 结果后来不能改了. 造成的结果就是一开机, 内存飙到40%, 一开VirtualBox, 直接飙到95%. 然后开个数据库开个EBS 服务, 基本就不用干其他事情了.
怎么修改VirtualBox 虚拟机的内存分配呢? 有一个实用程序可以直接修改:
cd C:\Program Files\VirtualBox VBoxManage.exe modifyvm "EBS R12 RUP8" --memory "2048"
那么这个程序修改了什么呢? 我们可以去看看下面两个配置文件;
1. 在User 目录下, 有个不可见目录 .VirtualBox, 里面有两个文件比较重要: 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="generalClosed,previewClosed,system,displayClosed,storageClosed,audioClosed,networkClosed,usbClosed,sharedFoldersClosed,descriptionClosed,serialPortsClosed"/> <ExtraDataItem name="GUI/GroupDefinitions/" value="m=28233f89-d496-4c66-9d63-2f42f23f253a,m=34d9ffe0-5c7d-4eab-a87e-b2321e1babcb"/> <ExtraDataItem name="GUI/HostScreenSaverDisabled" value="false"/> <ExtraDataItem name="GUI/Input/AutoCapture" value="false"/> <ExtraDataItem name="GUI/Input/HostKeyCombination" value="163"/> <ExtraDataItem name="GUI/LastItemSelected" value="m=EBS R12 RUP8"/> <ExtraDataItem name="GUI/LastWindowPosition" value="654,228,770,550"/> <ExtraDataItem name="GUI/RecentFolderHD" value="E:/"/> <ExtraDataItem name="GUI/RecentListHD" value="E:\EBS R12 RUP8.vbox;E:\EBS R12 RUP8-disk1.vdi;E:\EBS_Linux_64.vdi;E:\Linux\Linux.vdi;"/> <ExtraDataItem name="GUI/SplitterSizes" value="231,533"/> <ExtraDataItem name="GUI/SuppressMessages" value=",remindAboutMouseIntegrationOff,remindAboutMouseIntegrationOn,remindAboutAutoCapture,showRuntimeError.warning.HostAudioNotResponding,showRuntimeError.warning.BrokenSharedFolder,confirmInputCapture,remindAboutMouseIntegration,warnAboutInaccessibleMedia"/> <ExtraDataItem name="GUI/TrayIcon/Enabled" value="false"/> <ExtraDataItem name="GUI/UpdateCheckCount" value="18"/> <ExtraDataItem name="GUI/UpdateDate" value="never"/> <ExtraDataItem name="HostOnly/VirtualBox Host-Only Ethernet Adapter/IPAddress" value="192.168.77.1"/> <ExtraDataItem name="HostOnly/VirtualBox Host-Only Ethernet Adapter/IPNetMask" value="255.255.255.0"/> </ExtraData> <MachineRegistry> <MachineEntry uuid="{28233f89-d496-4c66-9d63-2f42f23f253a}" src="G:/VMs/EBS R12 RUP8/EBS R12 RUP8.vbox"/> <MachineEntry uuid="{34d9ffe0-5c7d-4eab-a87e-b2321e1babcb}" src="C:\Users\yuzzhang\VirtualBox VMs\ubuntu_server\ubuntu_server.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="0"/> </DHCPServers> </NetserviceRegistry> <SystemProperties defaultMachineFolder="C:\Users\yuzzhang\VirtualBox VMs" defaultHardDiskFormat="VDI" VRDEAuthLibrary="VBoxAuth" webServiceAuthLibrary="VBoxAuth" LogHistoryCount="3" exclusiveHwVirt="false"/> <USBDeviceFilters/> </Global> </VirtualBox>
G:/VMs/EBS R12 RUP8/EBS R12 RUP8.vbox我们就到这个目录下面去找, 可以看到两个文件, 一个是 .vbox 文件, 另一个是 .vbox-prev 文件. 同样后面的是备份文件不用管;
在这个配置文件里面
<Hardware version="2"> <CPU count="2" executionCap="90" 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="2048" PageFusion="false"/> <HID Pointing="PS2Mouse" Keyboard="PS2Keyboard"/> <HPET enabled="false"/> <Chipset type="PIIX3"/> <Boot> <Order position="1" device="Floppy"/> <Order position="2" device="DVD"/> <Order position="3" device="HardDisk"/> <Order position="4" device="None"/> ...
也可以直接修改这个文件, 但是文件注释告诉我们不要手动修改. 所以还是老老实实用程序或者通过界面修改吧;