Qemu mounts Linux kernel and busybox root file systems

Source: Internet
Author: User

Grandma, a bear, got killed by a stupid error for several nights and did not compile it into a static file. After running it, the system prompts no init file.

In fact, the whole process is quite simple, that is, the details are not noticed. I have written a script (for reference only, work is not OK) for your reference:

#! /Bin/ Bash # In order not to affect others, create a directory for our work  Mkdir  Kerneldbgcd kerneldbg # Use the GIT Version Management System to download the Linux kernel source code. Git:  //  Git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git  # Use the GIT Version Management System to download the busybox source code git clone git:  //  Busybox.net/busybox.git  # Check whether qemu is installed in the system. If not, install dpkg. -L | Grep  Qemu If [$? EQ 1  ]  Echo   "  Please install qemu first!  "      Echo   "  Usage: sudo apt-Get install qemu  "  Fi  # Compile busybox first. Set busybox to static link before compilation. Otherwise, hum, kill you @ # You can manually set. CD busybox through make menuconfig  If [- F. config] Sed   "  Config_staic = y  " # Modify to static compilation. Code ! Else      Echo   "  Missing. config, please \ "make menuconfig \" first  "  Fi  # Compile busybox and install it. A _ install directory is generated under the current directory.  Make  Make   Install # Go To The Linux directory CD .. CD Linux - Stable # After necessary Configuration  Make  Bzimage # create a disk image  Dd   If =/Dev/Zero of = rootfs. img bs = 1 m COUNT = 20  # Format the disk mkfs. ext3 rootfs. IMG # create a rootfs directory to mount rootfs. img  Mkdir  Rootfs # Mount rootfs. img  Sudo   Mount - O loop rootfs. IMG rootfs # copy all the content in the _ install directory generated by busybox to the rootfs directory. # This is actually the so-called root file system. CP -RV./busybox/_ install /*  . /Rootfs # create the necessary device file CD rootfssudo mknod rootfs/dev/console C 5 1 sudo mknod rootfs/dev/Ram B 1 0 # copy the bzimage compiled by Linux to CD .. CP. /Linux-stable/ARCH/x86/boot/bzimage # Start qemu and load the generated root file system and Kernel File qemu-hda. /rootfs. IMG-kernel. /bzimage-APPEND "root =/dev/SDA" 

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.