Using QEMU to emulate debug kernel and Debian root file system

Source: Internet
Author: User
Tags tainted

Development environment: Ubuntu 14.04.3 LTS 64bit

sudo debootstrap Jessie/mnt/jessie Http://mirrors.163.com/debian

In the/mnt/jessie directory, create an init file that reads as follows:

 [Email protected]380 : ~$ sudo  Span style= "COLOR: #0000ff" >vi /mnt/jessie/init # !/bin/sh  # Devtmpfs does not get automounted  for   Initramfs  echo   " ******** init **********   "/bin/mount -t Devtmpfs Devtmpfs/devexec  0  </dev/ consoleexec  1  >/dev/consoleexec  2  >/dev/consoleexec /sbin/init $* 

Refer to the Linux kernel documentation documentation/filesystems/ramfs-rootfs-initramfs.txt and use the script below to package Initramfs

[Email protected]380:/mnt$CatMkinitramfs.SH #!/bin/SH# Copyright2006Rob Landley <[email protected]>and Timesys corporation.# Licensed under GPL version2if[$#-ne2 ] Then  Echo "Usage:mkinitramfs Directory imagename.cpio.gz"Exit1fiif[-D" $" ] Then  Echo "creating $ from $"(CD" $";Find. | Cpio-o-H NEWC |gzip) >" $"Else  Echo "First argument must be a directory"Exit1fi

Package Command:

mkinitramfs.sh Jessie Rootfs.cpio.gz

Use the following command to start the kernel and root file system:

Qemu-system-x86_64-kernel bzimage-initrd/mnt/rootfs.cpio.gz/dev/zero-m 2g-nographic-append "Console=ttyS0"

Issue: Unable to enter INITRAMFS at startup because there is no init file under the root directory.

