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