Skip to content

Commit

Permalink
Update documents. (#5)
Browse files Browse the repository at this point in the history
* Update 02.system and 03.chroot.
* Update table of contents on README.md.
  • Loading branch information
junaruga committed Jul 27, 2019
1 parent 5fbac57 commit 50f33c2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 31 deletions.
38 changes: 15 additions & 23 deletions 02.system/README.md
@@ -1,14 +1,11 @@
# 02.system - How do qemu-user-static and binfmt_misc work on Fedora system?
# 02.system - qemu-user-static and binfmt_misc on Fedora

* qemu-user-static
* systemd-binfmt service
* binfmt_misc
* `bin/hello-$cpu`: Architecture spefic binary files.
## 1 Introduction

## 1. Requirements
Let's see how qemu-user-static and binfmt_misc work on Fedora OS system through experiments.

My environment is like this. This instructions are specified for Fedora.
Even when your architectur is not x86_64, you can refer the instructions.
Our environment used for this document is like this. This instructions are specified for Fedora.
Even when your architecture is not x86_64, you can refer this document.

```
$ uname -m
Expand All @@ -18,21 +15,16 @@ $ cat /etc/fedora-release
Fedora release 30 (Thirty)
```

## 2. Instructions

Initial condition.
Below archictecture specific binary file `01.basic/bin/hello-aarch64` does not work.
## 2 Files and programs

```
$ ls /proc/sys/fs/binfmt_misc
register status
Below files and programs are used.

$ file 01.basic/bin/hello-aarch64
01.basic/bin/hello-aarch64: ELF 64-bit LSB executable, ARM aarch64, version 1 (GNU/Linux), statically linked, BuildID[sha1]=fa19c63e3c60463e686564eeeb0937959bd6f559, for GNU/Linux 3.7.0, not stripped, too many notes (256)
* qemu-user-static RPM
* systemd-binfmt service (systemd)
* binfmt_misc
* `01.basic/bin/hello-$cpu`: Architecture spefic binary files.

$ 01.basic/bin/hello-aarch64
bash: 01.basic/bin/hello-aarch64: cannot execute binary file: Exec format error
```
## 3 Experiment

Install qemu-user-static RPM.

Expand Down Expand Up @@ -72,7 +64,7 @@ status
```

By the way, if you want to remove qemu-user-static completely to the state before `dnf install qemu-user-static`, run below commands.
You need to remove `/proc/sys/fs/binfmt_misc/qemu-$cpu` files by yourself. I reported the issue [1].
You need to remove `/proc/sys/fs/binfmt_misc/qemu-$cpu` files manually by yourself. I reported the issue [1].

```
$ sudo dnf remove qemu-user-static
Expand Down Expand Up @@ -216,14 +208,14 @@ Bit: 64-bit
Sizeof {int, long, long long, void*, size_t, off_t}: {4, 8, 8, 8, 8, 8}
```

## 3. What we learned
## 4 Conclusion

* `qemu-user-static` RPM includes interpreter files: `/usr/bin/qemu-$cpu-static` and binfmt configuration files: `/usr/lib/binfmt.d/qemu-$cpu-static.conf`.
* `dnf install qemu-user-static` RPM installs binfmt_misc files: `/proc/sys/fs/binfmt_misc/qemu-$cpu` from binfmt configuration files: `/usr/lib/binfmt.d/qemu-$cpu-static.conf` through `systemctl start systemd-binfmt`.
* When you want to remove the installed binfmt_misc files: `/proc/sys/fs/binfmt_misc/qemu-$cpu`, you need to remove the files manually by root user.
* binfmt_misc files: `/proc/sys/fs/binfmt_misc/qemu-$cpu` are installed as `flags: F` (See "01.basic" for the meaning of `flags: F`).

## 4. References
## 5 References

* [1] qemu-user-static: qemu-user-static works even after "dnf remove qemu-user-static"
https://bugzilla.redhat.com/show_bug.cgi?id=1732178
Expand Down
13 changes: 7 additions & 6 deletions 03.chroot/README.md
@@ -1,9 +1,12 @@
# 03.chroot - qemu-user-static, binfmt_misc and chroot
# 03.chroot - qemu-user-static, binfmt_misc and chroot on Fedora

## 1 Introduction

`qemu-user-static` works on chroot environment.

Let's see how it works. `mock` command is good example to see it. `mock` command uses chroot to enable the mock environment internally. The specified architecture's binary files are installed to the chroot environment when using `mock --forcearch $arch (cpu)` option. [1]

## 2 Experiment

```
$ uname -m
Expand All @@ -24,11 +27,9 @@ magic 7f454c460201010000000000000000000200b700
mask ffffffffffffff00fffffffffffffffffeffffff
```

You can use mock configuratoin files `/etc/mock/fedora-rawhide-$cpu.cfg` installed on your environment without any change.
You can use the detault mock configuratoin files `/etc/mock/fedora-rawhide-$cpu.cfg` without any change.

```
$ mock -r fedora-rawhide-aarch64 --forcearch=aarch64 --scrub=all
$ mock -r fedora-rawhide-aarch64 --forcearch=aarch64 shell
```

Expand Down Expand Up @@ -140,7 +141,7 @@ magic 7f454c460201010000000000000000000200b700
mask ffffffffffffff00fffffffffffffffffeffffff
```

## [NEED HELP] Host OS /proc/sys/fs/binfmt_misc files are commonly used for host OS and chroot environment?
### Host OS /proc/sys/fs/binfmt_misc files used on chroot environment?

There is no file under `/var/lib/mock/fedora-rawhide-aarch64/root/proc`.

Expand All @@ -157,6 +158,6 @@ There is no file under `/proc/sys/fs/binfmt_misc/`.
I assume that `/proc` is commonly used by host OS and chroot environment.
But I am not sure. Please tell me if you know something about it. :)

## References
## 3 References

* [1] mock forcearch feature: https://github.com/rpm-software-management/mock/wiki/Feature-forcearch
8 changes: 6 additions & 2 deletions README.md
@@ -1,7 +1,11 @@
# Fedora Workshop for multiarch

For [Talk-25]: Let's add Fedora multiarch containers to your CI at Flock 2019
* Fock 2019 talk: [Talk-25]: Let's add Fedora multiarch containers to your CI

Table of contents

* 01.basic: qemu-user-static and binfmt_misc
* 1 [qemu-user-static and binfmt_misc](01.basic/README.md)
* 1.1 qemu-user-static
* 1.2 qemu-user-static and binfmt_misc
* 2 [qemu-user-static and binfmt_misc on Fedora](02.system/README.md)
* 3 [qemu-user-static, binfmt_misc and chroot on Fedora](03.chroot/README.md)

0 comments on commit 50f33c2

Please sign in to comment.