[11.815891] Rtc_cmosxx:xx: Setting system clock to -- A- Geneva  -: +: -UTC (1449040919)[   11.818523] BIOS EDD facility v0. - 2004-jun- -,0Devices found[11.818900] EDD information not available. [   11.819783] ALSA device list:[11.819991] No soundcards found. [   12.396667] Input:imexps/2Generic Explorer Mouse as/devices/platform/i8042/serio1/input/input3[12.403434] Vfs:cannot Open Root device"(NULL)"or Unknown-block (0,0): Error-6[   12.403941] Please append a correct"root="boot option; here is the available partitions:[12.404870] Kernel Panic-not syncing:VFS:Unable toMountRoot FS on Unknown-block (0,0)[   12.405584] CPU:0Pid:1comm:swapper/0Not tainted3.13.0#7[   12.405945] Hardware Name:qemu Standard PC (i440fx + Piix,1996), BIOS Bochs on/ on/ .[   12.406561]0000000000008001ffff880074d01dd0 ffffffff81b8de3a ffffffff8201c2c8[12.407087] ffff880074d01e48 ffffffff81b89a24 223d746f00000010 ffff880074d01e58[12.407557] Ffff880074d01df8 000000000000004f ffff880074d01e680000000000000052[   12.408077] Call trace:[12.408502] [<ffffffff81b8de3a>] dump_stack+0x45/0x56[   12.408502] [<ffffffff81b89a24>] panic+0xc2/0X1C1[   12.408502] [<ffffffff8234e338>] mount_block_root+0x1a8/0x250[   12.408502] [<ffffffff8234e61b>] mount_root+0xf1/0XFA[   12.408502] [<ffffffff8234f2a0>]? Initrd_load+0X2C9/0x2d8[   12.408502] [<ffffffff8234e78b>] prepare_namespace+0x167/0x19f[   12.408502] [<ffffffff8234e04a>] Kernel_init_freeable+0x1c4/0x1d1[   12.408502] [<ffffffff8234d833>]? do_early_param+0x88/0x88[   12.408502] [<ffffffff81b85b00>]? rest_init+0x80/0x80[   12.408502] [<ffffffff81b85b0e>] kernel_init+0xe/0x120[   12.408502] [<ffffffff81b9f2ac>] ret_from_fork+0x7c/0xb0[   12.408502] [<ffffffff81b85b00>]? rest_init+0x80/0x80[   12.408502] General Protection FAULT:FFF2 [#1] SMP [12.408502] Modules Linkedinch:[   12.408502] CPU:0Pid:1comm:swapper/0Not tainted3.13.0#7[   12.408502] Hardware Name:qemu Standard PC (i440fx + Piix,1996), BIOS Bochs on/ on/ .[   12.408502] task:ffff880074c58000 ti:ffff880074d00000 task.ti:ffff880074d00000[12.408502] RIP:0010: [<ffffffff81b89aea>] [<ffffffff81b89aea>] panic+0x188/0X1C1[   12.408502] RSP:0018: Ffff880074d01de0 eflags:00000246[   12.408502] rax:0000000000006a6a rbx:ffffffff8201c2c8 rcx:00000000000000a0[12.408502] rdx:000000000000006a RSI:0000000000000000rdi:ffffffff826c8a70[12.408502] Rbp:ffff880074d01e48 R08:0000000000000001r09:00000000000001e1[12.408502] r10:736572203f205d3e R11:3030623538623138R12:0000000000000000[   12.408502] R13:0000000000000000R14:0000000000000000r15:ffff88007fa93000[12.408502] FS:0000000000000000(0000) gs:ffff880077800000 (0000) Knlgs:0000000000000000[   12.408502] CS:0010Ds:0000Es:0000cr0:000000008005003b[12.408502] cr2:00007fbb08c44140 cr3:000000000220c000 cr4:00000000000006f0[12.408502] DR0:0000000000000000DR1:0000000000000000DR2:0000000000000000[   12.408502] DR3:0000000000000000DR6:0000000000000000DR7:0000000000000000[   12.408502] stack:[12.408502] 223d746f00000010 ffff880074d01e58 ffff880074d01df8 000000000000004f[12.408502] Ffff880074d01e680000000000000052ffff880000095070 6120657361656c50[12.408502] 00000000000001ce ffff88007fa930000000000000008001 0000000000008001[   12.408502] Call trace:[12.408502] [<ffffffff8234e338>] mount_block_root+0x1a8/0x250[   12.408502] [<ffffffff8234e61b>] mount_root+0xf1/0XFA[   12.408502] [<ffffffff8234f2a0>]? Initrd_load+0X2C9/0x2d8[   12.408502] [<ffffffff8234e78b>] prepare_namespace+0x167/0x19f[   12.408502] [<ffffffff8234e04a>] Kernel_init_freeable+0x1c4/0x1d1[   12.408502] [<ffffffff8234d833>]? do_early_param+0x88/0x88[   12.408502] [<ffffffff81b85b00>]? rest_init+0x80/0x80[   12.408502] [<ffffffff81b85b0e>] kernel_init+0xe/0x120[   12.408502] [<ffffffff81b9f2ac>] ret_from_fork+0x7c/0xb0[   12.408502] [<ffffffff81b85b00>]? rest_init+0x80/0x80[   12.408502] Code:xx xx  theFfcc  About0c BF -  the  A xxE8 E0 -  theFF EB ef -  theC3 -EB b6 the3d A1 the  the xx xx  About  toE8 5a 3f 4e FF FB $  toE4 <4d> theEC 7c -  A  theF6 on  -  theF7 FF the  -  the  the xx  the  onC4 [12.408502] RIP [<ffffffff81b89aea>] panic+0x188/0X1C1[   12.408502] RSP <ffff880074d01de0>[   12.408502]---[end trace 96badb4295b8f792]---

QEMU provides several shortcut keys, CTRL + A h open Help

  • C-a h Print this help
  • C-a x Exit emulator Exit
  • C-A s save disk data back to file (If-snapshot)
  • C-a T Toggle console timestamps
  • C-a b Send Break (Magic SysRq)
  • C-a C Switch between console and monitor switch between the Linux console and the QEMU control terminal
  • C-a C-a sends C-a
  • Using QEMU to emulate debug kernel and Debian root file system

    Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.