aboutsummaryrefslogblamecommitdiffhomepage
path: root/content/2021-12-02-toying-with-virtio/build_kernel.sh
blob: b219b579058035e98d7dd1411fcc78f7bb01fdda (plain) (tree)


































































                                                                                            
#!/bin/bash

set -e

LINUX=linux-5.15.6

test -f $LINUX.tar.xz || wget -nc https://cdn.kernel.org/pub/linux/kernel/v5.x/$LINUX.tar.xz
test -d $LINUX || tar xf $LINUX.tar.xz

cd $LINUX

cat <<EOF > kernel_fragment.config
# 64bit kernel.
CONFIG_64BIT=y
# Enable support for cpio compressed initramfs (gzip).
CONFIG_BLK_DEV_INITRD=y
CONFIG_RD_GZIP=y
# Support for ELF and #! binary format.
CONFIG_BINFMT_ELF=y
CONFIG_BINFMT_SCRIPT=y
# Enable devtmpfs (can automatically populate /dev).
CONFIG_DEVTMPFS=y
CONFIG_DEVTMPFS_MOUNT=y
# Enable tty & console.
CONFIG_TTY=y
CONFIG_SERIAL_8250=y
CONFIG_SERIAL_8250_CONSOLE=y
# Enable proc & sys pseudo fs.
CONFIG_PROC_FS=y
CONFIG_SYSFS=y

# Enable support for virtio pci.
CONFIG_PCI=y
CONFIG_VIRTIO_MENU=y
CONFIG_VIRTIO_PCI=y

# Enable virtio console driver.
CONFIG_VIRTIO_CONSOLE=y

# Enable support for block devices.
CONFIG_BLK_DEV=y

# Enable virtio blk driver.
CONFIG_VIRTIO_BLK=y

# Enable support for ext2 filesystems.
CONFIG_EXT2_FS=y

# Enable general networking support.
CONFIG_NET=y

# Enable support for TCP/IP.
CONFIG_INET=y

# Enable support for network devices.
CONFIG_NETDEVICES=y

# Enable networking core drivers.
CONFIG_NET_CORE=y

# Enable virtio net driver.
CONFIG_VIRTIO_NET=y
EOF

make tinyconfig
./scripts/kconfig/merge_config.sh -n ./kernel_fragment.config
make -j$(nproc)