=head1 NAME

nbddiscard, nbdzero - discard or zero all data on a Network Block Device

=head1 SYNOPSIS

 nbddiscard [-c|--check] [-z|--zero] [--fast-zero]
            [-q|--quiet] [-v|--verbose] [-y|--yes]
            [-o|--offset OFFSET] [-l|--length LENGTH] NBD-URI

 nbddiscard -V|--version

 nbddiscard -h|--help

=for paragraph

 nbdzero [-c|--check] [--fast-zero]
         [-q|--quiet] [-v|--verbose] [-y|--yes]
         [-o|--offset OFFSET] [-l|--length LENGTH] NBD-URI

 nbdzero -V|--version

 nbdzero -h|--help

=head1 DESCRIPTION

nbddiscard discards all data on a Network Block Device (NBD) endpoint.
If supported, this frees up the backing storage and makes the device
completely sparse.  For example, if an NBD server is running locally
on port 10809 you could do:

 $ nbddiscard nbd://localhost
 PERMANENTLY ERASE everything on nbd://localhost bytes 0 - 1073741823
 (y/N)? y

nbdzero is the same, but the data is replaced by allocated, zeroed
blocks.

B<All data in the discarded or zeroed region is PERMANENTLY ERASED.>

For information about NBD URIs, see L<nbd_connect_uri(3)>.

=head1 OPTIONS

=over 4

=item B<-c>

=item B<--check>

Rather than modify the disk, merely check whether it is already sparse,
or with I<-z> that it already reads as zero.

=item B<--fast-zero>

Attempt fast zero (see L<nbd_can_fast_zero(3)>), which implies
I<--zero>.

Not all servers support the fast zero flag, but those that do promise
that an attempted fast zero operation will either complete more
quickly than explicitly writing zeroes to the image, or that it will
immediately fail because the operation is not inherently faster.

=item B<-h>

=item B<--help>

Display brief command line help and exit.

=item B<-l> LENGTH

=item B<--length> LENGTH

Instead of discarding to the end of the disk, discard only length
bytes.  You can use the normal suffixes like C<K>, C<M> etc.

=item B<-o> OFFSET

=item B<--offset> OFFSET

Instead of starting from the beginning of the disk, start at the given
offset.  You can use the normal suffixes like C<K>, C<M> etc.

=item B<-q>

=item B<--quiet>

Quiet mode, do not print any warnings.

=item B<-v>

=item B<--verbose>

Enable verbose libnbd messages.  This has the same effect as setting
the environment variable C<LIBNBD_DEBUG=1>

=item B<-V>

=item B<--version>

Display the package name and version and exit.

=item B<-y>

=item B<--yes>

Assume yes to all questions.  This will proceed straight to erasing
your data.  Use this in scripts to avoid interactivity.

=item B<-z>

=item B<--zero>

Zero, instead of discarding.  nbdzero is just nbddiscard with I<-z>.

=back

=head1 SEE ALSO

L<libnbd(3)>,
L<libnbd-python(3)>,
L<nbd_connect_uri(3)>,
L<nbdcopy(1)>,
L<nbddump(1)>,
L<nbdfuse(1)>,
L<nbdinfo(1)>,
L<nbdsh(1)>,
L<nbdublk(1)>,
L<blkdiscard(8)>,
L<qemu-img(1)>.

=head1 AUTHORS

Richard W.M. Jones

=head1 COPYRIGHT

Copyright Red Hat
