site  news  contact

How to run a Linux distribution in a container

January 17, 2021 — BarryK

This tutorial is written in the first-person by Barry Kauler (BarryK on the forums). Switching to first-person mode now...

EasyOS is able to run an application in a container, but can also run a complete Linux distribution. This web page introduces containers from a user-perspective:

https://easyos.org/user/using-easy-containers.html

...which shows an example of a complete distribution desktop running in a container. There is also developer-perspective information on compiling source code inside a container.

The page that you are reading now is very much developer-perspective, looking at how a different Linux distribution can be converted to run in a container in EasyOS.

So far, I have only done this with various Puppy Linux derivatives, as the 'dir2sfs' conversion script is aware of certain Puppy features. However, in theory, any Linux distribution can be converted.

The case study for this page is for 64-bit EasyOS running on the Raspberry Pi4, and to convert RasPup to run in a container. At the time of writing, EasyOS is not yet released for the Pi4, but is expected to be soon -- monitor my blog.

RasPup

This is an "official" Puppy Linux release, that runs on all Pi boards, from the Pi0 to the Pi4. It was created by Michael Amadio (01micko on the forums), and is built in woof-CE with Raspbian Buster DEB packages. The architecture is "armhf", 32-bit. Here is the project home:

http://raspup.eezy.xyz/index.php

Forum discussion:

https://forum.puppylinux.com/viewforum.php?f=141

Version 8.2.1 is here:

http://distro.ibiblio.org/puppylinux/arm/puppy-raspup-8.2.1/

Note that Michael also has a blog:

http://01micko.com/Blog

After downloading 'raspup-8.2.1-a60dc46d9-2gb-f2fs.img.zip' and 'raspup-8.2.1-a60dc46d9-2gb-f2fs.img.zip.md5.txt', I was ready to do the conversion...

Extracting the rootfs out of the image

'dir2sfs' is a script that does the conversion. It is very easy to use, however, there are some choices that might not be obvious, hence this tutorial is useful. What 'dir2sfs' needs is a folder with the "rootfs" in it...

Firstly, I extracted 'puppy_raspup_8.2.1.sfs' out of the downloaded file. You could expand the downloaded file, then mount the first partition, or write the file to a USB-stick. Whatever, you need to extract that SFS file. I did the latter.

If you are running Puppy or EasyOS, you can just click on an SFS to mount it and see the contents. Other Linux distros, you will have to use something like "mount -t squashfs <sfs file> <mount point>". Itemising the steps:

  1. So, I clicked on 'puppy_raspup_8.2.1.sfs' to mount it, then created a folder elsewhere, named 'raspup_8.2.1_armhf'.
  2. I opened a terminal and copied all the files from the SFS into 'raspup_8.2.1_armhf':
    # cp -a * /mnt/sda1/downloads/downloads2/input568/0-raspup/raspup_8.2.1_armhf/
    # sync
  3. I closed the terminal window, and clicked on the SFS again to unmount it.

I now have a folder with all of RasPup inside it. There is however, one little glitch:

'dir2sfs' tries to find the logo image for raspup, however, in this case needs some help. The script will find 'raspup48.png' in user/share/pixmaps, which is not a suitable logo.
raspup_8.2.1_armhf/usr/share/pixmaps must contain 48x48 'raspup.png' as this will be used as the desktop icon -- i got this from the RasPup homepage online. I also replaced 'raspup48.png' with this correct logo, as 'dir2sfs' will also consider this a the logo candidate.

dir2sfs

Now to actually use 'dir2sfs'. As input it requires a folder of the format 'name_version[-revision]_arch'. I launched the script:

# dir2sfs raspup_8.2.1_armhf

A series of GUI windows pop up, this is the first:

img1

...I chose "desk", because we want to run RasPup as a complete desktop.

in the next window, "SFS package database-entry creator" window, fill in as appropriate. Note, "Dependencies" must be empty, and "Repository path" set to "puppy/debian/buster":

img2

That Repository Folder path is of the form "distro/compatible-distro/compatible-release". In this case, it is a Puppy, built with Debian DEBs, version buster.

The next window has security choices. This window is likely to undergo changes in the future, but for now, this is what it looks like:

img3

...I clicked the "Expert" tab, then chose "Xephyr" X server. left all the others as-is. Note that Xephyr is required, as RasPup is going to run as a desktop filling the screen, not in a window.

That's it, 'raspup_8.2.1_armhf.sfs', 'raspup_8.2.1_armhf.specs' and 'raspup.png' have been created.


I then uploaded to the EasyOS SFS repository:

http://distro.ibiblio.org/easyos/aarch64/packages/sfs/puppy/debian/buster/

That's it from the developer-perspective. Now look from the user viewpoint...

sfsget

The link at the top of this page explains how to use "sfsget". Just summarizing here:

"sfsget" is an icon on the desktop. Click on it and you can download and install an SFS file, either to run in the main desktop, or in a container.

So, I went through the exercise, clicked on "sfsget":

img4

The SFS file downloaded, then got the next window:

img5

...clicked "NEW", that's it, an icon appeared on the desktop, joining the other containers:

img6

I clicked on "raspup" and the screen flipped over to the RasPup desktop. There is a message on the screen that "ALT-F6" will flip back to the main desktop. Yes, can flip between the two, it is great, never tire of doing this! 

Tags: dev