GithubHelp home page GithubHelp logo

spacecase123 / nullb Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kdave/nullb

0.0 0.0 0.0 30 KB

Simple null block device manager script, useful for zoned device testing.

License: GNU General Public License v2.0

Shell 4.71% C 94.70% Makefile 0.59%

nullb's Introduction

nullb

Simple null block device manager script, useful for zoned device testing. The devices are managed by configfs files, this script wraps the basic operations for convenience. The null block device is usually memory-backed so the capacity is limited but it should be sufficient to create 1GiB or 2GiB devices. The benefit is flexible zone size that could be otherwise unavailable with other types of device.

Requirements:

  • nullb_blk loadable kernel module
  • configfs either as loadable module or built-in

The script follows common command line interface when there are multiple subcommands provided by one script. Currently there is:

  • nullb setup - load required modules and mount configfs
  • nullb create [-s sizeMB] [-z zonesizeMB] - create a new device with given sizes, allocating the first free indes, device is /dev/nullb$index
  • nullb ls
  • nullb list - show table of created null_blk devices, size and zone sizes
  • nullb rm NAME
  • nullb delete NAME - delete existing null_blk device by name, must match the device node name like nullb0

Defaults:

  • device size: 2GiB
  • zone size: 256MiB

Quick start

# ./nullb setup
INFO: setup module and mounts

If that succeeds, the module has been loaded and the configfs is available.

# ./nullb create
INFO: Create nullb0
INFO: name=nullb0
INFO: size=2048M zone_size=256M
/dev/nullb0

The INFO messages are for clarity when run interactively, for scripting the last line contains the name of the device node that's been created.

# ./nullb ls
INFO: device nodes:
/dev/nullb0
INFO: created devices:
No  Name      Device                   Size    Zone size  On
 0  nullb0    /dev/nullb0             2048M         256M   1

The null block device nodes and the actual name in sysfs can be different so both are printed, though this script keeps both names respecting the index and name matches the device node filename.

# ./nullb rm nullb0
INFO: check mounts
INFO: removing nullb0

Mount checks just lists all mounts using the device but won't stop the removal. It should fail if the device is in use, otherwise the device and its resources are released after the command ends.

Trivia

  • the null_blk driver exists since kernel 3.12, zoned support has been added in 4.19 but please use at least 5.10 as a good base with improvements and fixes
  • the device data are backed by memory, reasonable size should be used for the 'size'
  • zone sizes must be a power of two, eg. 4MiB works
  • you can use the 'nullb' devices with 'btrfs' and have fun testing
  • use blkzone utility to 'report' or 'reset' zones on the device
  • https://zonedstorage.io

nullb's People

Contributors

kdave avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.