Creating a Mageia armv7hl docker image for Raspberry 3

Santa Claus has brought a shiny new Raspberry 3B+ to my son for Christmas ! While it came with raspian by default, I didn’t want to change it to Mageia directly even if it’s now available. We wanted to use it as a prod environment for his docker based setup on his laptop. Which is using Mageia 6 and also Mageia containers. So that’s where the fun begins because there is no mageia docker image for armv7hl available and usable on Raspberry. Well, now at least I have one, locally and can document here the way to do it, if you want to reproduce, or you can use mine as well, thanks to the docker hub !

So here are the steps of what I did to obtain mine:

  1. Download the arm reference image for raspberry and uncompress it
  2. Mount it as a loopback mount to access its content
  3. Use the content and QEMU magic to run armv7hl binaries on your x86_64 machine and prepare your environment
  4. Build a chroot on this point containing the minimal set of packages for a Mageia distribution
  5. Create the Docker image out of that file and enjoy using it !

Which means wrt commands:
$ #1

$ cd $HOME/tmp

$ wget http://librepc.homelinux.org/dl/raspi/181217_mga7arm_rpi.img.xz

$ xz -d 181217_mga7arm_rpi.img.xz

$ #2

$ sudo kpartx -a 181217_mga7arm_rpi.img

$ sudo mkdir -p /mnt

$ sudo mount /dev/mapper/loop1p2 /mnt

$ #3

$ sudo urpmi qemu-user-static qemu-system-arm

$ sudo systemctl start systemd-binfmt

$ sudo chroot /mnt

# arch     # isn't it magic !!

# urpmi.update -a

$ #4

# cd /home/pi

# export TARGETDIR=../tmp

# mkdir -p $TARGETDIR

# export MGAARCH=armv7hl

# export MGAVER=6

# /usr/sbin/urpmi.addmedia --distrib --urpmi-root "$TARGETDIR" ftp://ftp.free.fr/mirrors/mageia.org/distrib/$MGAVER/$MGAARCH

# LANG=C LANGUAGE=C /usr/sbin/urpmi --auto --no-recommends --download-all --allow-force --force --force-key --urpmi-root "$TARGETDIR" basesystem urpmi

# export TMPDM=/tmp

# echo 'NETWORKING=yes' > $TMPDM/network

# install -m 0644 $TMPDM/network "$TARGETDIR"/etc/sysconfig/network

# rm -f $TMPDM/network

# rm -rf "$TARGETDIR/dev" "$TARGETDIR/proc"

# install -m 0755 -d "$TARGETDIR/dev" "$TARGETDIR/proc"

# cat > $TMPDM/resolv.conf << EOF
nameserver 8.8.8.8
nameserver 8.8.4.4
EOF

# install -m 0644 $TMPDM/resolv.conf "$TARGETDIR/etc/resolv.conf"

# rm -f $TMPDM/resolv.conf

# export DATE=2019-01-05

# cat > Dockerfile << EOF
FROM scratch
MAINTAINER bcornec@mageia.org
WORKDIR /
ADD mageia-$MGAVER-$MGAARCH-$DATE.tar.xz /
LABEL name="Mageia $MGAVER Base Image Arch: $MGAARCH" \
vendor="Mageia" \
license="GPLv2" \
build-date="$DATE"
CMD /bin/bash
EOF

# tar -C $TARGETDIR -cJf mageia-$MGAVER-$MGAARCH-$DATE.tar.xz .

# chmod 644 Dockerfile mageia-$MGAVER-$MGAARCH-$DATE.tar.xz

$ #5

$ ssh pi@raspberry mkdir docker

$ scp /mnt/home/pi/Dockerfile /mnt/home/pi/mageia-6-armv7hl-*.tar.xz pi@raspberry:docker

$ ssh pi@raspberry

pi$ sudo urpmi docker

pi$ cd docker

pi$ docker build -t mageiaofficial:6-armv7hl .

pi$ docker images
REPOSITORY    TAG            IMAGE ID             CREATED        SIZE
mageiaofficial    6-armv7hl 9b5880971b45    9 seconds ago 386 MB

pi$ docker run -ti mageiaofficial:6-armv7hl /bin/bash
[root@33a7bb3763b5 /]# urpmi tcsh

ftp://ftp.free.fr/mirrors/mageia.org/distrib/6/armv7hl/media/core/release/tcsh-6.19.00-5.mga6.armv7hl.rpm
installing tcsh-6.19.00-5.mga6.armv7hl.rpm from /var/cache/urpmi/rpms
Preparing... #############################################
1/1: tcsh #############################################
[root@33a7bb3763b5 /]# exit

Voilà !!

 

So now on your raspberry, it’s for you as simple as:

docker pull bcornec/mageia:6-armv7hl

Will soon provide a cauldron one as well 🙂

Advertisements

Tags: , , , ,

