Created
August 23, 2017 19:56
-
-
Save ismailhkose/8805223819f65858e36d0d3e4fd5edc8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
TOP=$HOME/8-23-qemu_x86/ | |
mkdir -pv $TOP/obj/busybox-x86 | |
cd $TOP | |
curl https://busybox.net/downloads/busybox-1.26.2.tar.bz2 | tar -xj | |
cd busybox-1.26.2 | |
mkdir -pv bb_build | |
make O=bb_build defconfig | |
make O=../obj/busybox-x86 menuconfig | |
# Busybox Settings ---> choose * Build BusyBox as a static binary (no shared libs) | |
cd bb_build | |
make -j8 | |
make install | |
BUSYBOX_INSTALL_DIR=$TOP/busybox-1.26.2/bb_build/_install | |
# BUILD LINUX KERNEL | |
cd $TOP | |
curl https://cdn.kernel.org/pub/linux/kernel/v4.x/linux-4.9.2.tar.xz | tar xJf - | |
cd linux-4.9.2 | |
mkdir build1 | |
make O=build1 defconfig | |
cd build1 | |
make -j8 | |
#make ARCH=x86 x86_64_defconfig | |
#make O=build1 ARCH=x86 x86_64_defconfig | |
# Create Initramfs | |
mkdir -pv $TOP/initramfs | |
cd $TOP/initramfs | |
mkdir ./{etc,sys,proc} | |
cp -av $BUSYBOX_INSTALL_DIR/* . | |
rm linuxrc | |
# Create Init file | |
cat >> init << EOF | |
#!/bin/sh | |
mount -t proc none /proc | |
mount -t sysfs none /sys | |
echo -e "Hello World\n" | |
exec /bin/sh | |
EOF | |
chmod +x init | |
find . -print0 | cpio --null -ov --format=newc > initramfs.cpio | |
# We could also have created the initramfs as a compressed archive using gzip: | |
# find . -print0 | cpio --null -ov --format=newc | gzip -9 > initramfs.cpio.gz | |
cd ../ | |
cp $TOP/linux-4.9.2/build1/arch/x86_64/boot/bzImage $TOP | |
cp $TOP/initramfs/initramfs.cpio $TOP | |
ll | |
export DISPLAY=:0 | |
# Boot With initramfs | |
qemu-system-x86_64 -kernel bzImage -initrd initramfs.cpio -m 512 -nographic -append console=ttyS0 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
[ 1.602395] Netfilter messages via NETLINK v0.30.
[ 1.606598] nf_conntrack version 0.5.0 (4096 buckets, 16384 max)
[ 1.609557] ctnetlink v0.93: registering with nfnetlink.
[ 1.614610] ip_tables: (C) 2000-2006 Netfilter Core Team
[ 1.618499] Initializing XFRM netlink socket
[ 1.620601] NET: Registered protocol family 10
[ 1.627397] ip6_tables: (C) 2000-2006 Netfilter Core Team
[ 1.629139] sit: IPv6, IPv4 and MPLS over IPv4 tunneling driver
[ 1.631991] NET: Registered protocol family 17
[ 1.632818] Key type dns_resolver registered
[ 1.634927] microcode: AMD CPU family 0x6 not supported
[ 1.637603] registered taskstats version 1
[ 1.640607] Magic number: 13:647:951
[ 1.640916] tty tty8: hash matches
[ 1.641471] console [netcon0] enabled
[ 1.641585] netconsole: network logging started
[ 1.643415] ALSA device list:
[ 1.643508] No soundcards found.
[ 1.682131] Freeing unused kernel memory: 1144K (ffffffff81f34000 - ffffffff82052000)
[ 1.682355] Write protecting the kernel read-only data: 14336k
[ 1.684440] Freeing unused kernel memory: 1020K (ffff880001901000 - ffff880001a00000)
[ 1.698754] Freeing unused kernel memory: 1288K (ffff880001cbe000 - ffff880001e00000)
[ 1.699940] Failed to execute /init (error -2)
[ 1.700823] Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.
[ 1.701081] CPU: 0 PID: 1 Comm: swapper/0 Not tainted 4.9.2 #1
[ 1.701081] Hardware name: QEMU Standard PC (i440FX + PIIX, 1996), BIOS Ubuntu-1.8.2-1ubuntu1 04/01/2014
[ 1.701081] ffffc900000d3eb8 ffffffff8132bfb8 ffffffff818f1600 ffffffff81b97270
[ 1.701081] ffffc900000d3f38 ffffffff81127def ffffffff00000008 ffffc900000d3f48
[ 1.701081] ffffc900000d3ee0 0000000000000000 ffff88001fc1aac0 0000000000001be4
[ 1.701081] Call Trace:
[ 1.701081] [] dump_stack+0x4d/0x65
[ 1.701081] [] ? rest_init+0x60/0x80
[ 1.701081] [] panic+0xca/0x203
[ 1.701081] [] ? putname+0x4f/0x60
[ 1.701081] [] ? rest_init+0x80/0x80
[ 1.701081] [] kernel_init+0xe6/0x100
[ 1.701081] [] ret_from_fork+0x22/0x30
[ 1.701081] Kernel Offset: disabled
[ 1.701081] ---[ end Kernel panic - not syncing: No working init found. Try passing init= option to kernel. See Linux Documentation/init.txt for guidance.