Skip to content

Instantly share code, notes, and snippets.

@yalab
Created September 22, 2017 08:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yalab/7744fe49ec6c542892cf0807b4226a19 to your computer and use it in GitHub Desktop.
Save yalab/7744fe49ec6c542892cf0807b4226a19 to your computer and use it in GitHub Desktop.
FROM alpine
MAINTAINER yalab <rudeboyjet@gmail.com>
RUN apk --update --no-cache add alpine-sdk ncurses-dev bc linux-headers perl
ENV ARCH="x86_64"
RUN git clone --depth 1 git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git /linux
WORKDIR /linux
# docker build . -t kernel-build
# docker run -it -v /Users/yalab/vendor/linux:/linux kernel-build /bin/sh
# RUN cd /linux/linux && yes "" | make oldconfig
# //make x86_64_defconfig
# make menuconfig
# General setup -> Initial RAM filesystem and RAM disk support
# Device Drivers -> Block Devices -> Loopback Device Support
# make all && make modules
# $ qemu-system-x86_64 -kernel ./arch/bzImage
# $ docker exec $(docker ps -q) cat /linux/arch/x86_64/boot/bzImage > bzImage
# $ qemu-system-x86_64 -kernel bzImage
# $ echo -e '#include <stdio.h>\nint main(){\n while(1){\n printf("Hello kernel world\n");\n }\n return 0;\n}' > hello.c
# $ gcc -static hello.c -o hello
# $ echo hello | cpio -o -H newc > initramfs.img
# $ docker exec $(docker ps -q) cat /linux/boot/initramfs.img > initramfs.img
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment