SBD:/Running openSUSE containers on ChromeOS

Jump to: navigation, search

Situation

Many computers running ChromeOS or ChromeOS Flex can run openSUSE in a container. The ChromeOS container service is the lxc container environment running out of the Linux development environment.

Required Processor Capabilities

ChromeOS typically runs on both a x86_64 or aarch64 architecture. A Chromebook will typically have a processor from Intel or AMD for a x86_64 system. Some systems have an 64-bit ARM processor that show as a aarch64 processor architecture.

For example, the manufacturer and model of ARM processor in a Lenovo Chromebook Duet 5 13 system reports as a Qualcomm® SnapdragonTM aarch64 architecture.


Prerequisites

The following components are required to run an openSUSE container.

Linux development environment

  1. Install the Linux development environment. If this is disabled in the ChromeOS settings then the installed processor does not support virtualization requirements.
  2. Open the ChromeOS developer shell (crosh) by pressing ctl+alt+t.

Disk space

There should be enough disk space in the Linux development environment to download container images.

Architecture

The following diagram shows the architecture from the base hardware up to a running openSUSE container.

ChomeOS-Diagrams.png

Everything above ChromeOS is installed with the Linux development environment.

crosvm Virtual Machine Management

The crosvm virtual machine management interface is a kernel-based hypervisor based on KVM. It is the builtin Virtual Machine Monitor for Chrome OS, and is similar to other solutions such as VirtualBox or QEMU.

The vmc command is used to manage the ChromeOS hypervisor. For example, a listing of the virtual machines is displayed by running:

crosh> vmc list

The output should be similar to:

termina (56693657600 bytes, raw)
arcvm (7423516672 bytes, raw, sparse)
Total Size (bytes): 64117174272

The termina Virtual Machine

The termina virtual machine is installed with the Linux development environment.

terminia can be started from crosh by running:

 crosh> vmc start termina


The vmc command starts the termina virtual machine and launches a shell as:

 (termina) chronos@localhost ~ $ 


When started it runs a version of the Chromium OS. When running is reports the following OS information in the /etc/os-release file:

cat /etc/os-release 

NAME=Chromium OS
ID=chromiumos
HOME_URL=https://www.chromium.org/chromium-os
BUG_REPORT_URL=https://crbug.com/new
VERSION=114
VERSION_ID=114
BUILD_ID=15437.60.0

LXD/LXC Linux Container Management

Within the termina virtual machine is a container management service known as Linux containers (LXD/LXC). This is a light-weight container management solution that allows for multiple containers to run.

A listing of containers is performed by running:

 lxc list

The listing should show output similar to:

 +------------+---------+------+------+-----------+-----------+
 |    NAME    |  STATE  | IPV4 | IPV6 |   TYPE    | SNAPSHOTS |
 +------------+---------+------+------+-----------+-----------+
 | penguin    | STOPPED |      |      | CONTAINER | 0         |
 +------------+---------+------+------+-----------+-----------+


The penguin Container

When a terminal is opened in Chrome OS it starts the termina virtual machine, and then spins up a penguin container. This container is a Debian system that provides a terminal interface.

To see how this works perform the following:

  1. Start the Application Launcher
  2. Select Terminal
  3. Select penguin

You will see a message

 Starting the Linux container 

A terminal window opens a shell.

Return to the crosh shell and list the containers again:

 lxc list

Opening the terminal Application started the penguin container in the termina virtual machine and now shows a state of RUNNING.

 +------------+---------+-----------------------+------+-----------+-----------+
 |    NAME    |  STATE  |         IPV4          | IPV6 |   TYPE    | SNAPSHOTS |
 +------------+---------+-----------------------+------+-----------+-----------+
 | penguin    | RUNNING | 100.115.92.203 (eth0) |      | CONTAINER | 0         |
 +------------+---------+-----------------------+------+-----------+-----------+


Adding openSUSE Containers

openSUSE containers are not present by default, but can be spun up if desired.

List available images

Run the following command to list available suse containers:

 lxc image list images: |grep suse 

The output should be similar to:

 | opensuse/15.4 (3 more)                 | 2f6c6ea0e239 | yes    | Opensuse 15.4 arm64 (20240409_04:20)       
 | aarch64      | VIRTUAL-MACHINE | 212.07MB  | Apr 9, 2024 at 12:00am (UTC)  |
 | opensuse/15.4 (3 more)                 | 8614adf43a34 | yes    | Opensuse 15.4 arm64 (20240409_04:20)       
 | aarch64      | CONTAINER       | 44.25MB   | Apr 9, 2024 at 12:00am (UTC)  |
 | opensuse/15.4/amd64 (1 more)           | 635b1e13d6a7 | yes    | Opensuse 15.4 amd64 (20240409_04:20)       
 | x86_64       | VIRTUAL-MACHINE | 213.02MB  | Apr 9, 2024 at 12:00am (UTC)  |
 . . .

Launch an openSUSE container

An openSUSE container can be downloaded and launched by running lxc launch <image> <container-name>:

 lxc launch images:opensuse/15.5/arm64 opensuse15-5

This example downloads an openSUSE Leap 15.5 image built for Arm64 and named locally on my ChromeOS as opensuse15-5.

Return to the crosh shell and list the containers again:

 lxc list

The output now shows the opensuse15-5 container in a state of RUNNING:

 +--------------+---------+-----------------------+------+-----------+-----------+
 |     NAME     |  STATE  |         IPV4          | IPV6 |   TYPE    | SNAPSHOTS |
 +--------------+---------+-----------------------+------+-----------+-----------+
 | opensuse15-5 | RUNNING | 100.115.92.199 (eth0) |      | CONTAINER | 0         |
 +--------------+---------+-----------------------+------+-----------+-----------+
 | penguin      | RUNNING | 100.115.92.203 (eth0) |      | CONTAINER | 0         |
 +--------------+---------+-----------------------+------+-----------+-----------+

Enter the openSUSE container

A bash shell can be invoked in the container by running:

 lxc exec opensuse15-5  -- bash

All commands are now in the container:

 opensuse15-5:~ # cat /etc/os-release 
 NAME="openSUSE Leap"
 VERSION="15.5"
 ID="opensuse-leap"
 ID_LIKE="suse opensuse"
 VERSION_ID="15.5"
 PRETTY_NAME="openSUSE Leap 15.5"
 ANSI_COLOR="0;32"
 CPE_NAME="cpe:/o:opensuse:leap:15.5"
 BUG_REPORT_URL="https://bugs.opensuse.org"
 HOME_URL="https://www.opensuse.org/"
 DOCUMENTATION_URL="https://en.opensuse.org/Portal:Leap"
 LOGO="distributor-logo-Leap"

Type exit to leave the shell and exit the container.

Suspend the openSUSE container

Run the following command to stop the container:

lxc stop opensuse15-5

Return to the crosh shell and list the containers again to verify that the container stopped:

 lxc list

The output now shows the opensuse15-5 container is not STOPPED:

 +--------------+---------+-----------------------+------+-----------+-----------+
 |     NAME     |  STATE  |         IPV4          | IPV6 |   TYPE    | SNAPSHOTS |
 +--------------+---------+-----------------------+------+-----------+-----------+
 | opensuse15-5 | STOPPED |                       |      | CONTAINER | 0         |
 +--------------+---------+-----------------------+------+-----------+-----------+
 | penguin      | RUNNING | 100.115.92.203 (eth0) |      | CONTAINER | 0         |
 +--------------+---------+-----------------------+------+-----------+-----------+

Note: The container can be started again by running:

 lxc start opensuse15-5