Click here to Skip to main content
14,090,690 members
Click here to Skip to main content
Add your own
alternative version


6 bookmarked
Posted 18 Feb 2016
Licenced CPOL

How to run Yocto Linux OS in a virtual machine

, 18 Feb 2016
Rate this:
Please Sign up or sign in to vote.
In this article I'll show how to create a runnable image of Yocto and how to test it inside QEMU, a basic software emulator; and following how to run it inside an Hypervisor, like Microsoft Hyper-V on Windows.

This article is for our sponsors at CodeProject. These articles are intended to provide you with information on products and services that we consider useful and of value to developers

Get access to the new Intel® IoT Developer Kit, a complete hardware and software solution that allows developers to create exciting new solutions with the Intel® Galileo and Intel® Edison boards. Visit the Intel® Developer Zone for IoT.

Sometime we need a complete development environment to compile, deploy and test our solutions, and sometimes we can't play directly on the hardware, or, simply, the provided SDK is not enough for our development plans. This could be, for example, the case of Intel Edison or Galileo: how can I compile entire frameworks, runtimes and their dependencies on Yocto Linux OS?

In this article I'll show how to create a runnable image of Yocto and how to test it inside QEMU, a basic software emulator; and following how to run it inside an Hypervisor, like Microsoft Hyper-V on Windows.

Prerequisites to Work with this Tutorial

  • Debian/Ubuntu (tested on Debian 8.2 amd64)
  • Internet Connection
  • At least 100 GB free space on the disk

Preliminary Preparation of Your Building Machine

As root (or via "sudo") run the following command

# apt-get install wget git-core unzip make gcc g++ build-essential subversion sed autoconf automake texi2html texinfo coreutils diffstat python-pysqlite2 docbook-utils libsdl1.2-dev libxml-parser-perl libgl1-mesa-dev libglu1-mesa-dev xsltproc desktop-file-utils chrpath groff libtool xterm gawk fop

Note 1: the success of the previous command depends on the version of the Ubuntu/Debian you are using. Eventually, to resolve dependencies of packages you can run "aptitude" and force the installation of the right version of packages you need (for example, "aptitude install libsdl1.2-dev").

Note 2: for other Linux-distribution, like RadHat, CentOS, Fedora, SuSe, Gentoo, etc… I suggest to check the respective versions of the previous package using the correct package-manager (for example, zypper, yum, ...).

First Step: Set Up Working Folder

As normal user withous privileges (no root)

# cd
# mkdir yocto-2.0
# cd yocto-2.0
# wget
# tar xvjf poky-jethro-14.0.0.tar.bz2
# cd poky-jethro-14.0.0/

Note 3: you can choose other development branch of Yocto releases following this link In this tutorial will use the current latest release "Jocto Poky codename Jethro".

Note 4: if you want to fetch the lastest bleeding edge release of Yocto sources you can grab the master development branch, you need to substitute the wget operation with the following:

# git clone git://
# cd poky

Note 5: You can in addition also select a specific development branch using its codenname. For example:

# git clone -b jethro git://

Second Step: Set the Environment Variables for Your System Shell

There is a very easy-to-use script provided by Yocto developers.

# . ./oe-init-build-env

After you run the script, if it worked, your location will be changed to a build subdirectory that will be your new workspace. Something like /home/<your user>/yocto-2.0/poky-jethro-14.0.0/build/.

Third Step: Set Up Bitbake

Executing the previous script a conf/local.conf file was created.

The configuration file needs to set up bitbake, the build engine of Yocto (core component of the Yocto Project).

Edit the bitbake configuration file with your preferred text editor. In this tutorial we'll use nano, a simple command-line-interface text editor for Unix-like environments, as follows:

# cd conf/
# nano local.conf

Uncomment the following rows

DL_DIR ?= "${TOPDIR}/downloads"
SSTATE_DIR ?= "${TOPDIR}/sstate-cache"
TMPDIR ?= "${TOPDIR}/tmp"
SDKMACHINE ?= "i686"

