Created
December 30, 2018 02:52
-
-
Save anatol/8a684de0952ac7fe031946679edea912 to your computer and use it in GitHub Desktop.
Install Arch in QEMU and run KTSAN
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
https://medium.com/@clem.boin/creating-a-minimal-kernel-development-setup-using-qemu-and-archlinux-987896954d84 | |
# Install Arch system | |
qemu-image -f qcow2 kernel-dev-archlinux.img 4G | |
wget http://mirrors.edge.kernel.org/archlinux/iso/2018.12.01/archlinux-2018.12.01-x86_64.iso | |
# Note that ping does not work here | |
qemu-system-x86_64 -cdrom archlinux-2018.12.01-x86_64.iso -boot order=d -drive file=kernel-dev-archlinux.img,format=qcow2 -m 2G -enable-kvm -cpu host -smp 8 -net user,hostfwd=tcp::10022-:22 -net nic | |
# Run Arch system | |
qemu-system-x86_64 -hda wheezy-dirty.img -m 20G -smp 4 -net user,hostfwd=tcp::10022-:22 -net nic -nographic -kernel arch/x86/boot/bzImage -append "console=ttyS0 root=/dev/sda debug earlyprintk=serial slub_debug=QUZ" -enable-kvm -pidfile vm_pid | |
# TOREAD | |
https://blog.fpmurphy.com/2013/08/boot-linux-without-an-initramfs-2.html | |
http://nickdesaulniers.github.io/blog/2018/10/24/booting-a-custom-linux-kernel-in-qemu-and-debugging-it-with-gdb/ | |
https://www.collabora.com/news-and-blog/blog/2017/01/16/setting-up-qemu-kvm-for-kernel-development/ | |
https://medium.com/@clem.boin/creating-a-minimal-kernel-development-setup-using-qemu-and-archlinux-987896954d84 | |
https://github.com/google/ktsan/wiki | |
https://wiki.archlinux.org/index.php/User-mode_Linux#Build_rootfs_image | |
# TOREAD 2 | |
https://en.wikibooks.org/wiki/QEMU/Devices/Storage | |
# -initrd /boot/initramfs-linux.img | |
qemu-system-x86_64 -kernel arch/x86_64/boot/bzImage -nographic -append "console=ttyS0 root=/dev/sda rw debug earlyprintk=serial slub_debug=QUZ" -enable-kvm -cpu host -smp 8 -drive file=~/tmp/qemu-arch/rootfs.img,index=0 -net user,hostfwd=tcp::10022-:22 -net nic | |
# create rootfs | |
fallocate -l 8GiB rootfs.img | |
mkfs.ext4 -F rootfs.img | |
sudo mount -o loop rootfs.img mnt | |
sudo mkdir -p mnt/var/lib/pacman | |
sudo pacstrap mnt base | |
# build kernel | |
make defconfig | |
make kvmconfig | |
# Edit .config to set CONFIG_KTSAN=y | |
# Edit .config to unset CONFIG_SLUB and set CONFIG_SLAB=y | |
# Edit .config to set CONFIG_DEBUG_INFO=y | |
# ./scripts/config -e DEBUG_INFO -e GDB_SCRIPTS | |
make oldconfig | |
make -j8 LOCALVERSION=-tsan | |
# mount qcow2 disk | |
sudo modprobe nbd max_part=8 | |
sudo qemu-nbd --connect=/dev/nbd0 rootfs.img | |
mount /dev/nbd0 mnt | |
sudo qemu-nbd --disconnect /dev/nbd0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment