1nbdsh(1)                            LIBNBD                            nbdsh(1)
2
3
4

NAME

6       nbdsh - network block device (NBD) shell
7

SYNOPSIS

9        $ nbdsh
10
11        Welcome to nbdsh, the shell for interacting with
12        Network Block Device (NBD) servers.
13
14        The ‘nbd’ module has already been imported and there
15        is an open NBD handle called ‘h’.
16
17        nbd> h.connect_command (["nbdkit", "-s", "memory", "1G"])
18        nbd> h.get_size ()
19        1073741824
20        nbd> buf = b"hello, world"
21        nbd> h.pwrite (buf, 0, 0)
22        nbd> exit()
23

DESCRIPTION

25       nbdsh is a Python-based client shell for accessing Network Block Device
26       (NBD) servers.
27
28       For documentation about the libnbd API please open the shell and type:
29
30        help (nbd)
31

EXAMPLES

33   Print the size of an NBD export
34       The -u option connects to an NBD URI.  The -c option lets you execute
35       single Python statements from the command line.  Combining these two
36       options lets you print the size in bytes of an NBD export:
37
38        $ nbdsh -u nbd://localhost -c 'print (h.get_size ())'
39        1073741824
40
41   Hexdump the boot sector of an NBD export
42       Using -c - you can feed a whole Python program to the standard input of
43       nbdsh:
44
45        nbdsh -c - <<'EOF'
46        from subprocess import *
47
48        h.connect_uri ("nbd://localhost")
49        bootsect = h.pread (512, 0)
50        p = Popen ("hexdump -C", shell=True, stdin=PIPE)
51        p.stdin.write (bootsect)
52        EOF
53

OPTIONS

55       -h
56       --help
57           Display brief command line help and exit.
58
59       --base-allocation
60           Request the use of the "base:allocation" meta context, which is the
61           most common context used with nbd_block_status(3).  This is
62           equivalent to calling
63           "h.set_meta_context (nbd.CONTEXT_BASE_ALLOCATION)" in the shell
64           prior to connecting.
65
66       -c 'COMMAND ...'
67       --command 'COMMAND ...'
68           Instead of starting an interactive shell, run a command.  This
69           option can be specified multiple times in order to run multiple
70           commands.
71
72       -c -
73       --command -
74           Read standard input and execute it as a command.
75
76       -u URI
77       -uri URI
78       --connect URI
79           Connect to the given NBD URI.  This is equivalent to the
80           "h.connect_uri (URI)" command in the shell.
81
82       -V
83       --version
84           Display the package name and version and exit.
85

SEE ALSO

87       libnbd(3), libnbd-security(3), nbdfuse(1), qemu-img(1).
88

AUTHORS

90       Richard W.M. Jones
91
93       Copyright (C) 2019 Red Hat Inc.
94

LICENSE

96       This library is free software; you can redistribute it and/or modify it
97       under the terms of the GNU Lesser General Public License as published
98       by the Free Software Foundation; either version 2 of the License, or
99       (at your option) any later version.
100
101       This library is distributed in the hope that it will be useful, but
102       WITHOUT ANY WARRANTY; without even the implied warranty of
103       MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
104       Lesser General Public License for more details.
105
106       You should have received a copy of the GNU Lesser General Public
107       License along with this library; if not, write to the Free Software
108       Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
109       02110-1301 USA
110
111
112
113libnbd-1.3.7                      2020-04-23                          nbdsh(1)
Impressum