blob: ee3867e12e444823748dde7153cf04856b26a530 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
|
# QEMU
## Create image
```bash
qemu-img create -f raw image_file 4G
```
Run iso with image
```bash
qemu-system-i386 -cdrom _iso_image_ -boot order=d _qemu_image_
```
### Setting up memory
```
-m 512
```
### Setting up network card
```
-net nic
```
### Setting up tun device
```
brctl addbr tun0
iw dev wlp3s0 set 4addr on
brctl addif tun0 wlp3s0
```
### Lunching image
If everything installed then image could be runed just with
```bash
qemu-system-i386 _options_ _disk_image_
```
## Lunching self compiled kernel
Let compile kernel and prepare initramfs to lunch it. Create file init.c
```c
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
printf("Hello world!\n");
sleep(999999999);
}
```
compile
```bash
gcc init.c -o init -static
```
and create image to lunch
```bash
echo init | cpio -o -H newc | gzip > test.cpio.gz
```
And now we have luncuble stuff to test if kernel loads fine
```bash
qemu-system-x86_64 -m 512 -kernel ./bzImage -initrd test.cpio.gz
```
If everything whent fine we will see "Hello world"
## Compile qemu
To get qemu you can download file or just clone git repo here is page to
download files [http://wiki.qemu.org/Download](http://wiki.qemu.org/Download)
and git repo located at
```bash
git clone git://git.qemu-project.org/qemu.git
```
To see avaliable targets run
```bash
./configure --help
```
there alos many different options and targets just choose one that you need
most
Configure targets:
```bash
./configure --target-list=arm-softmmu,arm-linux-user
```
or could be choosen to compile all targets
```bash
./configure --enable-system
```
Compile
```bash
make
```
## Reference
1. [https://wiki.archlinux.org/index.php/QEMU](https://wiki.archlinux.org/index.php/QEMU)
2. [http://www.cnx-software.com/2012/03/08/how-to-build-qemu-system-arm-in-linux/](http://www.cnx-software.com/2012/03/08/how-to-build-qemu-system-arm-in-linux/)
3. [https://wiki.linaro.org/PeterMaydell/KVM/HowTo/BuildQEMU](https://wiki.linaro.org/PeterMaydell/KVM/HowTo/BuildQEMU)
4. [http://www.cs.rochester.edu/~sandhya/csc256/assignments/qemu_linux.html](http://www.cs.rochester.edu/~sandhya/csc256/assignments/qemu_linux.html)
5. [https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt](https://www.kernel.org/doc/Documentation/filesystems/ramfs-rootfs-initramfs.txt)
|