-
Notifications
You must be signed in to change notification settings - Fork 2
Quick Start: ublk
Hadi Moshayedi edited this page Jan 29, 2026
·
4 revisions
Initialize the disk file with an empty ext4:
touch ublk.raw
truncate --size 1G ublk.raw
mkfs.ext4 ublk.raw
Create the config file ublk-config.yaml:
path: "ublk.raw"
Start the backend:
export RUST_LOG=debug
sudo -E ~/projects/ubiblk/target/debug/ublk-backend --config ublk-config.yaml
You should see something like:
[INFO ubiblk::backends::common] Starting ublk backend. Process ID: 3327618
[INFO ubiblk::backends::ublk] Creating ublk backend ...
[INFO libublk::ctrl] ctrl: device 4 flags 2 created
[INFO libublk::io] dev 4 initialized
[INFO libublk::io] dev 4 queue 0 started
[INFO ubiblk::backends::ublk] ublk device is available at /dev/ublkb4
Now you can use /dev/ublkb4.
$ sudo fsck.ext4 /dev/ublkb4
e2fsck 1.46.5 (30-Dec-2021)
/dev/ublkb4: clean, 11/65536 files, 12955/262144 blocks
$ mkdir mnt
$ sudo mount /dev/ublkb4 mnt
To check if your kernel supports ublk, run:
grep CONFIG_BLK_DEV_UBLK /boot/config-$(uname -r)If the output is CONFIG_BLK_DEV_UBLK=y, then ublk support is built into the
kernel. If it is CONFIG_BLK_DEV_UBLK=m, then ublk is built as a module and you
need to load it with:
sudo modprobe ublk_drvSync implementation:
- 4k rand read: 57.8MiB/s
- 4k rand write: 153MiB/s
Async implementation:
- 4k rand read: 445MiB/s
- 4k rand write: 591MiB/s