summaryrefslogtreecommitdiff
path: root/md/writeup
diff options
context:
space:
mode:
Diffstat (limited to 'md/writeup')
-rw-r--r--md/writeup/qemu_usage.md49
1 files changed, 46 insertions, 3 deletions
diff --git a/md/writeup/qemu_usage.md b/md/writeup/qemu_usage.md
index 38fc3e0..7e1baf6 100644
--- a/md/writeup/qemu_usage.md
+++ b/md/writeup/qemu_usage.md
@@ -16,11 +16,21 @@ qemu-system-i386 -cdrom _iso_image_ -boot order=d _qemu_image_
### Setting up memory
-> -m 512
+```
+-m 512
+```
### Setting up network card
+```
-net nic
+```
+
+### Setting up tun device
+
+```
+brctl addbr tun0
+```
### Lunching image
@@ -30,8 +40,39 @@ If everything installed then image could be runed just with
qemu-system-i386 _options_ _disk_image_
```
-<!--## Lunching self compiled kernel-->
+## 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
@@ -72,4 +113,6 @@ make
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) \ No newline at end of file
+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) \ No newline at end of file