{"id":6126,"date":"2016-11-19T21:36:31","date_gmt":"2016-11-19T13:36:31","guid":{"rendered":"https:\/\/kyle.ai\/blog\/?p=6126"},"modified":"2018-07-20T16:06:11","modified_gmt":"2018-07-20T08:06:11","slug":"%e5%b0%86mac%e7%b3%bb%e7%bb%9f%e6%96%87%e4%bb%b6%e5%85%b1%e4%ba%ab%e7%bb%99virtualbox%e4%b8%ad%e7%9a%84ubuntu-server","status":"publish","type":"post","link":"https:\/\/kyle.ai\/blog\/6126.html","title":{"rendered":"\u5c06Mac\u7cfb\u7edf\u6587\u4ef6\u5171\u4eab\u7ed9VirtualBox\u4e2d\u7684Ubuntu Server"},"content":{"rendered":"<p>1. \u5728Virtualbox\u7684\u7a97\u53e3\u4e2d\uff0c\u8bbe\u7f6e&#8211;\u5b58\u50a8&#8211;\u63a7\u5236\u5668\uff08IDE\uff09\uff1b\u70b9\u51fbIDE\u6811\u4e0b\u7684\u5149\u76d8\u56fe\u6807\uff1b\u70b9\u51fb\u3010\u5206\u914d\u5149\u9a71\u3011\u7684\u6700\u53f3\u4fa7\u5149\u76d8\u56fe\u6807\uff1b\u9009\u62e9\u865a\u62df\u5149\u76d8VBoxGuestAdditions.iso\uff08\u901a\u5e38\u5728Virtualbox\u7684\u5b89\u88c5\u76ee\u5f55\u4e2d\uff09\uff1b\u786e\u5b9a\u3002<\/p>\n<p>2. \u5728Ubuntu Server\u7684\u7ec8\u7aef\u4e2d\uff0c\u68c0\u67e5VBoxGuestAdditions.iso\u7684\u8def\u5f84\u3002<\/p>\n<p>sudo blkid\uff1b\u5f97\u5230\u5982\u4e0b\u4fe1\u606f\uff0c\u77e5\u9053\u5b83\u5728\/dev\/sr0 \u4e2d\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n\/dev\/sr0: LABEL=&quot;VBOXADDITIONS_4.3.10_93012&quot; TYPE=&quot;iso9660&quot;\r\n<\/pre>\n<p>3. \u6302\u8f7d\u8bbe\u5907<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\ncd ~\r\nmkdir cdrom \r\nsudo mount \/dev\/sr0\/  ~\/cdrom\/ \r\ncd ~\/cdrom\/ \r\nsudo  .\/VBoxLinuxAdditions.run\r\n<\/pre>\n<p>\u6700\u540e\u770b\u5230<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nBuilding the VirtualBox Guest Additions kernel modules ...done.\r\n<\/pre>\n<p>\u5373\u5b8c\u6210\uff0c\u91cd\u542fUbuntu Server\uff0c\u68c0\u67e5\u662f\u5426\u88c5\u597d\u3002<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nlsmod  | grep -io vboxguest\r\nmodinfo vboxguest\r\ncompgen -g | grep vboxsf\r\n<\/pre>\n<p>\u5728centos6\u4e0b\u9762\uff0cISO\u6240\u5728\u8def\u5f84\u4e3a \/dev\/scd0\uff0ccentos7\u662f \/dev\/sr0\u3002\u5b89\u88c5\u7684\u65f6\u5019\u53ef\u80fd\u62a5\u9519\uff1a<\/p>\n<pre class=\"brush: plain; title: ; notranslate\" title=\"\">\r\ncat \/var\/log\/vboxadd-install.log\r\n\/tmp\/vbox.0\/Makefile.include.header:112: *** Error: unable to find the sources of your current Linux kernel. Specify KERN_DIR=&lt;directory&gt; and run Make again.  Stop.\r\nCreating user for the Guest Additions.\r\nCreating udev rule for the Guest Additions kernel module.\r\n<\/pre>\n<p>\u539f\u56e0\u662f uname -a \u8f93\u51fa\u7684 Linux \u5185\u6838\u7248\u672c\uff0c\u4e0e \/usr\/src\/kernels \u76ee\u5f55\u4e0b\u9762\u7684\u7248\u672c\u53f7\u5bf9\u5e94\u4e0d\u4e0a\uff0c\u9700\u8981\u6307\u5b9aKENR_DIR\u53c2\u6570\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# ls \/usr\/src\/kernels\r\n2.6.32-754.2.1.el6.x86_64\r\n\r\n# uname -a\r\nLinux kyle-centos6 2.6.32-696.el6.x86_64\r\n\r\n# KERN_DIR=\/usr\/src\/kernels\/2.6.32-754.2.1.el6.x86_64\/ sh VBoxLinuxAdditions.run\r\n<\/pre>\n<p>\u63a5\u4e0b\u6765\u53c8\u62a5\u53e6\u4e00\u4e2a\u9519\u8bef\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\n# cat \/var\/log\/VBoxGuestAdditions.log\r\n\r\nchcon: can't apply partial context to unlabeled file `\/usr\/lib64\/VBoxGuestAdditions\/mount.vboxsf'\r\nvboxadd.sh: failed: modprobe vboxguest failed.\r\n<\/pre>\n<p>\u8fd8\u662f\u56e0\u4e3akernels headers\u6587\u4ef6\u4e0euname -a\u8f93\u51fa\u7684\u7248\u672c\u4e0d\u4e00\u81f4\u3002\u9700\u8981\u5378\u8f7d\u5f53\u524d\u7248\u672c\uff0c\u5e76\u5b89\u88c5\u4e0e\u5185\u6838\u5339\u914d\u7684\u7248\u672c\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nrpm -e kernel-devel-2.6.32-754.2.1.el6.x86_64   # \u5378\u8f7d\r\nwget -c &quot;ftp:\/\/mirror.switch.ch\/pool\/4\/mirror\/scientificlinux\/6.3\/x86_64\/updates\/security\/kernel-devel-2.6.32-696.el6.x86_64.rpm&quot;\r\nrpm -ivh kernel-devel-2.6.32-696.el6.x86_64.rpm\r\nyum install gcc\r\nsh VBoxLinuxAdditions.run \r\n<\/pre>\n<p>4. \u6dfb\u52a0\u7528\u6237<\/p>\n<p>\u5c06\u5f53\u524d\u767b\u9646\u7684\u7528\u6237\u6dfb\u52a0\u5230 vboxsf \u7ec4\u4e2d\u53bb\uff0c\u65b9\u4fbf\u5f97\u5230\u6302\u8f7d\u540e\u7684\u6587\u4ef6\u5939\u8bfb\u5199\u6743\u9650 \uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nsudo adduser &#x5B;USER_NAME] vboxsf\r\n<\/pre>\n<p>5. \u5728virtualbox\u4e2d\u6302\u8f7d\u76ee\u5f55<\/p>\n<p>\u5728\u865a\u62df\u673a\u7684\u8bbe\u7f6e\u9875\u9762\u4e2d\uff0c\u9009\u62e9\u300e\u5171\u4eab\u6587\u4ef6\u5939\u300f\u9875\uff0c\u7136\u540e\u6dfb\u52a0\u4e00\u4e2a\uff0c\u52fe\u9009\u4e0a\u56fa\u5b9a\u5206\u914d\u4e0e\u81ea\u52a8\u6302\u8f7d\uff0c\u4e0b\u6b21\u91cd\u542f\u540e\u5c31\u4f1a\u81ea\u52a8\u6302\u8f7d\u3002<\/p>\n<p><a href=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2016\/11\/\u5c4f\u5e55\u5feb\u7167-2016-11-19-\u4e0b\u53489.33.04.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-6127\" src=\"https:\/\/kyle.ai\/blog\/wp-content\/uploads\/2016\/11\/\u5c4f\u5e55\u5feb\u7167-2016-11-19-\u4e0b\u53489.33.04.png\" alt=\"%e5%b1%8f%e5%b9%95%e5%bf%ab%e7%85%a7-2016-11-19-%e4%b8%8b%e5%8d%889-33-04\" width=\"1350\" height=\"764\" \/><\/a><\/p>\n<p>\u53ef\u4ee5\u7528mount\u547d\u4ee4\u67e5\u770b\u6302\u8f7d\u540e\u7684\u5730\u5740<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nmount\r\nkyle on \/media\/sf_kyle type vboxsf (rw,nodev,relatime)\r\n<\/pre>\n<p>\u5728windows\u4e2d\u901a\u8fc7virtualbox\u5b89\u88c5\u7684linux\u865a\u62df\u673a\uff0c\u5171\u4eabwindows\u76ee\u5f55\u5230linux\u4e2d\u53bb\uff0c\u7ed3\u679c\u5728\u5171\u4eab\u7684\u6587\u4ef6\u5939\u4e0b\u9762\u65e0\u6cd5\u521b\u5efa\u8f6f\u94fe\u63a5\uff0c\u5982\u4e0b\u89e3\u51b3\uff0c\u5728virtualbox\u5b89\u88c5\u76ee\u5f55\u4e2d\u6267\u884c\u5982\u4e0b\u547d\u4ee4\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nVBoxManage setextradata YOURVMNAME VBoxInternal2\/SharedFoldersEnableSymlinksCreate\/YOURSHAREFOLDERNAME 1\r\n<\/pre>\n<p>\u5176\u4e2d\uff0cYOURVMNAME\u4e3a\u865a\u62df\u673a\u4e2dlinux\u7cfb\u7edf\u7684\u540d\u79f0\uff0cYOURSHAREFOLDERNAME \u4e3a\u5171\u4eab\u7684\u76ee\u5f55\u540d\u79f0\u3002<\/p>\n<p>6. \u8bbe\u7f6e\u6302\u8f7d\u7528\u6237\u4ee5\u53ca\u6587\u4ef6\u6743\u9650<\/p>\n<p>\u5047\u5982\u6211\u4eec\u60f3\u4ee5\u7528\u6237tars\u6302\u8f7d\uff0c\u7136\u540e\u6587\u4ef6\u6743\u9650\u662f 755\uff0c\u9996\u5148\u5728virtualbox\u4e2d\u53d6\u6d88\u6389\u6587\u4ef6\u5171\u4eab\u7684\u201c\u81ea\u52a8\u6302\u8f7d\u201d\u9009\u9879\u3002\u7136\u540e\u5728\u865a\u62df\u673a\u4e2d\u8bbe\u7f6e\u7cfb\u7edf\u542f\u52a8\u65f6\u6267\u884c\u7684mount\u547d\u4ee4\uff1a<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\r\nvim \/etc\/rc.local\r\n\r\nsudo mount -t vboxsf SHARE_NAME -o rw,dmode=755,gid=GROUP_ID,uid=USER_ID \/path\/on\/guest\r\n\r\ngid\u4e0euid\u53ef\u4ee5\u901a\u8fc7  id username \u547d\u4ee4\u62ff\u5230\u3002\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>1. \u5728Virtualbox\u7684\u7a97\u53e3\u4e2d\uff0c\u8bbe\u7f6e&#8211;\u5b58\u50a8&#8211;\u63a7\u5236\u5668\uff08IDE\uff09\uff1b\u70b9\u51fbIDE\u6811\u4e0b\u7684\u5149 [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4],"tags":[],"class_list":["post-6126","post","type-post","status-publish","format-standard","hentry","category-skill"],"_links":{"self":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6126","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/comments?post=6126"}],"version-history":[{"count":5,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6126\/revisions"}],"predecessor-version":[{"id":6648,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/posts\/6126\/revisions\/6648"}],"wp:attachment":[{"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/media?parent=6126"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/categories?post=6126"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kyle.ai\/blog\/wp-json\/wp\/v2\/tags?post=6126"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}