Hello, in this tutorial, I'll show you how to run xfstests on a custom kernel. I needed to do this because I made a change to the fs subsystem and needed to understand how to run the tests after that change. Since it was a difficult task, I decided to repeat it a few times to understand how to do it and be able to teach you step by step. Also, I'd like to remind everyone not to make the same mistake I did by not properly testing a change made to the kernel. Don't just test build and boot.
sudo dnf install build-essential ncurses-devel flex bison openssl-devel libssl-devel dkms elfutils-libelf-devel libudev-devel pciutils-devel python3-devel qemu-system-x86 debootstrap rsync
apt
).make menuconfig
menuconfig
, you need to ensure some key variables are set. You can use the search function by pressing /
and typing the variable name. Make sure each of these is enabled with Y
(built directly into the kernel, not as a module).CONFIG_XFS_FS
CONFIG_E1000E
CONFIG_VIRTIO_NET
CONFIG_VIRTIO_PCI
CONFIG_NET_FAILOVER
CONFIG_E1000
make -j$(nproc)
make headers_install INSTALL_HDR_PATH=/tmp/kernel-headers
xfstests
tool inside the VM.xfstests
.dd if=/dev/zero of=disk.img bs=1M count=20480
disk.img
using dd
. This will be the home for our operating system.mkfs.ext4 disk.img
ext4
filesystem. This turns our empty file into a real, usable partition, ready to hold files and folders.xfs_io -f -c "falloc 0 10g" test.img
xfs_io
to create a 10 GB file that will be our primary test disk.mkfs.xfs test.img
mkfs.xfs
.xfs_io -f -c "falloc 0 10g" scratch.img
xfstests
will handle that itself when needed.mkdir -p qemu-rootfs
sudo mount disk.img qemu-rootfs
sudo debootstrap --arch=amd64 bookworm qemu-rootfs http://deb.debian.org/debian/
sudo chroot qemu-rootfs /bin/bash
chroot
environment inside the new system.passwd
root
user, which you will need to log in to the VM later. Type exit
to leave the chroot
environment.sudo umount qemu-rootfs
sudo mount disk.img qemu-rootfs
sudo rsync -av /tmp/kernel-headers qemu-rootfs/usr/src/
sudo umount qemu-rootfs
Start the VM using your custom-compiled kernel and the prepared disks.
qemu-system-x86_64 \
-kernel <path_to_ur_kernel>arch/x86/boot/bzImage \
-hda disk.img \
-hdb test.img \
-hdc scratch.img \
-netdev user,id=mynet0 \
-device e1000,netdev=mynet0 \
-append "root=/dev/sda rw console=ttyS0" \
-nographic \
-smp 2 \
-m 2G
After the VM boots, log in as the root
user with the password you just created.
ip link show
ens3
) to use in the following commands.ip link set ens3 up
dhclient ens3
echo "nameserver 8.8.8.8" > /etc/resolv.conf
apt-get update
apt-get install -y pkg-config autoconf libtool
apt-get install -y acl attr automake bc dbench dump e2fsprogs fio gawk \
gcc git indent libacl1-dev libaio-dev libcap-dev libgdbm-dev libtool \
libtool-bin liburing-dev libuuid1 lvm2 make psmisc python3 quota sed \
uuid-dev uuid-runtime xfsprogs xfslibs-dev sqlite3 libgdbm-compat-dev
xfstests
.xfstests
:git clone https://git.kernel.org/pub/scm/fs/xfs/xfstests-dev.git
cd xfstests-dev
make
mkdir -p /mnt/test
mkdir -p /mnt/scratch
mount /dev/sdb /mnt/test
cp local.config.example local.config
local.config
file with vim
:export TEST_DEV=/dev/sdb
export TEST_DIR=/mnt/test
export SCRATCH_DEV=/dev/sdc
export SCRATCH_MNT=/mnt/scratch
export FSTYP=xfs
xfstests
which devices to use for testing.With everything configured, you can now run the tests to validate your changes.
./check -g auto
xfs/scrub
:./check xfs/001