xref: /OK3568_Linux_fs/kernel/Documentation/admin-guide/device-mapper/dm-init.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun================================
2*4882a593SmuzhiyunEarly creation of mapped devices
3*4882a593Smuzhiyun================================
4*4882a593Smuzhiyun
5*4882a593SmuzhiyunIt is possible to configure a device-mapper device to act as the root device for
6*4882a593Smuzhiyunyour system in two ways.
7*4882a593Smuzhiyun
8*4882a593SmuzhiyunThe first is to build an initial ramdisk which boots to a minimal userspace
9*4882a593Smuzhiyunwhich configures the device, then pivot_root(8) in to it.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunThe second is to create one or more device-mappers using the module parameter
12*4882a593Smuzhiyun"dm-mod.create=" through the kernel boot command line argument.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunThe format is specified as a string of data separated by commas and optionally
15*4882a593Smuzhiyunsemi-colons, where:
16*4882a593Smuzhiyun
17*4882a593Smuzhiyun - a comma is used to separate fields like name, uuid, flags and table
18*4882a593Smuzhiyun   (specifies one device)
19*4882a593Smuzhiyun - a semi-colon is used to separate devices.
20*4882a593Smuzhiyun
21*4882a593SmuzhiyunSo the format will look like this::
22*4882a593Smuzhiyun
23*4882a593Smuzhiyun dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunWhere::
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun	<name>		::= The device name.
28*4882a593Smuzhiyun	<uuid>		::= xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ""
29*4882a593Smuzhiyun	<minor>		::= The device minor number | ""
30*4882a593Smuzhiyun	<flags>		::= "ro" | "rw"
31*4882a593Smuzhiyun	<table>		::= <start_sector> <num_sectors> <target_type> <target_args>
32*4882a593Smuzhiyun	<target_type>	::= "verity" | "linear" | ... (see list below)
33*4882a593Smuzhiyun
34*4882a593SmuzhiyunThe dm line should be equivalent to the one used by the dmsetup tool with the
35*4882a593Smuzhiyun`--concise` argument.
36*4882a593Smuzhiyun
37*4882a593SmuzhiyunTarget types
38*4882a593Smuzhiyun============
39*4882a593Smuzhiyun
40*4882a593SmuzhiyunNot all target types are available as there are serious risks in allowing
41*4882a593Smuzhiyunactivation of certain DM targets without first using userspace tools to check
42*4882a593Smuzhiyunthe validity of associated metadata.
43*4882a593Smuzhiyun
44*4882a593Smuzhiyun======================= =======================================================
45*4882a593Smuzhiyun`cache`			constrained, userspace should verify cache device
46*4882a593Smuzhiyun`crypt`			allowed
47*4882a593Smuzhiyun`delay`			allowed
48*4882a593Smuzhiyun`era`			constrained, userspace should verify metadata device
49*4882a593Smuzhiyun`flakey`		constrained, meant for test
50*4882a593Smuzhiyun`linear`		allowed
51*4882a593Smuzhiyun`log-writes`		constrained, userspace should verify metadata device
52*4882a593Smuzhiyun`mirror`		constrained, userspace should verify main/mirror device
53*4882a593Smuzhiyun`raid`			constrained, userspace should verify metadata device
54*4882a593Smuzhiyun`snapshot`		constrained, userspace should verify src/dst device
55*4882a593Smuzhiyun`snapshot-origin`	allowed
56*4882a593Smuzhiyun`snapshot-merge`	constrained, userspace should verify src/dst device
57*4882a593Smuzhiyun`striped`		allowed
58*4882a593Smuzhiyun`switch`		constrained, userspace should verify dev path
59*4882a593Smuzhiyun`thin`			constrained, requires dm target message from userspace
60*4882a593Smuzhiyun`thin-pool`		constrained, requires dm target message from userspace
61*4882a593Smuzhiyun`verity`		allowed
62*4882a593Smuzhiyun`writecache`		constrained, userspace should verify cache device
63*4882a593Smuzhiyun`zero`			constrained, not meant for rootfs
64*4882a593Smuzhiyun======================= =======================================================
65*4882a593Smuzhiyun
66*4882a593SmuzhiyunIf the target is not listed above, it is constrained by default (not tested).
67*4882a593Smuzhiyun
68*4882a593SmuzhiyunExamples
69*4882a593Smuzhiyun========
70*4882a593SmuzhiyunAn example of booting to a linear array made up of user-mode linux block
71*4882a593Smuzhiyundevices::
72*4882a593Smuzhiyun
73*4882a593Smuzhiyun  dm-mod.create="lroot,,,rw, 0 4096 linear 98:16 0, 4096 4096 linear 98:32 0" root=/dev/dm-0
74*4882a593Smuzhiyun
75*4882a593SmuzhiyunThis will boot to a rw dm-linear target of 8192 sectors split across two block
76*4882a593Smuzhiyundevices identified by their major:minor numbers.  After boot, udev will rename
77*4882a593Smuzhiyunthis target to /dev/mapper/lroot (depending on the rules). No uuid was assigned.
78*4882a593Smuzhiyun
79*4882a593SmuzhiyunAn example of multiple device-mappers, with the dm-mod.create="..." contents
80*4882a593Smuzhiyunis shown here split on multiple lines for readability::
81*4882a593Smuzhiyun
82*4882a593Smuzhiyun  dm-linear,,1,rw,
83*4882a593Smuzhiyun    0 32768 linear 8:1 0,
84*4882a593Smuzhiyun    32768 1024000 linear 8:2 0;
85*4882a593Smuzhiyun  dm-verity,,3,ro,
86*4882a593Smuzhiyun    0 1638400 verity 1 /dev/sdc1 /dev/sdc2 4096 4096 204800 1 sha256
87*4882a593Smuzhiyun    ac87db56303c9c1da433d7209b5a6ef3e4779df141200cbd7c157dcb8dd89c42
88*4882a593Smuzhiyun    5ebfe87f7df3235b80a117ebc4078e44f55045487ad4a96581d1adb564615b51
89*4882a593Smuzhiyun
90*4882a593SmuzhiyunOther examples (per target):
91*4882a593Smuzhiyun
92*4882a593Smuzhiyun"crypt"::
93*4882a593Smuzhiyun
94*4882a593Smuzhiyun  dm-crypt,,8,ro,
95*4882a593Smuzhiyun    0 1048576 crypt aes-xts-plain64
96*4882a593Smuzhiyun    babebabebabebabebabebabebabebabebabebabebabebabebabebabebabebabe 0
97*4882a593Smuzhiyun    /dev/sda 0 1 allow_discards
98*4882a593Smuzhiyun
99*4882a593Smuzhiyun"delay"::
100*4882a593Smuzhiyun
101*4882a593Smuzhiyun  dm-delay,,4,ro,0 409600 delay /dev/sda1 0 500
102*4882a593Smuzhiyun
103*4882a593Smuzhiyun"linear"::
104*4882a593Smuzhiyun
105*4882a593Smuzhiyun  dm-linear,,,rw,
106*4882a593Smuzhiyun    0 32768 linear /dev/sda1 0,
107*4882a593Smuzhiyun    32768 1024000 linear /dev/sda2 0,
108*4882a593Smuzhiyun    1056768 204800 linear /dev/sda3 0,
109*4882a593Smuzhiyun    1261568 512000 linear /dev/sda4 0
110*4882a593Smuzhiyun
111*4882a593Smuzhiyun"snapshot-origin"::
112*4882a593Smuzhiyun
113*4882a593Smuzhiyun  dm-snap-orig,,4,ro,0 409600 snapshot-origin 8:2
114*4882a593Smuzhiyun
115*4882a593Smuzhiyun"striped"::
116*4882a593Smuzhiyun
117*4882a593Smuzhiyun  dm-striped,,4,ro,0 1638400 striped 4 4096
118*4882a593Smuzhiyun  /dev/sda1 0 /dev/sda2 0 /dev/sda3 0 /dev/sda4 0
119*4882a593Smuzhiyun
120*4882a593Smuzhiyun"verity"::
121*4882a593Smuzhiyun
122*4882a593Smuzhiyun  dm-verity,,4,ro,
123*4882a593Smuzhiyun    0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256
124*4882a593Smuzhiyun    fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd
125*4882a593Smuzhiyun    51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584
126