{"version":"1.0","provider_name":"Jui-Nan Lin&#039;s Blog","provider_url":"https:\/\/jnlin.org","author_name":"jnlin","author_url":"https:\/\/jnlin.org\/author\/jnlin\/","title":"\u4f7f\u7528 Virtual Box Headless \u8dd1 Virtual Machine","html":"<p><a href=\"http:\/\/www.virtualbox.org\/\">VirtualBox<\/a> \u662f Sun (\u5f8c\u4f86\u88ab <a href=\"http:\/\/www.oracle.com\/\">Oracle<\/a> \u8cb7\u4e0b) \u958b\u767c\u7684\u4e00\u5957\u865b\u64ec\u5316\u8edf\u9ad4\u3002\u4ed6\u7684 Host OS \u53ef\u4ee5\u662f Windows, Linux, MacOS, FreeBSD\u3002\u9664\u6b64\u4e4b\u5916\uff0cVirtualBox \u53ef\u4ee5\u5728 Terminal \u4e0b\u57f7\u884c\uff0c\u986f\u793a\u7684\u756b\u9762\u7531 RDP\/VNC \u8f38\u51fa\uff0c\u4ea6\u5373 Headless \u6a21\u5f0f\u3002\u8981\u7279\u5225\u6ce8\u610f\u7684\u662f\uff0cRDP \u8f38\u51fa\u50c5\u9650\u65bc\u5c08\u5c6c\u6388\u6b0a\u7248\u672c\uff0cOSE (Open Source Edition) \u7248\u672c\u662f\u6c92\u6709\u9019\u500b\u529f\u80fd\u7684\u3002<\/p>  <p>\u8981\u4f7f\u7528 VNC \u8f38\u51fa\uff0c\u5fc5\u9808\u5728\u5b89\u88dd\u7684\u6642\u5019\u52a0\u5165 VNC \u652f\u63f4\uff1a<\/p> <code># cd \/usr\/ports\/emulators\/virtualbox-ose; make WITH_VNC=yes all install clean <\/code>  <p>\u5b89\u88dd\u597d VirtualBox \u4e4b\u5f8c\uff0c\u5fc5\u9808\u518d\u5b89\u88dd kernel module\uff1a<\/p> <code># cd \/usr\/ports\/emulators\/virtualbox-ose-kmod; make install clean<\/code>   <p>\u63a5\u8457\u628a\u9700\u8981\u7684 Kernel Module \u8f09\u9032\u4f86\uff1a<\/p> <code># kldload vboxdrv; kldload vboxnetadp; kldload vboxnetflt<\/code>   <p>\u4e4b\u524d\u5beb\u5728 <code>\/boot\/loader.conf<\/code> \u6703\u5c0e\u81f4\u958b\u6a5f\u6642 Kernel Panic\uff0c\u4f46\u5982\u679c\u958b\u5b8c\u6a5f\u624b\u52d5\u8f09\u5165\u5c31\u4e0d\u6703\uff0c\u76ee\u524d\u9084\u6c92\u627e\u51fa\u539f\u56e0\u3002<\/p>  <p>\u63a5\u4e0b\u4f86\u65b0\u589e\u4e00\u500b Virtual Machine\uff1a\uff08\u4ee5\u4e0b\u90fd\u53ef\u4ee5\u4e0d\u9700\u8981 root \u6b0a\u9650\uff09<\/p> <code>% VBoxManage createvm winxp --register<\/code>   <p>\u7136\u5f8c\u8a2d\u5b9a VM \u7684\u8cc7\u6e90\u9700\u6c42\uff1a<\/p> <code>% VBoxManage modifyvm winxp --acpi on --ioapic on --memory 1024 --cpus 2 --nic1 bridged --nictype 82540EM --bridgeadapter1 em1<\/code>   <p>\u4ee5\u4e0a\u7684\u7bc4\u4f8b\u5206\u914d\u4e86 1024MB (1GB) \u7684 RAM \u8207 2 \u500b Virtual CPU \u7d66 <code>winxp<\/code> \u9019\u500b VM\uff0c\u53e6\u5916\u5efa\u7acb\u4e86\u4e00\u5f35\u865b\u64ec\u7db2\u5361\uff0c\u578b\u865f\u70ba <code>Intel 82540EM<\/code>\uff0c\u6a4b\u63a5\u5230\u5be6\u9ad4\u7684 em1 \u9019\u5f35\u7db2\u5361\u4e0a\u3002<\/p>  <p>\u518d\u4f86\u5efa\u7acb\u4e00\u500b\u65b0\u7684 120GB \u865b\u64ec\u786c\u789f\uff1a<\/p> <code>% VBoxManage createhd --filename winxp --size 122880<\/code>   <p>\u5728 VM \u88e1\u589e\u52a0\u4e00\u500b IDE Controller\uff1a<\/p> <code>% VBoxManage storagectl winxp --name &quot;IDE Controller&quot; --add ide<\/code>   <p>\u628a\u786c\u789f\u8207\u5b89\u88dd ISO \u6a94\u9023\u63a5\u5230 IDE Controller\uff1a<\/p> <code>% VBoxManage storageattach winxp --storagectl &quot;IDE Controller&quot; --port 0 --device 0 --type hdd --medium winxp    <br \/>% VBoxManage storageattachwinxp --storagectl &quot;IDE Controller&quot; --port 1 --device 0 --type dvddrive --medium winxp.iso<\/code>   <p>\u63a5\u8457\u5c31\u53ef\u4ee5\u958b\u6a5f\u4e86\uff1a<\/p> <code>% VBoxHeadless -s winxp --vnc --vncport 5900 --vncpass password<\/code>   <p>\u57f7\u884c\u6210\u529f\u5f8c\uff0c\u53ef\u4ee5\u7528 VNC \u9023\u5165\u770b\u5230\u5b89\u88dd Windows XP \u7684\u756b\u9762\uff1a<\/p> <a href=\"http:\/\/jnlin.pixnet.net\/album\/photo\/118401718-virtualbox.png\"><img src=\"\/\/ext.pimg.tw\/jnlin\/1316252142-2922008165_m.png\" \/><\/a>   <p>\u95dc\u6a5f\u3001\u91cd\u958b\u6a5f\u53ef\u4ee5\u4f7f\u7528 <code>VBoxManage<\/code> \u4f86\u5b8c\u6210\uff1a<\/p> <code>% VBoxManage controlvm winxp poweroff<\/code>","type":"rich"}