-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs: Add some tips on getting a rootfs
#104 (review) prompted me to try an experimentm it turns out conatiner runtimes provide a super lightweight way to produce a rootfs. Also provide a minimal example for mkosi. This won't work without a user namespace so I guess we shouldn't merge this until after #104 or something simliar is in place.
- Loading branch information
Showing
3 changed files
with
55 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
# Getting a rootfs | ||
|
||
There are many ways to produce a directory to pass to the `rootfs` config field, | ||
here are a couple of potential solutions. | ||
|
||
## From a container image | ||
|
||
OCI images can be turned into tarballs which can be extracted into a rootfs. For | ||
example: | ||
|
||
```sh | ||
❯❯ mkdir $rootfs_dir && cd $rootfs_dir | ||
❯❯ cat > Containerfile | ||
FROM docker.io/library/debian | ||
RUN apt update | ||
RUN apt install -y qemu-guest-agent | ||
|
||
❯❯ podman build -t deb-qga # Docker would work exactly the same | ||
❯❯ podman export -o deb.tar $(podman create deb-qga) | ||
❯❯ tar xf deb.tar | ||
❯❯ rm Containerfile deb.tar | ||
``` | ||
|
||
## Using mkosi | ||
|
||
[`mkosi`](https://github.com/systemd/mkosi) is a more advanced tool for building | ||
OS images, as well as just producing a rootfs it can build full disk images with | ||
a bootloader, plus many other features. You'll need to refer to the full | ||
documentation to really understand `mkosi`, but here's a minimal example. This | ||
will only work if you host system has `apt`, otherwise you'll need to adapt it | ||
for your host distro or run it in a container. | ||
|
||
`mkosi.conf`: | ||
|
||
```ini | ||
[Output] | ||
Format=directory | ||
|
||
[Distribution] | ||
Distribution=debian | ||
Release=testing | ||
|
||
[Content] | ||
Packages= | ||
mount | ||
qemu-guest-agent | ||
``` | ||
|
||
Then from the directory containing that file, run `mkosi -f`. This should | ||
produce a directory named `image` that you can use for your `rootfs` config | ||
field. |