1.\" $NetBSD: dm.4,v 1.7 2015/05/04 06:14:47 pgoyette Exp $ 2.\" 3.\" Copyright (c) 1996, 1997 The NetBSD Foundation, Inc. 4.\" All rights reserved. 5.\" 6.\" This code is derived from software contributed to The NetBSD Foundation 7.\" by Adam Hamsik 8.\" 9.\" Redistribution and use in source and binary forms, with or without 10.\" modification, are permitted provided that the following conditions 11.\" are met: 12.\" 1. Redistributions of source code must retain the above copyright 13.\" notice, this list of conditions and the following disclaimer. 14.\" 2. Redistributions in binary form must reproduce the above copyright 15.\" notice, this list of conditions and the following disclaimer in the 16.\" documentation and/or other materials provided with the distribution. 17.\" 18.\" THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS 19.\" ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED 20.\" TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21.\" PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS 22.\" BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23.\" CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24.\" SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25.\" INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26.\" CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28.\" POSSIBILITY OF SUCH DAMAGE. 29.Dd April 4, 2015 30.Dt DM 4 31.Os 32.Sh NAME 33.Nm dm 34.Nd Device-mapper disk driver 35.Sh SYNOPSIS 36.Cd "pseudo-device dm" 37.Sh DESCRIPTION 38The 39.Nm 40driver provides the capability of creating one or more virtual disks 41based on the target mapping. 42.Pp 43This document assumes that you're familiar with how to generate 44kernels, how to properly configure disks and pseudo-devices in a 45kernel configuration file, and how to partition disks. 46This driver is used by the Linux lvm2tools to create and manage 47lvm in 48.Nx . 49.Pp 50Currently, the 51.Pa linear , zero , 52and 53.Pa error 54targets are implemented. 55Each component partition should be offset at least 2 sectors 56from the beginning of the component disk. 57This avoids potential conflicts between the component disk's 58disklabel and 59.Nm Ap s 60disklabel. 61In i386 it is offset by 65 sectors, where 63 sectors are the initial 62boot sectors and 2 sectors are used for the disklabel which is set 63to be read-only. 64.Pp 65In order to compile in support for 66.Nm , 67you must add a line similar to the following to your kernel 68configuration file: 69.Bd -unfilled -offset indent 70pseudo-device dm #device-mapper disk device 71.Ed 72.Pp 73.Nm 74may create linear mapped devices, zero, and error block devices. 75Zero and error block devices are used mostly for testing. 76.Pa Linear 77devices are used to create virtual disks with linearly mapped virtual 78blocks to blocks on real disk. 79.Nm 80Device-mapper devices are controlled through the 81.Pa /dev/mapper/control 82device. 83For controlling this device 84.Xr ioctl 2 85calls are used. 86For the implementation of the communication channel, 87the 88.Xr proplib 3 89library is used. 90The protocol channel is defined as a proplib dictionary with needed 91values. 92For more details, look at 93.Pa sys/dev/dm/netbsd-dm.h . 94Before any device can be used, every device-mapper disk device must 95be initialized. 96For initialization one line must be passed to the kernel driver in 97the form of a proplib dictionary. 98Every device can have more than one table active. 99An example for such a line is: 100.Bd -unfilled -offset indent 1010 10240 linear /dev/wd1a 384 102.Ed 103.Pp 104The first parameter is the start sector for the table defined with 105this line, the second is the length in sectors which is described 106with this table. 107The third parameter is the target name. 108All other parts of this line depend on the chosen target. 109.Pp 110For the linear target, there are two additional parameters: 111The fourth parameter describes the disk device to which the 112device-mapper disk is mapped. 113The fifth parameter is the offset on this disk from the start of 114the disk/partition. 115.Sh SEE ALSO 116.Xr config 1 , 117.Xr proplib 3 , 118.Xr dmsetup 8 , 119.Xr fsck 8 , 120.Xr lvm 8 , 121.Xr MAKEDEV 8 , 122.Xr mount 8 , 123.Xr newfs 8 124.Sh HISTORY 125The device-mapper disk driver first appeared in 126.Nx 6.0 . 127.Sh AUTHORS 128.An Adam Hamsik Aq Mt haad@NetBSD.org 129implemented the device-mapper driver for 130.Nx . 131.Pp 132.An Brett Lymn Aq Mt blymn@NetBSD.org , 133.An Reinoud Zandijk Aq Mt reinoud@NetBSD.org , 134and 135.An Bill Stouder-Studenmund Aq Mt wrstuden@NetBSD.org 136provided guidance and answered questions about the 137.Nx 138implementation. 139.Sh BUGS 140This driver is still a work-in-progress \(em there can be bugs. 141