Often one wants to test software but one doesn't have hardware at hand to run the test software on. It is possible however to emulate hardware and that is what GENIVI does when it releases its qemu based baselines. In this article I wanted to show another way to test the software via emulation, but with a lightweight method of using a container. This has the advantage of both creating an operating environment that is a lot like GENIVI's, but is not a full blown operating system. This is handy if you already have an available GNU/Linux OS like Debian that you're using since it can run side-by-side without messing up your system.
I used to use a chroot to do this type of testing, but systemd has a tool called systemd-nspawn which can do a lot of the heavy lifting for us so I'll be using that for this article since systemd is also used in GENIVI.
Creating the container
I used the systemd-nspawn command to create a Debian based container. I'm using unstable here but you can use other versions of course, unstable should work for our purposes. Here's the exact command I used;
# debootstrap --arch=amd64 unstable ~/debivi/ # systemd-nspawn -D debivi Spawning container debivi on /home/jeremiah/debivi. Press ^] three times within 1s to kill container. /etc/localtime is not a symlink, not updating container timezone. root@debivi:~# passwd Enter new UNIX password: Retype new UNIX password: passwd: password updated successfully root@debivi:~#
Note I'm calling this directory "debivi" but you can use whatever clever name you like. It takes a little while to download and set up all the software, but not too long because this is a minimal install. Next, let's populate the container and boot it;
Boot into container
$ sudo systemd-nspawn -M debivi -D ./debivi -b
This will boot the container. The -M flag names the container, the -b flag is for boot and the -D specifies which directory the container should contain.
Copied from MediaWiki
Last Edit: 14:56, 5 December 2014 Jeremiah