1nbdkit-client(1) NBDKIT nbdkit-client(1)
2
3
4
6 nbdkit-client - how to mount NBD filesystems on a client machine
7
9 For NBD exports that contain filesystems there are several approaches
10 to mounting them on a client machine.
11
12 To ensure the nbd kernel module is loaded you may need to do:
13
14 # echo nbd > /etc/modules-load.d/nbd.conf
15
16 This will not take effect until you reboot, so also do:
17
18 # modprobe nbd
19
20 Easy mounting at boot time
21 For simple setups the following method is the easiest way to get an NBD
22 filesystem to mount at boot. Create or edit /etc/rc.local or
23 /etc/rc.d/rc.local:
24
25 #!/bin/sh -
26 nm-online
27 modprobe nbd
28 nbd-client server /dev/nbd0
29 mount /dev/nbd0 /mnt
30
31 Mounting using systemd mount points
32 You can use systemd mount points to mount NBD filesystems at boot
33 and/or on demand.
34
35 Set up an nbdtab(5) mapping. If /etc/nbdtab doesn't exist, then create
36 it first. Add this line:
37
38 nbd0 server / bs=512,persist
39
40 As a workaround for https://github.com/NetworkBlockDevice/nbd/issues/91
41 you must currently modify the nbd@.service file:
42
43 # cp /usr/lib/systemd/system/nbd@.service /etc/systemd/system/
44 # vi /etc/systemd/system/nbd@.service
45
46 and edit or create these settings in the "[Service]" section:
47
48 [Service]
49 Type=oneshot
50 RemainAfterExit=yes
51 ExecStart=/usr/sbin/nbd-client %i
52 ExecStop=/usr/sbin/nbd-client -d /dev/%i
53
54 Finally create a systemd mount file called
55 /etc/systemd/system/mnt.mount:
56
57 [Unit]
58 Requires=nbd@nbd0.service
59 [Mount]
60 What=/dev/nbd0
61 Where=/mnt
62 Type=ext4
63
64 You can either reboot now or do:
65
66 # systemctl start mnt.mount
67
68 Other systemd services which need this mount point can depend on this
69 mount unit.
70
72 Red Hat Enterprise Linux 8 enabled the "nbd.ko" Linux kernel module but
73 only for Unix domain sockets (ie. local connections). This means you
74 cannot connect to an NBD server over a TCP network. This also affects
75 Linux distributions derived from RHEL like CentOS, Alma and others.
76
77 This does not affect use of nbdkit as an NBD server, only the Linux
78 kernel as an NBD client. Userspace Linux clients such as libnbd(3)
79 tools will work.
80
82 nbdkit(1), nbdkit-loop(1), nbdkit-service(1), nbd-client(8), nbdtab(5),
83 systemd(1), systemd.mount(5).
84
86 Richard W.M. Jones
87
89 Copyright Red Hat
90
92 Redistribution and use in source and binary forms, with or without
93 modification, are permitted provided that the following conditions are
94 met:
95
96 • Redistributions of source code must retain the above copyright
97 notice, this list of conditions and the following disclaimer.
98
99 • Redistributions in binary form must reproduce the above copyright
100 notice, this list of conditions and the following disclaimer in the
101 documentation and/or other materials provided with the
102 distribution.
103
104 • Neither the name of Red Hat nor the names of its contributors may
105 be used to endorse or promote products derived from this software
106 without specific prior written permission.
107
108 THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY
109 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
110 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
111 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE
112 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
113 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
114 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
115 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
116 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
117 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
118 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
119
120
121
122nbdkit-1.36.2 2023-11-26 nbdkit-client(1)