How to build a rootfs (root filesystem) image for running Linux on the x86isa model.
Most modern Linux machines boot by first loading an initramfs as
the file system mounted on
On our machine, we choose to use the initramfs as our root
file system and don't
We assume you're following this using a Linux system with a
"Linux-style" file system. While this should work with other Linux
distributions, we've tested the model with Alpine Linux's rootfs
(version 3.21, the latest as of writing). We chose this distribution
because it is small, making it easy to quickly recreate the cpio
archive as needed when testing and because they provide a download
link on their website for a tarball of their rootfs, rather than
having to bootstrap the rootfs using a tool like Arch Linux's
Alpine Linux version 3.21 for x86_64 can be downloaded here.
From that page, download the file
Once you've downloded the Alpine mini root file system, do the following to extract it:
mkdir alpine cd alpine # Note: the Alpine tarball will extract into your current directory, # so you should create a directory to contain the files, as shown # above tar xvf <downloaded Alpine tarball path>
Now, we need to add an
#!/bin/busybox sh mount -t devtmpfs none /dev mount -t proc proc /proc mount -t sysfs sysfs /sys hostname x86isa-linux export HOME=/root exec sh -l
at
If you wish to install additional software, you can
The last step is to create the cpio archive. We'll use libarchive's
implementation of
bsdtar --format newc --uid 0 --gid 0 -cvf <archive path>.img *
Make sure you aren't saving your archive in the rootfs directory.
Once that is done you should have a cpio archive