{"id":418,"date":"2018-01-02T22:15:38","date_gmt":"2018-01-02T21:15:38","guid":{"rendered":"http:\/\/wp12759592.server-he.de\/?p=418"},"modified":"2018-01-02T22:15:38","modified_gmt":"2018-01-02T21:15:38","slug":"run-bitbake-in-virtual-box-with-shared-folder","status":"publish","type":"post","link":"https:\/\/www.timokorthals.de\/?p=418","title":{"rendered":"Run bitbake in Virtual Box with Shared Folder"},"content":{"rendered":"<p>I just had to update the build host for the embedded operating system of the AMiRo Autonomous Mini Robot to Ubuntu 16.04. Since the old-fashioned Yocto 1.7 only bakes on Ubuntu 14.04 I had to virtualize the machine. But since the downloads and builds take up a huge amount of space, my approach was to keep the virtualized build distribution (aka guest) as slim as possible and make use of the vast amount of super fast SSD_PCIE space of the Virtual Box host. So there are two possibilities:<br \/>\n<strong>APPROACH 1<\/strong>: Make use of Virtual Box Shared Folder so that the guest accesses a folder on the SSD_PCIE drive as\u00a0 a network drive<br \/>\n<strong>APPROACH 2<\/strong>: Physically mounted the SSD_PCIE disk inside the guest distribution<\/p>\n<p>To bypass any long readings: APPROACH 1 does not work due to unsupported hard links between host and guest and second, it is horribly slow. APPROACH 2 is the way to go and runs super fast. For didactical reasons, both approaches are listed.<\/p>\n<h2>Tested on the following configuration<\/h2>\n<ul>\n<li>Host: Ubuntu Xenial 16.04, VBox 5.2.2 + GuestAdditions<\/li>\n<li>Guest: Ubuntu Trusty 14.04<\/li>\n<\/ul>\n<h2>APPROACH 1: Shared Folder<\/h2>\n<p>Used acronym: VB_SF &#8211; VirtualBox Shared Folder<\/p>\n<h3>Shared folder settings<\/h3>\n<ul>\n<li>Location on host (Choose any location you like): \/mnt\/ssd_pcie\/yocto_build_root<\/li>\n<li>Name: yocto_build_root<\/li>\n<li>Shared folder settings: Read only, [ ] Automount, [x] Permanent<\/li>\n<li>Add necessary users to groups\n<ul>\n<li>\/etc\/group on host: <span class=\"lang:sh decode:true crayon-inline\">vboxusers:x:&lt;gid&gt;:&lt;host_user&gt;<\/span><\/li>\n<li>\/etc\/group on guest: <span class=\"lang:sh decode:true crayon-inline\">vboxsf:x:&lt;gid&gt;:&lt;guest_user&gt;<\/span><\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<h3>Issue 1: Symlinks are disabled for security reasons in VB_SF<\/h3>\n<p>Courtesy: https:\/\/ahtik.com\/fixing-your-virtualbox-shared-folder-symlink-error\/<\/p>\n<p>Enable Symlinks in Virtual Box by entering the following commands on your host machine:<\/p>\n<pre class=\"lang:sh decode:true\" title=\"symlinks\">VBoxManage setextradata VM_NAME\r\nVBoxInternal2\/SharedFoldersEnableSymlinksCreate\/SHARE_NAME 1\r\n<\/pre>\n<p>Example:<\/p>\n<pre class=\"lang:sh decode:true\" title=\"symlinks example\">VBoxManage setextradata yocto-build-trusty\r\nVBoxInternal2\/SharedFoldersEnableSymlinksCreate\/yocto_build_root 1\r\n<\/pre>\n<h3>Issue 2: Correct permission on VB_SF to fix issues like &#8220;tar wants to set utime&#8221;<\/h3>\n<p>Courtesy: http:\/\/redwarrior.org\/blog\/?p=61<\/p>\n<p>For some reason, uid and gid are not correctly set in Virtual Box guests, so it needs to be done manually. Add to \/etc\/rc.local on the guest system (mount\u00a0yocto_build_root to \/media\/yocto_build_root):<\/p>\n<pre class=\"lang:sh decode:true\" title=\"utime\">mount -t vboxsf -o uid=1000,gid=1000 yocto_build_root \/media\/sf_yocto_build_root<\/pre>\n<h3>Issue 3: Hard links are not allowed in shared folders<\/h3>\n<p>Only allow Symlinks adding a script (alias won&#8217;t work) that fakes the native ln command. Execute the following line on the guest system:<\/p>\n<pre class=\"lang:sh decode:true\" title=\"Fake ln\">mv \/bin\/ln \/bin\/ln.org &amp;&amp; echo -e '#!\/bin\/bash\\n\/bin\/ln \"$@\"' &gt; \/bin\/ln<\/pre>\n<h3>Issue 4: Insufficient inods on VB_SF (can be inspected by &#8216;df -i&#8217;)<\/h3>\n<p>If you execute bitbake on the guest, it will complain about insufficient inods. So you have to decrease the numbers of available inods in the sanity check of the bitbake configuration in .\/build\/conf\/local.conf from 100k\/1k to 999:<\/p>\n<pre class=\"lang:sh decode:true\" title=\"inode configuration\">BB_DISKMON_DIRS = \"\\\r\n    STOPTASKS,${TMPDIR},1G,999 \\\r\n    STOPTASKS,${DL_DIR},1G,999 \\\r\n    STOPTASKS,${SSTATE_DIR},1G,999 \\\r\n    ABORT,${TMPDIR},100M,999 \\\r\n    ABORT,${DL_DIR},100M,999 \\\r\n    ABORT,${SSTATE_DIR},100M,999\"<\/pre>\n<h3>Issue 5 UNSOLVED: If tar contains hard links, they cannot be extracted<\/h3>\n<p>Don&#8217;t know how to fix this, so APPROACH 2 is the way to go!<\/p>\n<h2>APPROACH 2: Physically mounted disk<\/h2>\n<p>Courtesy: https:\/\/superuser.com\/questions\/495025\/use-physical-harddisk-in-virtual-box<\/p>\n<ul>\n<li>Add user to &#8216;disk&#8217; group on host: usermod -a -G disk &lt;host_user&gt;<\/li>\n<li>Create a vmdk file of the hard drive (not partition): VBoxManage internalcommands<\/li>\n<li>createrawvmdk -filename \/path\/to\/file.vmdk -rawdisk \/dev\/&lt;disk&gt;<\/li>\n<li>Add vmdk file to mountable discs<\/li>\n<li>Set mode: File -&gt; Virtual Media Manager -&gt; Choose disc -&gt; Type: WriteThrough<\/li>\n<\/ul>\n<h2>Prepare guest for bitbake<\/h2>\n<p>Courtesy: http:\/\/www.yoctoproject.org\/docs\/1.7.3\/ref-manual\/ref-manual.html<\/p>\n<pre class=\"lang:sh decode:true\" title=\"Guest preparation\"># Yocto 1.7.* essentials\r\napt-get install gawk wget git-core diffstat unzip texinfo gcc-multilib build-essential chrpath socat libsdl1.2-dev xterm make xsltproc docbook-utils fop dblatex xmlto autoconf automake libtool libglib2.0-dev\r\n# Other packages\r\napt-get install subversion dkms git git-gui tig rsync screen vim nano iftop htop bmon filezilla zip rar unrar p7zip unzip zsh sshuttle sshfs byobu exfat-fuse exfat-utils atop iperf agrep ghex ntp arptables\r\n#\u00a0Ubuntu development (or whatever you like)\r\napt-get install geany valgrind g++ cmake ninja-build<\/pre>\n<p>&nbsp;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I just had to update the build host for the embedded operating system of the AMiRo Autonomous Mini Robot to Ubuntu 16.04. Since the old-fashioned Yocto 1.7 only bakes on Ubuntu 14.04 I had to virtualize the machine. But since the downloads and builds take up a huge amount of space, my approach was to &hellip; <a href=\"https:\/\/www.timokorthals.de\/?p=418\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Run bitbake in Virtual Box with Shared Folder<\/span> <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[3],"tags":[],"_links":{"self":[{"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=\/wp\/v2\/posts\/418"}],"collection":[{"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=418"}],"version-history":[{"count":2,"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=\/wp\/v2\/posts\/418\/revisions"}],"predecessor-version":[{"id":420,"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=\/wp\/v2\/posts\/418\/revisions\/420"}],"wp:attachment":[{"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.timokorthals.de\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}