xref: /linux/Documentation/admin-guide/device-mapper/dm-init.rst (revision 6cf2a73cb2bc422a03984b285a63632c27f8c4e4)
1*f0ba4377SMauro Carvalho Chehab================================
26bbc923dSHelen KoikeEarly creation of mapped devices
3*f0ba4377SMauro Carvalho Chehab================================
46bbc923dSHelen Koike
56bbc923dSHelen KoikeIt is possible to configure a device-mapper device to act as the root device for
66bbc923dSHelen Koikeyour system in two ways.
76bbc923dSHelen Koike
86bbc923dSHelen KoikeThe first is to build an initial ramdisk which boots to a minimal userspace
96bbc923dSHelen Koikewhich configures the device, then pivot_root(8) in to it.
106bbc923dSHelen Koike
116bbc923dSHelen KoikeThe second is to create one or more device-mappers using the module parameter
126bbc923dSHelen Koike"dm-mod.create=" through the kernel boot command line argument.
136bbc923dSHelen Koike
146bbc923dSHelen KoikeThe format is specified as a string of data separated by commas and optionally
156bbc923dSHelen Koikesemi-colons, where:
16*f0ba4377SMauro Carvalho Chehab
176bbc923dSHelen Koike - a comma is used to separate fields like name, uuid, flags and table
186bbc923dSHelen Koike   (specifies one device)
196bbc923dSHelen Koike - a semi-colon is used to separate devices.
206bbc923dSHelen Koike
21*f0ba4377SMauro Carvalho ChehabSo the format will look like this::
226bbc923dSHelen Koike
236bbc923dSHelen Koike dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
246bbc923dSHelen Koike
25*f0ba4377SMauro Carvalho ChehabWhere::
26*f0ba4377SMauro Carvalho Chehab
276bbc923dSHelen Koike	<name>		::= The device name.
286bbc923dSHelen Koike	<uuid>		::= xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ""
296bbc923dSHelen Koike	<minor>		::= The device minor number | ""
306bbc923dSHelen Koike	<flags>		::= "ro" | "rw"
316bbc923dSHelen Koike	<table>		::= <start_sector> <num_sectors> <target_type> <target_args>
326bbc923dSHelen Koike	<target_type>	::= "verity" | "linear" | ... (see list below)
336bbc923dSHelen Koike
346bbc923dSHelen KoikeThe dm line should be equivalent to the one used by the dmsetup tool with the
35*f0ba4377SMauro Carvalho Chehab`--concise` argument.
366bbc923dSHelen Koike
376bbc923dSHelen KoikeTarget types
386bbc923dSHelen Koike============
396bbc923dSHelen Koike
406bbc923dSHelen KoikeNot all target types are available as there are serious risks in allowing
416bbc923dSHelen Koikeactivation of certain DM targets without first using userspace tools to check
426bbc923dSHelen Koikethe validity of associated metadata.
436bbc923dSHelen Koike
44*f0ba4377SMauro Carvalho Chehab======================= =======================================================
45*f0ba4377SMauro Carvalho Chehab`cache`			constrained, userspace should verify cache device
46*f0ba4377SMauro Carvalho Chehab`crypt`			allowed
47*f0ba4377SMauro Carvalho Chehab`delay`			allowed
48*f0ba4377SMauro Carvalho Chehab`era`			constrained, userspace should verify metadata device
49*f0ba4377SMauro Carvalho Chehab`flakey`		constrained, meant for test
50*f0ba4377SMauro Carvalho Chehab`linear`		allowed
51*f0ba4377SMauro Carvalho Chehab`log-writes`		constrained, userspace should verify metadata device
52*f0ba4377SMauro Carvalho Chehab`mirror`		constrained, userspace should verify main/mirror device
53*f0ba4377SMauro Carvalho Chehab`raid`			constrained, userspace should verify metadata device
54*f0ba4377SMauro Carvalho Chehab`snapshot`		constrained, userspace should verify src/dst device
55*f0ba4377SMauro Carvalho Chehab`snapshot-origin`	allowed
56*f0ba4377SMauro Carvalho Chehab`snapshot-merge`	constrained, userspace should verify src/dst device
57*f0ba4377SMauro Carvalho Chehab`striped`		allowed
58*f0ba4377SMauro Carvalho Chehab`switch`		constrained, userspace should verify dev path
59*f0ba4377SMauro Carvalho Chehab`thin`			constrained, requires dm target message from userspace
60*f0ba4377SMauro Carvalho Chehab`thin-pool`		constrained, requires dm target message from userspace
61*f0ba4377SMauro Carvalho Chehab`verity`		allowed
62*f0ba4377SMauro Carvalho Chehab`writecache`		constrained, userspace should verify cache device
63*f0ba4377SMauro Carvalho Chehab`zero`			constrained, not meant for rootfs
64*f0ba4377SMauro Carvalho Chehab======================= =======================================================
656bbc923dSHelen Koike
666bbc923dSHelen KoikeIf the target is not listed above, it is constrained by default (not tested).
676bbc923dSHelen Koike
686bbc923dSHelen KoikeExamples
696bbc923dSHelen Koike========
706bbc923dSHelen KoikeAn example of booting to a linear array made up of user-mode linux block
71*f0ba4377SMauro Carvalho Chehabdevices::
726bbc923dSHelen Koike
736bbc923dSHelen Koike  dm-mod.create="lroot,,,rw, 0 4096 linear 98:16 0, 4096 4096 linear 98:32 0" root=/dev/dm-0
746bbc923dSHelen Koike
756bbc923dSHelen KoikeThis will boot to a rw dm-linear target of 8192 sectors split across two block
766bbc923dSHelen Koikedevices identified by their major:minor numbers.  After boot, udev will rename
776bbc923dSHelen Koikethis target to /dev/mapper/lroot (depending on the rules). No uuid was assigned.
786bbc923dSHelen Koike
79*f0ba4377SMauro Carvalho ChehabAn example of multiple device-mappers, with the dm-mod.create="..." contents
80*f0ba4377SMauro Carvalho Chehabis shown here split on multiple lines for readability::
816bbc923dSHelen Koike
824241d516SHelen Koike  dm-linear,,1,rw,
834241d516SHelen Koike    0 32768 linear 8:1 0,
844241d516SHelen Koike    32768 1024000 linear 8:2 0;
854241d516SHelen Koike  dm-verity,,3,ro,
864241d516SHelen Koike    0 1638400 verity 1 /dev/sdc1 /dev/sdc2 4096 4096 204800 1 sha256
874241d516SHelen Koike    ac87db56303c9c1da433d7209b5a6ef3e4779df141200cbd7c157dcb8dd89c42
884241d516SHelen Koike    5ebfe87f7df3235b80a117ebc4078e44f55045487ad4a96581d1adb564615b51
896bbc923dSHelen Koike
906bbc923dSHelen KoikeOther examples (per target):
916bbc923dSHelen Koike
92*f0ba4377SMauro Carvalho Chehab"crypt"::
93*f0ba4377SMauro Carvalho Chehab
946bbc923dSHelen Koike  dm-crypt,,8,ro,
956bbc923dSHelen Koike    0 1048576 crypt aes-xts-plain64
966bbc923dSHelen Koike    babebabebabebabebabebabebabebabebabebabebabebabebabebabebabebabe 0
976bbc923dSHelen Koike    /dev/sda 0 1 allow_discards
986bbc923dSHelen Koike
99*f0ba4377SMauro Carvalho Chehab"delay"::
100*f0ba4377SMauro Carvalho Chehab
1016bbc923dSHelen Koike  dm-delay,,4,ro,0 409600 delay /dev/sda1 0 500
1026bbc923dSHelen Koike
103*f0ba4377SMauro Carvalho Chehab"linear"::
104*f0ba4377SMauro Carvalho Chehab
1056bbc923dSHelen Koike  dm-linear,,,rw,
1066bbc923dSHelen Koike    0 32768 linear /dev/sda1 0,
1076bbc923dSHelen Koike    32768 1024000 linear /dev/sda2 0,
1086bbc923dSHelen Koike    1056768 204800 linear /dev/sda3 0,
1096bbc923dSHelen Koike    1261568 512000 linear /dev/sda4 0
1106bbc923dSHelen Koike
111*f0ba4377SMauro Carvalho Chehab"snapshot-origin"::
112*f0ba4377SMauro Carvalho Chehab
1136bbc923dSHelen Koike  dm-snap-orig,,4,ro,0 409600 snapshot-origin 8:2
1146bbc923dSHelen Koike
115*f0ba4377SMauro Carvalho Chehab"striped"::
116*f0ba4377SMauro Carvalho Chehab
1176bbc923dSHelen Koike  dm-striped,,4,ro,0 1638400 striped 4 4096
1186bbc923dSHelen Koike  /dev/sda1 0 /dev/sda2 0 /dev/sda3 0 /dev/sda4 0
1196bbc923dSHelen Koike
120*f0ba4377SMauro Carvalho Chehab"verity"::
121*f0ba4377SMauro Carvalho Chehab
1226bbc923dSHelen Koike  dm-verity,,4,ro,
1236bbc923dSHelen Koike    0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256
1246bbc923dSHelen Koike    fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd
1256bbc923dSHelen Koike    51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584
126