Skip to the text
KDOS
Menu
kdos.dev KDOS from Scratch KDOS 0.2 · 4dd4a10 · 2026-11-30 Contents Index

98.22. ubdsrv-1.8

ublk userspace block devices — libublksrv, and the ublk tool with its loop, null, NBD and NFS targets

Version 1.8, release 1
Shelf disk — Block devices: partitioning, RAID, LVM, block encryption, SMART, NVMe, recovery, image writing and async I/O
Phase 41_system (System), 406 of 1047 in build order
Licence (MIT OR GPL-2.0-only) AND (MIT OR LGPL-2.1-only)
Homepage https://github.com/ublk-org/ublksrv
Build time 1.3 SBU
Installed size 900.9 KiB in 22 files
Recipe ports/core/disk/ubdsrv/kpkgbuild

About

ublksrv is the user-space server for ublk, the kernel’s interface for block devices implemented by a user-space program: the kernel creates /dev/ublkbN and hands each I/O request to the server through io_uring, and the server answers it from a file, a network service or memory. The port installs libublksrv, for writing such servers, and the ublk tool with its targets: ublk add -t loop backs a device with a file, -t nbd with an NBD server, -t nfs with a file on an NFS share, -t sheepdog with a Sheepdog volume, -t nvme_vfio with an NVMe drive driven from user space through VFIO (built because the kernel headers carry linux/vfio.h), and -t null with nothing, for testing. It needs the kernel’s ublk_drv module, which the linux port builds (CONFIG_BLK_DEV_UBLK=m). The upstream repository is ublk-org/ublksrv; the port and its package are named ubdsrv.

Sources

Dependencies

Depends on: autoconf, automake, libtool, pkgconf, liburing, libnfs.

Required by (1): libnbd.

Optional, off in KDOS

These switches in build.sh turn off a feature whose library is a port here. The recipe may turn each off on purpose, or because the library was not yet a port when the recipe was written; this list cannot tell which.

Patches

build.sh applies these; kpkg applies nothing by itself.

Installation

From the repository root, inside the build container, this is the line kdosbuild runs for the port:

script/chroot/exec.sh bash -c 'source script/phases/41_system/phase.env && kpkg install ubdsrv'

What kpkg does

kpkg runs these steps, in this order, as root inside the chroot. The port directory is /ports/core/disk/ubdsrv.

1. Verify every declared source. Each file a sha256 = line names, found in the port directory or in /var/cache/kpkg/sources, must hash to its line; a mismatch stops the build before anything is unpacked.

cd /ports/core/disk/ubdsrv
echo '881eb23b154ac0946609c82d4220df0598907c0f1061b00985b6956d50129e6d  ubdsrv-1.8.tar.gz' | sha256sum -c -

2. Unpack. The work directory is emptied and the first source is unpacked into $SRC with its top directory stripped; any later tarball lands unstripped beside it in $SRC_ROOT, and a file that is not a tarball is copied into $SRC.

SRC_ROOT=/var/cache/kpkg/work/ubdsrv
SRC=$SRC_ROOT/ubdsrv-1.8
PKG=$SRC_ROOT/pkg
rm -rf "$SRC_ROOT"
mkdir -p "$SRC" "$PKG"
tar --no-same-permissions --warning=no-unknown-keyword -xf ubdsrv-1.8.tar.gz -C "$SRC" --strip-components=1

Every config.guess and config.sub older than automake’s is then replaced with automake’s, so a configure script recognises the musl target.

3. Build. build.sh is sourced in a subshell under set -e, from $SRC, with name, version, release and the five paths PKGNAME, PORT_SRC, SRC_ROOT, SRC and PKG set as shell variables. Its body, verbatim:

patch -p1 -i "$PORT_SRC/musl-prctl.patch"
autoreconf -fi
export CXXFLAGS="$CXXFLAGS -fpermissive"
./configure --prefix=/usr --libdir=/usr/lib --sbindir=/usr/sbin --disable-static \
	--without-gnutls \
	--with-libnfs \
	--without-libiscsi
make noinst_PROGRAMS=
make noinst_PROGRAMS= DESTDIR=$PKG install

The switches, and why each is set:

The common switches of each build system are explained in the Flag glossary.

4. Package. kpkg removes libtool archives, the info directory index, mimeinfo.cache and every fonts.dir from $PKG, copies the source’s licence files into /usr/share/licenses/ubdsrv, prunes what the image does not ship, lints the tree and rolls it reproducibly:

tar --sort=name --format=gnu --numeric-owner --owner=0 --group=0 \
    --mtime=@$SOURCE_DATE_EPOCH \
    --use-compress-program='xz -9 -T0 --block-size=32MiB --no-adjust' \
    -cf ubdsrv-1.8-1.tar.xz -C "$PKG" .

5. Adopt. kpkgadd installs the package’s files over the root, refusing a path another package owns, records the file list in /var/lib/kpkg/db/ubdsrv, and runs the triggers its paths call for.

Contents

Installed programs: ublk, ublk.loop, ublk.nbd, ublk.nfs, ublk.null, ublk.nvme_vfio, ublk.sheepdog, ublk_chown.sh, ublk_chown_docker.sh, ublk_user_id.

Installed libraries: libublksrv.so.

Installed directories: /usr/share/licenses/ubdsrv.

Short descriptions

ublk Utility to manage ublk devices
ublksrv.pc ublk server library and headers