1.\" $NetBSD: dkctl.8,v 1.29 2020/03/30 08:36:09 wiz Exp $ 2.\" 3.\" Copyright 2002 Wasabi Systems, Inc. 4.\" All rights reserved. 5.\" 6.\" Written by Jason R. Thorpe for Wasabi Systems, Inc. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. All advertising materials mentioning features or use of this software 17.\" must display the following acknowledgement: 18.\" This product includes software developed for the NetBSD Project by 19.\" Wasabi Systems, Inc. 20.\" 4. The name of Wasabi Systems, Inc. may not be used to endorse 21.\" or promote products derived from this software without specific prior 22.\" written permission. 23.\" 24.\" THIS SOFTWARE IS PROVIDED BY WASABI SYSTEMS, INC. ``AS IS'' AND 25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 26.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 27.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL WASABI SYSTEMS, INC 28.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 29.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 30.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 31.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 32.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 33.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 34.\" POSSIBILITY OF SUCH DAMAGE. 35.\" 36.Dd March 29, 2020 37.Dt DKCTL 8 38.Os 39.Sh NAME 40.Nm dkctl 41.Nd program to manipulate disks 42.Sh SYNOPSIS 43.Nm 44.Ar device 45.Nm 46.Ar device 47.Ar command 48.Op Ar arg Op ... 49.Sh DESCRIPTION 50.Nm 51allows a user or system administrator to manipulate and configure disks 52in various ways. 53It is used by specifying a disk to manipulate, the command 54to perform, and any arguments the command may require. 55.Ar device 56is the disk (wdN, sdN, ...) containing the wedges unless noted otherwise. 57If 58.Nm 59is called without any command, it displays strategy, cache, and all of 60the wedges of the specified device. 61.Sh COMMANDS 62The following commands are supported: 63.Bl -tag -width XXstrategyXXnameXX 64.It Ic addwedge Ar name Ar startblk Ar blkcnt Ar ptype 65Define a 66.Dq wedge 67on the specified disk starting at block number 68.Ar startblk 69and spanning 70.Ar blkcnt 71blocks. 72You need to create the partition first with 73.Xr fdisk 8 74or 75.Xr gpt 8 , 76.Nm 77will just name it. 78The wedge will have the volume name 79.Ar name 80and the partition type 81.Ar ptype . 82Valid choices for ptype would be 83.Ar unused , 84.Ar swap , 85.Ar ffs , 86.Ar lfs , 87.Ar ext2fs , 88.Ar cd9660 , 89.Ar ados , 90.Ar hfs , 91.Ar msdos , 92.Ar filecore , 93.Ar raidframe , 94.Ar ccd , 95.Ar appleufs , 96.Ar ntfs , 97.Ar cgd , 98and 99.Ar zfs . 100.Pp 101The device name of the virtual block device assigned to the wedge will be 102displayed after the wedge has been successfully created. 103See 104.Xr dk 4 105for more information about disk wedges. 106.It Ic badsector Ar flush | list | retry 107Used for managing the kernel's bad sector list for 108.Xr wd 4 109devices. 110The software bad sector list is only maintained if the option 111.Dq WD_SOFTBADSECT 112was specified on kernel configuration. 113.Bl -tag -width XflushXX -offset indent 114.It flush 115Clears the in kernel list of bad sectors. 116.It list 117Prints out the list of bad sector ranges recorded by the kernel. 118.It retry 119Flushes the in kernel list and then retries all of the previously recorded 120bad sectors, causing the list to self update. 121This option 122.Em can only 123be used with character devices. 124.El 125.It Ic delwedge Ar dk 126Delete the wedge specified by its device name 127.Ar dk 128from the specified disk. 129.It Ic getcache 130Get and display the cache enables for the specified device. 131.It Ic getwedgeinfo 132Display information about the specified disk wedge. 133.Ar device 134in this case is the wedge name. 135.It Ic keeplabel Op Ar yes | no 136Specify to keep or drop the in-core disklabel on the last close of 137the disk device. 138(Keep if 139.Ar yes 140is specified, drop if 141.Ar no 142is specified.) 143.It Ic listwedges Oo Fl e Oc Op Fl q 144List all of the wedges configured on the specified disk. 145With 146.Fl e 147exit with a non-zero exit status if there are no wedges 148configured on that disk. 149With 150.Fl q 151(quiet mode) 152there is no output related to the wedges that do, or do not, exist. 153.It Ic makewedges 154Delete all wedges configured on the specified disk, and autodiscover 155the wedges again. 156Wedges that are in use are not deleted and conflicting 157or overlapping wedges are not created. 158You need to list wedges to find out what has changed. 159.It Ic setcache Ar none | r | w | rw Op Ar save 160Set the cache enables for the specified device. 161The enables are as follows: 162.Bl -tag -offset indent -width XsaveX 163.It none 164Disable all caches on the disk. 165.It r 166Enable the read cache, and disable all other caches on the disk. 167.It w 168Enable the write cache, and disable all other caches on the disk. 169.It rw 170Enable both the read and write caches on the disk. 171.It save 172If specified, and the cache enables are savable, saves the cache 173enables in the disk's non-volatile parameter storage. 174.El 175.It Ic strategy Op Ar name 176Get and set the disk I/O scheduler (buffer queue strategy) on the 177drive. 178If you do not provide a 179.Ar name 180argument, the currently selected strategy will be shown. 181To set the bufq strategy, the 182.Ar name 183argument must be specified. 184.Ar name 185must be the name of one of the built-in kernel disk I/O schedulers. 186To get the list of supported schedulers, use the following command: 187.Bd -literal -offset indent 188$ sysctl kern.bufq.strategies 189.Ed 190.It Ic synccache Op Ar force 191Causes the cache on the disk to be synchronized, flushing all dirty 192write cache blocks to the media. 193If 194.Ar force 195is specified, the cache synchronization command will be issued even 196if the kernel does not believe that there are any dirty cache blocks 197in the disk's cache. 198.El 199.Pp 200Note: The 201.Ic addwedge 202and 203.Ic delwedge 204commands only modify the in-kernel representation of disks; for 205modifying information on the disks themselves, refer to 206.Xr fdisk 8 207or 208.Xr gpt 8 . 209.Sh SEE ALSO 210.Xr ioctl 2 , 211.Xr dk 4 , 212.Xr sd 4 , 213.Xr wd 4 , 214.Xr disklabel 5 , 215.Xr atactl 8 , 216.Xr fdisk 8 , 217.Xr gpt 8 , 218.Xr scsictl 8 219.Sh HISTORY 220The 221.Nm 222command first appeared in 223.Nx 1.6 . 224.Sh AUTHORS 225The 226.Nm 227command was written by 228.An Jason R. Thorpe 229of Wasabi Systems, Inc. 230