Sample Header Ad - 728x90

Differences Between `/dev/null` and Devices Under `null_blk` Driver

11 votes
2 answers
1737 views
I recently encountered the [Linux Null Block device driver](https://docs.kernel.org/block/null_blk.html) , null_blk, while I benchmarking the I/O stack instead of on a specific block device. I found the devices created under this driver (let's use the device name /dev/nullb0 as an example) quite intriguing, especially considering their similarity in name to the /dev/null device. Since I couldn't find any existing questions on this topic from Stackoverflow, I decided to reach out for clarification. My main question is: **what are the differences between the /dev/null and the block device created under the null_blk device driver?** --- To this point: I've already noticed some distinctions. - First, (as far as I understand), the null device /dev/null doesn't go through any driver. However, devices created under null_blk are true block drivers that the data must pass through. I also confirmed this by running fio on both devices; /dev/null performs much better in terms of random read IOPS and submission latency. - Second, we know that reading from /dev/null results in an EOF (for example, cat /dev/null), but when I attempt cat /dev/nullb0, it doesn't return an EOF and instead hangs. - Additionally, as a side note, the kernel documentation for null_blk mentions parameters for configuration, but I don't see any similar options for /dev/null to be configured. It seems, large number of differences exist under the similar names. Can someone provide further also formal insights or clarification on these differences? Thanks!
Asked by JGL (161 rep)
Apr 10, 2024, 07:15 AM
Last activity: Apr 14, 2024, 02:01 PM