nbdkit-client1
How to mount nbd filesystems on a client machine
Overview
For NBD exports that contain filesystems there are several approaches to mounting them on a client machine.
To ensure the nbd kernel module is loaded you may need to do:
# echo nbd > /etc/modules-load.d/nbd.conf
This will not take effect until you reboot, so also do:
# modprobe nbd
Easy mounting at boot time
For simple setups the following method 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-onlinemodprobe nbdnbd-client server /dev/nbd0mount /dev/nbd0 /mnt
Mounting using systemd mount points
You can use systemd mount points to mount NBD filesystems at boot and/or on demand.
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 [email protected] file:
# cp /usr/lib/systemd/system/[email protected] /etc/systemd/system/# vi /etc/systemd/system/[email protected]
and edit or create these settings in the "[Service]" section:
[Service]Type=oneshotRemainAfterExit=yesExecStart=/usr/sbin/nbd-client %iExecStop=/usr/sbin/nbd-client -d /dev/%i
Finally create a systemd mount file called /etc/systemd/system/mnt.mount:
[Unit][email protected][Mount]What=/dev/nbd0Where=/mntType=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.
Limitations
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.
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.
Releases
3 releases since Debian 11 (Bullseye); the text changed 2 times.