1nbdkit-client(1) NBDKIT nbdkit-client(1)
2
3
4
6 nbdkit-service - 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 nbdkit(1), nbdkit-loop(1), nbdkit-service(1), nbd-client(8), nbdtab(5),
73 systemd(1), systemd.mount(5).
74
76 Richard W.M. Jones
77
79 Copyright (C) 2013-2020 Red Hat Inc.
80
82 Redistribution and use in source and binary forms, with or without
83 modification, are permitted provided that the following conditions are
84 met:
85
86 · Redistributions of source code must retain the above copyright
87 notice, this list of conditions and the following disclaimer.
88
89 · Redistributions in binary form must reproduce the above copyright
90 notice, this list of conditions and the following disclaimer in the
91 documentation and/or other materials provided with the
92 distribution.
93
94 · Neither the name of Red Hat nor the names of its contributors may
95 be used to endorse or promote products derived from this software
96 without specific prior written permission.
97
98 THIS SOFTWARE IS PROVIDED BY RED HAT AND CONTRIBUTORS ''AS IS'' AND ANY
99 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
100 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
101 PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL RED HAT OR CONTRIBUTORS BE
102 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
103 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
104 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
105 BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
106 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
107 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
108 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
109
110
111
112nbdkit-1.24.2 2021-03-02 nbdkit-client(1)