Skip to content

How to build a JuNest image using QEMU

Filippo Squillace edited this page Jul 19, 2015 · 2 revisions

First steps

This tutorial show how to create a JuNest image for x86 inside QEMU. Of course, for images of different architecture (i.e. x86_64, arm, etc) the procedure would be the same.

You first need to create an empty image:

qemu-img create archlinux-i686.img 8G

Install ArchLinux

  • You need first to download the ArchLinux image.
  • Run QEMU for i386 architecture:
qemu-system-i386 -hda archlinux-i686.img -boot d -cdrom ../archlinux-2014
.12.01-dual.iso -m 1024
  • Follow the procedure from the ArchLinux website
    • It is suggested to create just one partition /dev/sda1 on DOS partition table:
cfdisk /dev/sda
mkfs.ext4 /dev/sda1

Install JuNest and needed dependencies for the building

  • Configure the ArchLinux in order to install internet with netctl
  • JuNest image needs some packages to be already available inside ArchLinux:
pacman -S git base-devel arch-install-scripts 
  • (Optional) Install haveged in order to generate entropy. This is useful when you need to create the keyring for pacman:
pacman -Syu haveged
systemctl start haveged
systemctl enable haveged
  • Install package-query from AUR
#as user
mkdir package-query && cd package-query
wget https://aur.archlinux.org/packages/pa/package-query/PKGBUILD
makepkg -fsc
#as root
pacman -U package-query.*.xz

Build JuNest image

Before building the image it is better to update the OS first:

pacman -Syu

Use JUNEST_TEMPDIR if you want to place the building directory on a partition with more space (default is /tmp)

JUNEST_TEMPDIR=/tmp/ junest -b

Retrieve the JuNest image

  • fdisk gives the start and end offsets in 512-byte sectors, so multiply by 512 to get the correct offset to pass to mount:
fdisk -l archlinux-i686.img
  • Mount the QEMU image to extract the JuNest tar.gz file:
mkdir /mnt/archlinux-i686
mount -o loop,offset=OFFSET archlinux-i686.img /mnt/archlinux-i686