I suggest to build all the available extra features to the image. The resulting images will be heavy (around 8GB each), but absolutely complete and absolutely versatile for every need of development.

EXTRA_IMAGE_FEATURES = "dbg-pkgs dev-pkgs ptest-pkgs tools-sdk tools-debug eclipse-debug tools-profile tools-testapps debug-tweaks"

Now, save the changes made to the file local.conf with CTRL+X keyboard combination.


# cd ..
# hob

Now an instance of Hob (the GTK2-based graphical user interface for BitBake) should start, checking for the correctness of build system.

Now select qemux86 as machine in the dropdown menu.

Wait until Hob will finish parsing BitBake recipes and generating dependency tree. Then, select your preferred target image to build from the "select an image recipe" from the menu above. In this sample we'll select the full core image without the GUI: core-image-full-cmdline.

Now click on "Advanced Configuration".

In "Image types" panel leave poky in the "Distro" menu if you want to build the latest stable release. Then in "Image types" field select the format you need: usually, I select ".iso", ".vdi" and ".vmdk", they are the most useful and comfortable formats.

In "Output" panel please select the best options that fit your needs. I suggest to add at least 4GB of free storage to your image, to populate the SDK for i686 architecture (if you are playing with Edison development board). In addition, I find very usefull to set "deb" as packaging format for the root filesystem. So, as follows:

Ok, save. Now, you are ready to build your image! Click on "Build image" button!

Hob will launch for you an instance of bitbake core-image-full-cmdline with your favorite settings.

Note 7: this process will take a very long time to build the final images. But depending on your host machine capabilities you can change the number of processor cores used in build operation acting on "BitBake parallel threads" and "Make parallel threads". To can modify these variables from Hob settings window:

Note 8: finally, with Hob you have the opportunity to decide what packages you want to include inside the image you are going to build. To do that before start building the image, you can select "Edit image recipe".

And, then, choose packages to include through the following window:

Now, when the building process will end, you’ll be able to directly try out your new generated images! Clicking on "Run image" Hob will launch for you an instance of QEMU to run the newly created qemux86 image.

But, before, system will ask you to provide super-user privileges password:

Another UNIX command line console window will open to show the loading state and the splashscreen of Yocto Project OS.

You are now ready to log into the root account of your newly created Yocto image. Remember: inserting debug-tweaks parameter in EXTRA_IMAGE_FEATURES variable onto the conf/local.conf you’ll be able to login as root leaving the password field empty. Otherwise, you’ll need to set up root password in the recipe before building the image.

You are now ready to star playing with the Yocto QEMU virtual machine.

Note 9: after built the Yocto image as presented in this tutorial, 89.8GBs of free space were occupied on the drive.

You will can find the generated images in the .iso, .vmdk, .vdi and the other formats you choose inside the directory ~/yocto-2.0/poky-jethro-14.0.0/build/tmp/deploy/images/qemux86/*. Now, you are free to load the images inside your preferred hypervisor or emulator (Microsoft* Hyper-V, vmWare Fusion, Virtualbox, etc…).


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Intel Corporation
United States United States
You may know us for our processors. But we do so much more. Intel invents at the boundaries of technology to make amazing experiences possible for business and society, and for every person on Earth.

Harnessing the capability of the cloud, the ubiquity of the Internet of Things, the latest advances in memory and programmable solutions, and the promise of always-on 5G connectivity, Intel is disrupting industries and solving global challenges. Leading on policy, diversity, inclusion, education and sustainability, we create value for our stockholders, customers and society.
Group type: Organisation

43 members

You may also be interested in...


Comments and Discussions

-- There are no messages in this forum --
Permalink | Advertise | Privacy | Cookies | Terms of Use | Mobile
Web04 | 2.8.190518.1 | Last Updated 18 Feb 2016
Article Copyright 2016 by Intel Corporation
Everything else Copyright © CodeProject, 1999-2019
Layout: fixed | fluid