Created
October 31, 2021 21:16
-
-
Save valkheim/6efc6d61ad06e36832b973c0b12cdf85 to your computer and use it in GitHub Desktop.
prepare_kernel.sh
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
KERNEL=4.10.3 | |
NPROC=$(nproc) | |
HERE=$(dirname $(readlink -f "$0")) | |
function log | |
{ | |
printf "[+] $1\n" | |
} | |
#log "Installing dependencies" | |
#yay -Syu bc qemu qemu-arch-extra | |
log "Fetching Linux ($KERNEL)" | |
kernel_name="linux-$KERNEL" | |
kernel_slug="v$(echo "$KERNEL" | cut -c1).x" | |
kernel_remote="https://mirrors.edge.kernel.org/pub/linux/kernel/$kernel_slug/$kernel_archive_name.tar.gz" | |
kernel_archive_path="$HERE/kernels/$kernel_name.tar.gz" | |
if [ ! -f "$kernel_archive_path" ]; then | |
log "Downloading $kernel_remote to $kernel_archive_path" | |
mkdir -p $(dirname "$kernel_archive_path") | |
wget -q -c "$kernel_remote" -O "$kernel_archive_path" | |
fi | |
kernel_dirpath="$HERE/kernels/$kernel_name" | |
if [ ! -d "$kernel_dirpath" ]; then | |
log "Extracting $kernel_archive_path to $HERE/kernels" | |
mkdir -p $(dirname "$kernel_archive_path") | |
tar xf "$kernel_archive_path" -C "$HERE/kernels" | |
fi | |
log "Building kernel" | |
if [ ! -f "$kernel_dirpath/arch/x86/boot/bzImage" ]; then | |
make -C "$kernel_dirpath" -j "$NPROC" defconfig | |
echo "CONFIG_NET_9P=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_NET_9P_DEBUG=n" >> "$kernel_dirpath/.config" | |
echo "CONFIG_9P_FS=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_9P_FS_POSIX_ACL=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_9P_FS_SECURITY=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_NET_9P_VIRTIO=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_VIRTIO_PCI=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_VIRTIO_BLK=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_VIRTIO_BLK_SCSI=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_VIRTIO_NET=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_VIRTIO_CONSOLE=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_HW_RANDOM_VIRTIO=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_DRM_VIRTIO_GPU=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_VIRTIO_PCI_LEGACY=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_VIRTIO_BALLOON=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_VIRTIO_INPUT=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_CRYPTO_DEV_VIRTIO=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_BALLOON_COMPACTION=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_PCI=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_PCI_HOST_GENERIC=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_GDB_SCRIPTS=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_DEBUG_INFO=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_DEBUG_INFO_REDUCED=n" >> "$kernel_dirpath/.config" | |
echo "CONFIG_DEBUG_INFO_SPLIT=n" >> "$kernel_dirpath/.config" | |
echo "CONFIG_DEBUG_FS=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_DEBUG_INFO_DWARF4=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_DEBUG_INFO_BTF=y" >> "$kernel_dirpath/.config" | |
echo "CONFIG_FRAME_POINTER=y" >> "$kernel_dirpath/.config" | |
make -C "$kernel_dirpath" -j "$NPROC" bzImage | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment