https://github.com/abbbi/nullfsvfs Skip to content Sign up * Why GitHub? Features - + Mobile - + Actions - + Codespaces - + Packages - + Security - + Code review - + Issues - + Integrations - + GitHub Sponsors - + Customer stories- * Team * Enterprise * Explore + Explore GitHub - Learn and contribute + Topics - + Collections - + Trending - + Learning Lab - + Open source guides - Connect with others + The ReadME Project - + Events - + Community forum - + GitHub Education - + GitHub Stars program - * Marketplace * Pricing Plans - + Compare plans - + Contact Sales - + Education - [ ] [search-key] * # In this repository All GitHub | Jump to | * No suggested jump to results * # In this repository All GitHub | Jump to | * # In this user All GitHub | Jump to | * # In this repository All GitHub | Jump to | Sign in Sign up {{ message }} abbbi / nullfsvfs * Notifications * Star 97 * Fork 7 a virtual black hole file system that behaves like /dev/null GPL-3.0 License 97 stars 7 forks Star Notifications * Code * Issues 2 * Pull requests 0 * Actions * Projects 0 * Wiki * Security * Insights More * Code * Issues * Pull requests * Actions * Projects * Wiki * Security * Insights master Switch branches/tags [ ] Branches Tags Could not load branches Nothing to show {{ refName }} default View all branches Could not load tags Nothing to show {{ refName }} default View all tags 1 branch 6 tags Code Clone HTTPS GitHub CLI [https://github.com/a] Use Git or checkout with SVN using the web URL. [gh repo clone abbbi/] Work fast with our official CLI. Learn more. * Open with GitHub Desktop * Download ZIP Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching GitHub Desktop If nothing happens, download GitHub Desktop and try again. Go back Launching Xcode If nothing happens, download Xcode and try again. Go back Launching Visual Studio Code Your codespace will open once ready. There was a problem preparing your codespace, please try again. Latest commit @abbbi abbbi set module_version ... db73ba4 Jun 16, 2021 set module_version db73ba4 Git stats * 97 commits Files Permalink Failed to load latest commit information. Type Name Latest commit message Commit time .github/workflows use github actions for ci Jun 16, 2021 debian set module_version Jun 16, 2021 LICENSE Create LICENSE May 19, 2021 Makefile readme Nov 8, 2018 README.md remove travis-ci Jun 16, 2021 nullfs.c set module_version Jun 16, 2021 nullfs.jpg .. Nov 12, 2018 test.sh testscript Nov 14, 2018 View code Index nullfs usage keep usecases supported todos/ideas README.md Index * About * Usage * Use Cases * Keeping data * Mount options nullfs a virtual file system that behaves like /dev/null It can handle regular file operations like mkdir/rmdir/ln but writing to files does not store any data. The file size is however saved, so reading from the files behaves like reading from /dev/zero with a fixed size. Writing and reading is basically an NOOP, so it can be used for performance testing with applications that require directory structures. Implemented as kernel module, instead of using FUSE, there is absolutely no overhead for copying application data from user to kernel space while performing write or read operations. alt text usage # make make -C /lib/modules/4.18.5/build M=/home/abi/lwnfs modules make[1]: Entering directory '/usr/src/linux-headers-4.18.5' Building modules, stage 2. MODPOST 1 modules make[1]: Leaving directory '/usr/src/linux-headers-4.18.5' # insmod nullfs.ko # mkdir /sinkhole # mount -t nullfs none /sinkhole/ # mkdir /sinkhole/testdir # touch /sinkhole/testdir/myfile # echo foobar > /sinkhole/testdir/myfile # ls -lah /sinkhole/testdir/myfile -rw-r--r-- 1 root root 0 Nov 8 20:17 /sinkhole/testdir/myfile # cat /sinkhole/testdir/myfile # pv < /dev/zero > /sinkhole/testdir/myfile 11.1GiB 0:00:04 [3.85GiB/s] [ <=> ] # cat /sinkhole/testdir/myfile # File size is preserved to work around applications that do size checks: # dd if=/dev/zero of=/nullfs/DATA bs=1M count=20 # 20+0 records in # 20+0 records out # 20971520 bytes (21 MB, 20 MiB) copied, 0.00392452 s, 5.3 GB/s # stat -c%s /nullfs/DATA # 20971520 Reading from the files does not copy anything to userspace and is an NOOP; makes it behave like reading from /dev/zero: # dd if=/nullfs/DATA of=/tmp/REALFILE # 40960+0 records in # 40960+0 records out # 20971520 bytes (21 MB, 20 MiB) copied, 0.0455288 s, 461 MB/s # hexdump -C /tmp/REALFILE # 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 |................| keep There is the possiblity to exclude certain files from beeing sent into the void. For example if the file matching "fstab" should be kept in memory, one can mount nullfs with the "write=" option. # mount -t nullfs none /sinkhole/ -o write=fstab # cp /etc/fstab /sinkhole/ # wc -l /sinkhole/fstab 14 /sinkhole/fstab # cp /etc/passwd /sinkhole/ # wc -l /sinkhole/passwd 0 /sinkhole/passwd Another option is using the sysfs interface to change the exclude string after the module has been loaded: echo foo > /sys/fs/nullfs/exclude Keep in mind that file data is kept in memory and no boundary checks are done, so this might fill up your RAM in case you exclude big files from beeing nulled. usecases See: Use Cases The module has been used for performance testing with redis, see: https://www.usenix.org/system/files/atc20-george.pdf supported The following mount options are supported: -o mode= set permissions on mount directory ( mount .. -o mode=777 ) -o uid= set uid on mount directory ( mount .. -o uid=1000 ) -o gid= set gid on mount directory ( mount .. -o gid=1000 ) todos/ideas * replace simple_statfs call with real one, show free space of a directory that can be passed during kernel module load * support multiple parameters for write= option * allow regex for write= option via trace.h About a virtual black hole file system that behaves like /dev/null Topics linux filesystem linux-kernel dev null vfs virtual-file-system performance-testing nulldev nullfs Resources Readme License GPL-3.0 License Releases 6 Version 0.6 Latest Jun 16, 2021 + 5 releases Packages 0 No packages published Languages * C 94.3% * Shell 4.6% * Makefile 1.1% * (c) 2021 GitHub, Inc. * Terms * Privacy * Security * Status * Docs * Contact GitHub * Pricing * API * Training * Blog * About You can't perform that action at this time. You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.