1) DD If=/dev/zero of=./busybox.img bs=1m count=64
2) Mkfs.ext3 busybox.img
3) Download busybox,http://www.busybox.net/downloads/
#tar jxvf busybox-1.18.0.tar.bz2 (Decompression busybox compression pack)
#cd busybox-1.18.0 (into the extracted BusyBox source directory)
#make menuconfig (Configuration BusyBox)
Note When configuring, be sure to select the static Link option, which is located at:
Busybox settings–> Build options–> build Busybox as a static binary
#yum Install libselinux-static libsepol-static glibc-static (depending on the system may also require additional packages, this is the number of packages I need to install in my system, which is required for link busybox)
Next, we install BusyBox
#make Install (BusyBox is installed by default in the directory whose source tree directory is named _install)
4) Make launch img
In the BusyBox source directory
Cp-a./_install/*/mnt/disk/
sudo cp-a./examples/bootfloppy/etc/mnt/disk
sudo mkdir/mnt/disk/dev
sudo mkdir/mnt/disk/proc
sudo mkdir/mnt/disk/etc
sudo cp-ar./examples/bootfloppy/etc/mnt/disk/etc
sudo cp-a/dev/zero/mnt/disk/dev/
sudo cp-a/dev/console/mnt/disk/dev/
sudo cp-a/dev/null/mnt/disk/dev/
sudo cp-a/dev/tty*/mnt/disk/dev/
sudo cp-a/dev/ttys0/mnt/disk/dev/
5) Download Linux kernel source code
In the Linux kernel source directory
Make Defconfig
Make Menuconfig
Make Bzimage
6) Installing Qemu,yum install QEMU
7) Start Linux
Qemu-system-x86_64-s-kernel arch/x86_64/boot/bzimage-append "ROOT=/DEV/SDA"-hda busybox.img
GDB problem:
1) Download gdb7.7,http://ftp.gnu.org/gnu/gdb/
2) to the GDB source directory, vim gdb/remote.c
if (Buf_len > 2 * rsa->sizeof_g_packet)
Error (_ ("Remote ' G ' packet reply is too long:%s"), RS->BUF);
Change to:
if (Buf_len > 2 * rsa->sizeof_g_packet) {
Rsa->sizeof_g_packet = Buf_len;
for (i = 0; i < Gdbarch_num_regs (gdbarch); i++) {
if (Rsa->regs[i].pnum = =-1)
Continue
if (Rsa->regs[i].offset >= rsa->sizeof_g_packet)
Rsa->regs[i].in_g_packet = 0;
Else
Rsa->regs[i].in_g_packet = 1;
}
}
3) Recompile the installation gdb:
./configure--prefix=/usr/local/mygdb
Make && make install
4) using the new GDB:
/usr/local/mygdb/bin/gdb Vmlinux
Note: The above is just a personal note, no detailed description of each process, if you do not succeed please understand, I also found a lot of information on the internet to succeed, especially in different environments different Linux kernel version problem is not the same.
This article is from "Chen Yu blog" blog, please be sure to keep this source http://chenpiaoping.blog.51cto.com/5631143/1529988