Home

Awesome

Browser VM

A custom Buildroot config for a Linux x86 VM, meant to be run in the browser as part of browser-shell. The resulting Linux ISO is meant to be run under emulation in the browser via v86, and includes:

Following the Buildroot customization docs we create a folder buildroot-v86/ with all the necessary config files, filesystem overlay, and scripts necessary to build our distribution.

Running via Docker

To build the Docker image use the build.sh script, or:

$ docker build -t buildroot .

And then to run the build:

$ docker run \
    --rm \
    --name build-v86 \
    -v $PWD/dist:/build \
    -v $PWD/buildroot-v86/:/buildroot-v86 \
    buildroot

NOTE: we define two volumes to allow the container to access the v86 config, and also to write the ISO once complete. In the above I've used $PWD, but you can use any absolute path.

When the build completes, an ISO file will be places in ./dist/v86-linux.iso in your source tree (i.e., outside the container).

If you need to re-configure things, instead of just running the build, do the following:

$ docker run \
    --rm \
    --name build-v86 \
    -v $PWD/dist:/build \
    -v $PWD/buildroot-v86/:/buildroot-v86 \
    -ti \
    --entrypoint "bash" \
    buildroot

Now in the resulting bash terminal, you can run make menuconfig and other make commands.

buildroot-v86/ Layout

We define a v86 buildroot "board" via the following files and directories:

+-- board/
    +-- v86
        +-- linux.config        # our custom Linux kernel config (make linux-menuconfig)
        +-- post_build.sh       # script to copy ISO file out of docker container
        +-- rootfs_overlay/     # overrides for files in the root filesystem
            +-- etc/
                +-- inittab     # we setup a ttyS0 console terminal to auto-login
                +-- fstab       # we auto-mount the Plan 9 Filer filesystem to /mnt
    +-- configs/
        +-- v86_defconfig       # our custom buildroot config (make menuconfig)
    +-- Config.in               # empty, but required https://buildroot.org/downloads/manual/manual.html#outside-br-custom
    +-- external.mk             # empty, but required https://buildroot.org/downloads/manual/manual.html#outside-br-custom
    +-- external.desc           # our v86 board config for make
    +-- build-v86.sh            # entrypoint for Docker to run our build

If you need or want to update these config files, do the following:

$ make BR2_EXTERNAL=/buildroot-v86 v86_defconfig
$ make menuconfig
...
$ make savedefconfig
$ make linux-menuconfig
...
$ make linux-savedefconfig

Configuration Notes

These are the options I set when configuring buildroot for v86. I'm only specifying the things I set.

$ cd buildroot-2018.02
$ make menuconfig

Then follow these config steps in the buildroot config menu (NOTE: these docs may have drifted from the actual config in the source, so consult that first):

Target options

Build options

Toolchain

System configuration

Kernel

Target packages

Need to figure this out. I tried adding imagemagik, git, uemacs, but they are all adding too much size to the image.

Filesystem images

Bootloaders

Linux configuration

Now configure the Linux Kernel:

$ make linux-menuconfig

And set the following options to accomplish this:

CONFIG_NET_9P=y
CONFIG_NET_9P_VIRTIO=y
CONFIG_9P_FS=y
CONFIG_9P_FS_POSIX_ACL=y
CONFIG_PCI=y
CONFIG_VIRTIO_PCI=y
CONFIG_PCI=y
CONFIG_VIRTIO_PCI=y

Processor type and features

Bus options (PCI, etc.)

Networking support

Device Drivers

Filesystems

Now run make

When it finishes, the built image is in ./output/images.