nbdkit-client(1)
π nbdkit-client β bestie's guide to mounting NBD filesystems π
okay so this is the nbdkit-client(1) page, and it's literally all about how to mount NBD filesystems on a client machine. no cap, it's giving "we have a filesystem in an NBD export and we need it on a physical machine" energy. let's go π¦
β¨ NAME β¨
nbdkit-client β how to mount NBD filesystems on a client machine
πΈ DESCRIPTION πΈ
so for NBD exports that contain filesystems, there are several approaches to mounting them on a physical machine. pick your fighter π
and for virtual machines? that's a whole separate vibe, see the section "ATTACHING NBD DEVICES TO A VIRTUAL MACHINE" at the end. π
π Easy mounting at boot time π
for simple setups, this is the easiest way to get an NBD filesystem to mount at boot. create or edit /etc/rc.local or /etc/rc.d/rc.local:
#!/bin/sh -
nm-online
modprobe nbd
nbd-client server /dev/nbd0
mount /dev/nbd0 /mnt
π«Ά Mounting using systemd mount points π«Ά
you can use systemd mount points to mount NBD filesystems at boot and/or on demand. it's giving "on demand, your honor" β¨
set up an nbdtab(5) mapping. if /etc/nbdtab doesn't exist, then create it first. add this line:
nbd0 server / bs=512,persist
β οΈ as a workaround for https://github.com/NetworkBlockDevice/nbd/issues/91 you must currently modify the nbd@.service file:
# cp /usr/lib/systemd/system/nbd@.service /etc/systemd/system/
# vi /etc/systemd/system/nbd@.service
and edit or create these settings in the "[Service]" section:
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/sbin/nbd-client %i
ExecStop=/usr/sbin/nbd-client -d /dev/%i
finally, create a systemd mount file called /etc/systemd/system/mnt.mount:
[Unit]
Requires=nbd@nbd0.service
[Mount]
What=/dev/nbd0
Where=/mnt
Type=ext4
you can either reboot now, or do:
# systemctl start mnt.mount
other systemd services which need this mount point can depend on this mount unit. bestie behavior, honestly. π
π LOADING THE LINUX KERNEL MODULE π
the native Linux NBD client is a kernel module called "nbd.ko". it is not always loaded on demand. to ensure it is loaded you may need to do:
# echo nbd > /etc/modules-load.d/nbd.conf
this will not take effect until you reboot, so to load it right away do:
# modprobe nbd
π RHEL and nbd.ko π
Red Hat Enterprise Linux 8 enabled the "nbd.ko" Linux kernel module but only for Unix domain sockets (ie. local connections). this means you cannot connect to an NBD server over a TCP network. this also affects Linux distributions derived from RHEL like CentOS, Alma and others. rip to the network girlies π
this does not affect use of nbdkit as an NBD server, only the Linux kernel as an NBD client. Userspace Linux clients such as libnbd(3) tools will work. slay. π
π§ ATTACHING NBD DEVICES TO A VIRTUAL MACHINE π§
notice in these cases that the virtual machine does not use the NBD protocol directly. instead, the virtual machine sees a local disk. thus there is no need to enable an NBD client or kernel module inside the virtual machine. behind the scenes the hypervisor (eg. Qemu) converts the local disk into an NBD connection. it's giving illusion, main character energy β¨
β Using libvirt XML β
use the virsh(1) "edit" subcommand to modify the libvirt XML of a virtual machine:
# virsh edit guest-name
the <disk> element should be placed in the <devices> section of the XML, after any other <disk> elements. for more information about libvirt XML see https://libvirt.org/formatdomain.html
for NBD devices served over a Unix domain socket (nbdkit -U option) add:
<disk device="disk" type="network">
<source protocol="nbd">
<host transport="unix" socket="/path/to/unix.sock"/>
</source>
<target dev="vdb" bus="virtio"/>
<driver name="qemu" type="raw"/>
</disk>
if using a TCP socket (nbdkit -p option):
<disk device="disk" type="network">
<source protocol="nbd">
<host name="localhost" port="10809"/>
</source>
<target dev="vdb" bus="virtio"/>
<driver name="qemu" type="raw"/>
</disk>
π Using qemu directly π
Qemu can open NBD URIs. to get nbdkit to show the URI it is serving use the --print-uri option.
for example:
$ nbdkit -f -U - --print-uri memory 1G
nbd+unix://?socket=/tmp/nbdkitTV6kS8/socket
Shell-quoted URI: "nbd+unix://?socket=/tmp/nbdkitTV6kS8/socket"
Command to query the NBD endpoint:
nbdinfo "nbd+unix://?socket=/tmp/nbdkitTV6kS8/socket"
$ qemu-system-x86_64 [...] \
-drive file="nbd+unix://?socket=/tmp/nbdkitTV6kS8/socket",format=raw,if=virtio
π₯ SEE ALSO π₯
nbdkit(1), nbdkit-loop(1), nbdkit-service(1), nbd-client(8), nbdtab(5), systemd(1), systemd.mount(5), virsh(1), https://libvirt.org/formatdomain.html.
π AUTHORS π
Richard W.M. Jones
πΈ COPYRIGHT πΈ
Copyright Red Hat
π LICENSE π
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
- Neither the name of Red Hat nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
and that's the whole page bestie!! πβ¨ this one's from nbdkit-1.48.1, dated 2026-08-29 β go mount something iconic π¦ππ
π¦ where this page comes from
- fedora 44: nbdkit-server 1.48.1-1.fc44 Β· BSD-3-Clause
- fedora 44: nbdkit-server 1.48.1-1.fc44 Β· BSD-3-Clause
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms