A tiny educational filesystem module project implemented for Linux 5.10 kernel. Most design and implementation of this project were inspired by Ext2 Filesystem
- mkfs.pintfs.c – Initializes the file disk.
- Implemented minimal filesystem components:
super,dir,inode,file,namei. - Compatible with Linux kernel 5.10.219v.
- Reference: ext2 filesystem.
- Supports common Linux file-related commands (e.g.,
touch,echo,cat,rm,mkdir). - Works as a kernel module (
pintfs.ko) mountable with loopback devices. ⚠️ Known limitations:viis not supported for editing files.- Bug: after
rm file, removing the parent directory withrmdirfails.
// Install Linux
wget https://cdn.kernel.org/pub/linux/kernel/v5.x/linux-5.10.219.tar.xz
tar -xf linux-5.10.219.tar.xz
// Linux Kernel Image compile
cd linux-5.10.219
make defconfig
make -j$(nproc) bzImage
make modules
make modules_prepareUpdate KDIR in Makefile to your kernel source path.
cd ~/project/pintfs
make// Install Qemu
sudo apt update
sudo apt install qemu-system-x86 qemu-utils
// Minimal Debian
sudo apt install debootstrap
sudo debootstrap --arch=amd64 stable ./rootfs http://deb.debian.org/debian
// Qemu Disk Image
qemu-img create rootfs.img 2G
mkfs.ext4 rootfs.img
sudo mkdir /mnt/tmp
sudo mount -o loop rootfs.img /mnt/tmp
sudo cp -a rootfs/* /mnt/tmp
// Remove ID/Password in Qemu
sudo vi /mnt/rfs/etc/passwd
root:x:0:0:root:/root:/bin/bash -> root::0:0:root:/root:/bin/bash
sudo umount /mnt/tmp// Make pintdisk.raw Image
gcc -o mkfs.pintfs mkfs.pintfs.c
dd if=/dev/zero of=pintdisk.raw bs=4k count=64 //256kb
sudo ./mkfs.pintfs pintdisk.raw
// pintfs.ko -> rootfs.img
sudo mount -o loop rootfs.img /mnt/tmp
sudo cp pintfs.ko /mnt/tmp/root
// pintdisk.raw -> rootfs.img
sudo cp pintdisk.raw /mnt/tmp/root/
sudo umount /mnt/rfsqemu-system-x86_64 \
-kernel /root/linux-5.10.219/arch/x86/boot/bzImage \
-drive file=rootfs.img,format=raw,index=0,media=disk \
-append "root=/dev/sda console=ttyS0 rw" \
-nographicId: root
insmod pintfs.ko
mkdir test
mount -o loop,rw -t pintfs pintdisk.raw test
mount | grep pintfs
cd testThen, enjoy!
🚀 How to make file
touch file
echo hello >> file
cat file