4 Responses to “Creating a Mageia armv7hl docker image for Raspberry 3”

  1. Rolf Pedersen Says:

    Good job! Is there something similar for the Cubox-i? Thanks.

  2. brunocornec Says:

    I’m pretty new to all these SOCs stuff, so learning as I walk 😉
    So seems your Cubox-i is equiped with i.MX6 SOCs using Cortex A9 ARM cores, being ARMv7-A (from https://en.wikipedia.org/wiki/ARM_architecture)

    What Mageia supports from the wiki is here: https://wiki.mageia.org/en/Feature:ARM_Port so Raspberry Pi v1 & v2, IMX53QSB: i.MX53 Quick Start Board
    Except that I know that Raspberry v3 are also supported, so the page is no completely up to date.

    From Thomas presentation at https://bootlin.com/pub/conferences/2017/lca/petazzoni-arm-introduction/petazzoni-arm-introduction.pdf seems that “supported” is a complex thing to decide as you need CPU (which I think I have being armv7) but also SOC (which I’m unsure).

    But for me if your platform already has a distro running on it, then you’re covered. and running a mageia container on it based on the image I made should work as we have the same CPU arch as Rasppberry. At least, that’s my understanding. feel free to testand give feedback here !

  3. Rolf Pedersen Says:

    Thanks for all that info. I’ll delve into it by-and-by 😉
    I’m running libreelec on the Cubox-i I4P-300-D model (on the label): https://www.solid-run.com/nxp-family/cubox-i/

    The container concept is totally new for me, don’t know if it can install on libreelec. It looks like multiple distro images are available: https://developer.solid-run.com/article-categories/i-mx6-software/

    The kodi-related images have been hit and miss with an older version of libreelec gaining the best results as a low-power HTPC playing videos from various NAS. My experience makes me a little leery about overtaxing the hardware.

    I took a picture of the System Info Hardware tab but looks like I can’t post it here. FWIW, here’s a bit of ssh terminal output:

    LibreELEC:~ # cat /proc/cpuinfo
    processor : 0
    model name : ARMv7 Processor rev 10 (v7l)
    BogoMIPS : 3.12
    Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant : 0x2
    CPU part : 0xc09
    CPU revision : 10

    processor : 1
    model name : ARMv7 Processor rev 10 (v7l)
    BogoMIPS : 3.12
    Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant : 0x2
    CPU part : 0xc09
    CPU revision : 10

    processor : 2
    model name : ARMv7 Processor rev 10 (v7l)
    BogoMIPS : 3.12
    Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant : 0x2
    CPU part : 0xc09
    CPU revision : 10

    processor : 3
    model name : ARMv7 Processor rev 10 (v7l)
    BogoMIPS : 3.12
    Features : swp half thumb fastmult vfp edsp neon vfpv3 tls vfpd32
    CPU implementer : 0x41
    CPU architecture: 7
    CPU variant : 0x2
    CPU part : 0xc09
    CPU revision : 10

    Hardware : Freescale i.MX6 Quad/DualLite (Device Tree)
    Revision : 0000
    Serial : 0000000000000000

    LibreELEC:~ # cat /proc/meminfo
    MemTotal: 2070024 kB
    MemFree: 1623212 kB
    MemAvailable: 1739664 kB
    Buffers: 38604 kB
    Cached: 135724 kB
    SwapCached: 0 kB
    Active: 114440 kB
    Inactive: 118464 kB
    Active(anon): 62304 kB
    Inactive(anon): 2344 kB
    Active(file): 52136 kB
    Inactive(file): 116120 kB
    Unevictable: 0 kB
    Mlocked: 0 kB
    HighTotal: 1318912 kB
    HighFree: 1172788 kB
    LowTotal: 751112 kB
    LowFree: 450424 kB
    SwapTotal: 0 kB
    SwapFree: 0 kB
    Dirty: 0 kB
    Writeback: 0 kB
    AnonPages: 58620 kB
    Mapped: 29528 kB
    Shmem: 6072 kB
    Slab: 19096 kB
    SReclaimable: 9124 kB
    SUnreclaim: 9972 kB
    KernelStack: 1184 kB
    PageTables: 1160 kB
    NFS_Unstable: 0 kB
    Bounce: 0 kB
    WritebackTmp: 0 kB
    CommitLimit: 1035012 kB
    Committed_AS: 619216 kB
    VmallocTotal: 245760 kB
    VmallocUsed: 10396 kB
    VmallocChunk: 167796 kB
    LibreELEC:~ #

  4. brunocornec Says:

    Seems from thelink you gave there are a lot of distributions available for your box, so I’d recommend you use Fedora which has a fairly up to date docker engine to benefit aftwards from docker images, such as the one I provided. Now if you already use another distro and want to stick to it, then install docker on it following instructions from their web site.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s


%d bloggers like this: