Run bitbake in Virtual Box with Shared Folder

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:
APPROACH 1: Make use of Virtual Box Shared Folder so that the guest accesses a folder on the SSD_PCIE drive as  a network drive
APPROACH 2: Physically mounted the SSD_PCIE disk inside the guest distribution

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.

Tested on the following configuration

  • Host: Ubuntu Xenial 16.04, VBox 5.2.2 + GuestAdditions
  • Guest: Ubuntu Trusty 14.04

APPROACH 1: Shared Folder

Used acronym: VB_SF – VirtualBox Shared Folder

Shared folder settings

  • Location on host (Choose any location you like): /mnt/ssd_pcie/yocto_build_root
  • Name: yocto_build_root
  • Shared folder settings: Read only, [ ] Automount, [x] Permanent
  • Add necessary users to groups
    • /etc/group on host: vboxusers:x:<gid>:<host_user>
    • /etc/group on guest: vboxsf:x:<gid>:<guest_user>

Issue 1: Symlinks are disabled for security reasons in VB_SF

Courtesy: https://ahtik.com/fixing-your-virtualbox-shared-folder-symlink-error/

Enable Symlinks in Virtual Box by entering the following commands on your host machine:

Example:

Issue 2: Correct permission on VB_SF to fix issues like “tar wants to set utime”

Courtesy: http://redwarrior.org/blog/?p=61

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 yocto_build_root to /media/yocto_build_root):

Issue 3: Hard links are not allowed in shared folders

Only allow Symlinks adding a script (alias won’t work) that fakes the native ln command. Execute the following line on the guest system:

Issue 4: Insufficient inods on VB_SF (can be inspected by ‘df -i’)

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:

Issue 5 UNSOLVED: If tar contains hard links, they cannot be extracted

Don’t know how to fix this, so APPROACH 2 is the way to go!

APPROACH 2: Physically mounted disk

Courtesy: https://superuser.com/questions/495025/use-physical-harddisk-in-virtual-box

  • Add user to ‘disk’ group on host: usermod -a -G disk <host_user>
  • Create a vmdk file of the hard drive (not partition): VBoxManage internalcommands
  • createrawvmdk -filename /path/to/file.vmdk -rawdisk /dev/<disk>
  • Add vmdk file to mountable discs
  • Set mode: File -> Virtual Media Manager -> Choose disc -> Type: WriteThrough

Prepare guest for bitbake

Courtesy: http://www.yoctoproject.org/docs/1.7.3/ref-manual/ref-manual.html

 

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.