diff options
author | johannst <johannes.stoelp@gmail.com> | 2021-05-12 00:02:36 +0200 |
---|---|---|
committer | johannst <johannes.stoelp@gmail.com> | 2021-05-12 00:02:36 +0200 |
commit | beac9714ef693f97feb68e1793fa1ad30d8a96e4 (patch) | |
tree | 4cde25742031202d44b2f1e65212cbcca44eb52d /content/20191027-kernel-debugging-qemu | |
parent | 37f1e779e870276123a8f8af1c12ed5045c80553 (diff) | |
download | blog-beac9714ef693f97feb68e1793fa1ad30d8a96e4.tar.gz blog-beac9714ef693f97feb68e1793fa1ad30d8a96e4.zip |
added old blog entries
Diffstat (limited to 'content/20191027-kernel-debugging-qemu')
-rw-r--r-- | content/20191027-kernel-debugging-qemu/build_initrd.sh | 50 | ||||
-rw-r--r-- | content/20191027-kernel-debugging-qemu/build_kernel.sh | 38 |
2 files changed, 88 insertions, 0 deletions
diff --git a/content/20191027-kernel-debugging-qemu/build_initrd.sh b/content/20191027-kernel-debugging-qemu/build_initrd.sh new file mode 100644 index 0000000..74f9896 --- /dev/null +++ b/content/20191027-kernel-debugging-qemu/build_initrd.sh @@ -0,0 +1,50 @@ +#!/bin/bash + +set -e + +BUSYBOX=busybox-1.31.0 +INITRD=$PWD/initramfs.cpio.gz + +## Build busybox + +echo "[+] configure & build $BUSYBOX ..." +[[ ! -d $BUSYBOX ]] && { + wget https://busybox.net/downloads/$BUSYBOX.tar.bz2 + bunzip2 $BUSYBOX.tar.bz2 && tar xf $BUSYBOX.tar +} + +cd $BUSYBOX +make defconfig +sed -i 's/# CONFIG_STATIC .*/CONFIG_STATIC=y/' .config +make -j4 busybox +make install + +## Create initrd + +echo "[+] create initrd $INITRD ..." + +cd _install + +# 1. create initrd folder structure +mkdir -p bin sbin etc proc sys usr/bin usr/sbin dev + +# 2. create init process +cat <<EOF > init +#!/bin/sh + +mount -t proc none /proc +mount -t sysfs none /sys + +exec setsid cttyhack sh +EOF +chmod +x init + +# 3. create device nodes +sudo mknod dev/tty c 5 0 +sudo mknod dev/tty0 c 4 0 +sudo mknod dev/ttyS0 c 4 64 + +# 4. created compressed initrd +find . -print0 \ + | cpio --null -ov --format=newc \ + | gzip -9 > $INITRD diff --git a/content/20191027-kernel-debugging-qemu/build_kernel.sh b/content/20191027-kernel-debugging-qemu/build_kernel.sh new file mode 100644 index 0000000..f1e15bb --- /dev/null +++ b/content/20191027-kernel-debugging-qemu/build_kernel.sh @@ -0,0 +1,38 @@ +#!/bin/bash + +set -e + +LINUX=linux-5.3.7 +wget https://cdn.kernel.org/pub/linux/kernel/v5.x/$LINUX.tar.xz +unxz $LINUX.tar.xz && tar xf $LINUX.tar + +cd $LINUX + +cat <<EOF > kernel_fragment.config +# 64bit kernel +CONFIG_64BIT=y +# enable support for compressed initrd (gzip) +CONFIG_BLK_DEV_INITRD=y +CONFIG_RD_GZIP=y +# support for ELF and #! binary format +CONFIG_BINFMT_ELF=y +CONFIG_BINFMT_SCRIPT=y +# /dev +CONFIG_DEVTMPFS=y +CONFIG_DEVTMPFS_MOUNT=y +# tty & console +CONFIG_TTY=y +CONFIG_SERIAL_8250=y +CONFIG_SERIAL_8250_CONSOLE=y +# pseudo fs +CONFIG_PROC_FS=y +CONFIG_SYSFS=y +# debugging +CONFIG_DEBUG_INFO=y +CONFIG_PRINTK=y +CONFIG_EARLY_PRINTK=y +EOF + +make tinyconfig +./scripts/kconfig/merge_config.sh -n ./kernel_fragment.config +make -j4 |