diff options
| author | FreeArtMan <dos21h@gmail.com> | 2015-12-24 17:08:03 +0000 | 
|---|---|---|
| committer | FreeArtMan <dos21h@gmail.com> | 2015-12-24 17:08:03 +0000 | 
| commit | 71b92750cd361f8945f2533ca2b7e302ea181149 (patch) | |
| tree | 4c6d1be967478c2f40c49811f106c42fdf70b8d2 /md/writeup | |
| parent | 45d3c1d6287f8e2272436ed99109ff5dd1774254 (diff) | |
| download | md-content-71b92750cd361f8945f2533ca2b7e302ea181149.tar.gz md-content-71b92750cd361f8945f2533ca2b7e302ea181149.zip  | |
Added running Linux kernel on QEMU with minimal initramfs
Diffstat (limited to 'md/writeup')
| -rw-r--r-- | md/writeup/qemu_usage.md | 49 | 
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  | 
