# QEMU, the FAST! processor emulator (Ubuntu)

**URL:** <https://hub.mender.io/t/qemu-the-fast-processor-emulator-ubuntu/1550>\
**Category:** Debian family\
**Created:** [February 17, 2020, 1:23pm UTC](https://hub.mender.io/t/qemu-the-fast-processor-emulator-ubuntu/1550 "2020-02-17T13:23:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [February 17, 2020, 1:23pm UTC](https://hub.mender.io/t/qemu-the-fast-processor-emulator-ubuntu/1550/1 "2020-02-17T13:23:14Z")

</div>

# Board description

**QEMU** (short for **Quick Emulator** ) is a free and open-source emulator that performs hardware virtualization.

QEMU is a hosted virtual machine monitor, it emulates the machine’s processor through dynamic and provides a set of different hardware and device models for the machine, enabling it to run a variety of guest operating systems. It also can be used with [KVM](https://en.wikipedia.org/wiki/Kernel-based_Virtual_Machine) to run virtual machines at near-native speed (by taking advantage of hardware extensions such as [Intel VT-x](https://en.wikipedia.org/wiki/X86_virtualization)).

QEMU machines are something that we at [Mender](https://mender.io/) use heavily during development and this is also the primary target for our integration tests.

 ![svg](https://canada1.discourse-cdn.com/flex036/uploads/mender/original/1X/81316d46fd53857998394469204a2805a1a2e415.png)

URL: [https://qemu.weilnetz.de/doc/qemu-doc.html](https://qemu.weilnetz.de/doc/qemu-doc.html)  
Wiki: [https://wiki.qemu.org/Documentation](https://wiki.qemu.org/Documentation)

# Test results

The Ubuntu releases in the table below have been tested by the Mender community. Please update it if you have tested this integration on other Ubuntu releases.

| Debian | Build | Runtime |
| --- | --- | --- |
| Ubuntu-Bionic-x86-64 | :test_works: | :test_works: |

**Build** Means that the image generation completes without errors and outputs images.  
**Runtime** Means that Mender has been verified to work on the board.

# Getting started

## Convert your own image

### Prerequisites

- A Linux-based laptop/workstation (Ubuntu has been verified to work)
- You need to [install Docker Engine](https://docs.docker.com/install) to use this tutorial

### Build Docker image for `mender-convert`

Open a terminal and clone the [mender-convert repository](https://github.com/mendersoftware/mender-convert), e.g.

```bash
git clone -b 2.0.x https://github.com/mendersoftware/mender-convert.git

```

Enter your `mender-convert` environment:

```bash
cd mender-convert

```

There is a utility script which can be used to generate the appropriate docker image to run `mender-convert`:

```bash
./docker-build

```

This will create a container image you can use to run `mender-convert`.

## Download the pre-generated Ubuntu Bionic image

Download the raw Ubuntu disk image into a subdirectory `input`:

```bash
mkdir -p input
cd input
wget https://d1b0l86ne08fsf.cloudfront.net/mender-convert/images/Ubuntu-Bionic-x86-64.img.gz

```

Extract the raw Ubuntu disk image:

```bash
gunzip Ubuntu-Bionic-x86-64.img.gz && cd ..

```

### Convert the Ubuntu disk image to support Mender

With the raw disk image and the container configured above, we can convert the  
image.

You can get your Mender Professional tenant token at the [My organization page in Mender Professional](https://hosted.mender.io/ui/#/settings/my-organization).

Configure the Mender client for hosted Mender server:

```bash
./scripts/bootstrap-rootfs-overlay-hosted-server.sh \
    --output-dir ${PWD}/rootfs_overlay_demo \
    --tenant-token "Paste token from Mender Professional"

```

There are additional scripts in the `scripts/` directory to configure with a local demo server, or production server.

Run mender-convert inside the container by running:

```bash
MENDER_ARTIFACT_NAME=release-1 ./docker-mender-convert \
    --disk-image input/Ubuntu-Bionic-x86-64.img \
    --config configs/qemux86-64_config \
    --overlay ./rootfs_overlay_demo

```

Conversion will take 10-15 minutes, depending on your storage and resources available.

**NOTE**!

You will need an SD card with an capacity of at least **8GB** when using the default arguments. The SD card layout will be the following using the default arguments:

| Part | Type | Purpose | Size | Configure size |
| --- | --- | --- | --- | --- |
| sda1 | vfat | Store the bootloader | 44MB | `MENDER_BOOT_PART_SIZE_MB` |
| sda2 | ext4 | Store the root file system and kernel (active) | 3908MB | `MENDER_STORAGE_TOTAL_SIZE_MB` [1](#footnote1) |
| sda3 | ext4 | Store the root file system and kernel (inactive) | 3908MB | `MENDER_STORAGE_TOTAL_SIZE_MB` [1](#footnote1) |
| sd4 | ext4 | Store persistent data, preserved during Mender updates. | 128MB | `MENDER_DATA_PART_SIZE_MB` [2](#footnote2) |

1. The rootfs partition size is calculated using the following formula:

```
 (storage-total-size-mb - data-part-size-mb - boot-part-size) / 2

```

2. You rarely need to adjust the data part size using `MENDER_DATA_PART_SIZE_MB` as this will expanded on first boot to occupy the remaining free blocks of the SD card.

You can read more about the partition layout required for Mender [here](https://docs.mender.io/devices/general-system-requirements#partition-layout)

## Use the output images

After a successful conversion, the images and artifacts are:

- deploy/Ubuntu-Bionic-x86-64-qemux86\_64-mender.img.gz
- deploy/Ubuntu-Bionic-x86-64-qemux86\_64-mender.ext4
- deploy/Ubuntu-Bionic-x86-64-qemux86\_64-mender.mender

The disk image (with `.sdimg.gz` suffix) can be used to start a QEMU instance with Mender integrated. On the other hand, if you already have Mender running on your device and want to deploy a rootfs update from this conversion, you should use the [Mender Artifact](https://docs.mender.io/architecture/mender-artifacts?target=_blank) files, which have `.mender` suffix. You can either deploy this Artifact in managed mode with the Mender server (upload it under Releases in the server UI) or by using the Mender client only in [Standalone deployments](https://docs.mender.io/architecture/standalone-deployments?target=_blank).

### Boot generated disk image using qemu-system-x86\_64

First we need to unpack the disk image:

```bash
cd deploy
gunzip Ubuntu-Bionic-x86-64-qemux86_64-mender.img.gz
cd ..

```

Start the QEMU:

```bash
qemu-system-x86_64 -enable-kvm -m 512 -smp 2 -bios /usr/share/ovmf/x64/OVMF_CODE.fd -drive format=raw,file=deploy/Ubuntu-Bionic-x86-64-qemux86_64-mender.img

```

Login is: `root / password`

After about 10 minutes, you should see your device Pending authorization under the Devices tab in your Mender server. Authorize your device to join your Mender server.

You can now deploy software updates to your QEMU device using the Mender server!

# References

- The documentation on [Building a Mender Debian image](https://docs.mender.io/artifacts/debian-family) contains more information about using Mender with the Debian family of distributions.

- The official [Mender documentation](https://docs.mender.io/) explains how Mender works. This is simply a board-specific complement to the official documentation.

# Known issues

…

* * *

_If this post was useful to you, please press like, or leave a thank you note to the contributor who put valuable time into this and made it available to you. It will be much appreciated!_

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [March 31, 2020, 9:32am UTC](https://hub.mender.io/t/qemu-the-fast-processor-emulator-ubuntu/1550/2 "2020-03-31T09:32:38Z")

</div>

10 posts were split to a new topic: [Issue with connecting QEMU (Ubuntu) image to demo server](https://hub.mender.io/t/issue-with-connecting-qemu-ubuntu-image-to-demo-server/1718)

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [April 23, 2020, 7:40am UTC](https://hub.mender.io/t/qemu-the-fast-processor-emulator-ubuntu/1550/3 "2020-04-23T07:40:38Z")

</div>

4 posts were split to a new topic: [Issue with starting QEMU after conversion with mender-convert](https://hub.mender.io/t/issue-with-starting-qemu-after-conversion-with-mender-convert/1819)

---

<div class="post-metadata">

**Author:** ![mirzak](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/mirzak/32/2056_2.png) [@mirzak](https://hub.mender.io/u/mirzak)\
**Post date:** [May 18, 2020, 6:57am UTC](https://hub.mender.io/t/qemu-the-fast-processor-emulator-ubuntu/1550/4 "2020-05-18T06:57:04Z")

</div>

3 posts were split to a new topic: [Running mender-client-qemu](https://hub.mender.io/t/running-mender-client-qemu/1936)

---

<div class="post-metadata">

**Author:** ![TheYoctoJester](https://yyz2.discourse-cdn.com/flex036/user_avatar/hub.mender.io/theyoctojester/32/1444_2.png) [@TheYoctoJester](https://hub.mender.io/u/TheYoctoJester)\
**Post date:** [October 17, 2024, 12:06pm UTC](https://hub.mender.io/t/qemu-the-fast-processor-emulator-ubuntu/1550/5 "2024-10-17T12:06:39Z")

</div>

A post was split to a new topic: [Ubuntu 24.04 on QEMU?](https://hub.mender.io/t/ubuntu-24-04-on-qemu/7238)
