我有一台运行 vagrant/virtualbox 的非常强大的主机。我安装了官方 Xenial 云镜像。启动非常慢,需要 3 分钟以上。如果我查看 virtualbox 的日志,会发现有几个时间段,在几十秒内什么都没有发生:
00:00:05.306399 GIM: KVM: Enabled wall-clock struct. at 0x0000000002103128 - u32Sec=1490709692 u32Nano=164211738 uVersion=2
00:00:15.853501 PIT: mode=2 count=0x12a5 (4773) - 249.98 Hz (ch=0)
00:00:17.635954 APIC0: Switched mode to x2APIC
00:00:18.161514 PIT: mode=0 count=0x10000 (65536) - 18.20 Hz (ch=0)
00:00:18.893709 CPUM: VCPU 1: Cached APIC base MSR = 0xfee00800
00:00:18.893902 APIC1: Switched mode to x2APIC
00:00:18.893941 GIM: KVM: VCPU 1: Enabled system-time struct. at 0x000000021ffed040 - u32TscScale=0xfffed226 i8TscShift=-1 uVersion=2 fFlags=0x1 uTsc=0x227f7943f uVirtNanoTS=0x113fa8853
00:00:40.767172 PIIX3 ATA: Ctl#0: RESET, DevSel=0 AIOIf=0 CmdIf0=0x00 (-1 usec ago) CmdIf1=0x00 (-1 usec ago)
00:00:40.767323 PIIX3 ATA: Ctl#0: finished processing RESET
00:00:40.770214 PIIX3 ATA: Ctl#1: RESET, DevSel=0 AIOIf=0 CmdIf0=0x00 (-1 usec ago) CmdIf1=0x00 (-1 usec ago)
00:00:40.770323 PIIX3 ATA: Ctl#1: finished processing RESET
00:00:57.578234 NAT: Link up
00:01:01.526079 LsiLogic#0: 2/0 (Bus/Target) doesn't exist
...
00:01:01.535077 LsiLogic#0: Guest issued CDB {0x12, 0x0, 0x0, 0x0, 0x24, 0x0}
00:01:24.478703 AIOMgr: Flush failed with VERR_INVALID_PARAMETER, disabling async flushes
00:01:32.045017 VMMDev: Guest Additions information report: Version 5.1.18 r114002 '5.1.18'
怎么了?
答案1
我也遇到了同样的问题 - 也使用官方的 Xenial 云镜像 - 我通过将其添加到我的 Vagrantfile 中解决了该问题:
config.vm.provider "virtualbox" do |vb|
vb.customize [ "modifyvm", :id, "--uartmode1", "disconnected" ] # THIS LINE
end
因此,该ubuntu-xenial-16.04-cloudimg-console.log
文件不再在启动时创建,并且启动时间大大缩短。