← Documents Documentation/admin-guide/device-mapper/dm-init.rst GitHub 원문 ↗

Linux 6.18.37 · Administration / Device Mapper

Early creation of mapped devices

커널 부팅 명령줄의 dm-mod.create로 device-mapper 장치를 조기에 만들고, target 제약과 dm-mod.waitfor를 적용하는 방법입니다.

Source pathDocumentation/admin-guide/device-mapper/dm-init.rst
Source versionLinux v6.18.37
TranslationDUJINLABS 전문 번역 + 해설

요약·해설과 원문, 전문 번역을 서로 분리했습니다. API 이름, symbol, source path는 원문 표기를 사용합니다.

1. 요약·해설

원문의 핵심 논리와 kernel programming 관점의 보충 설명입니다. 아래의 전문 번역과는 별도로 작성했습니다.

조기 생성 문법

dm-init.rst:1-36

Initial ramdisk 방식과 `dm-mod.create=` 방식, 장치·table 구분 문법을 설명합니다.

Target 제약과 예제

dm-init.rst:37-126

부팅 시 허용되거나 제약되는 target을 구분하고 linear, verity, crypt 등 실제 선언 예제를 풀이합니다.

비동기 장치 대기

dm-init.rst:127-133

`dm-mod.waitfor=`로 MMC·USB 같은 비동기 backing 장치를 기다린 뒤 table을 설정합니다.

2. 영어 원문 전체

번역 기준이 된 Linux v6.18.37 원문입니다. 줄 번호는 이 버전의 파일 좌표입니다.

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

3. 한국어 전문 번역

영어 원문의 문단 순서와 의미를 유지한 전체 번역입니다. 코드, 함수명, symbol과 URL은 원문 표기를 유지합니다.

매핑 장치의 조기 생성 방식과 dm-mod.create 문법

1-36

시스템의 루트 장치로 동작할 device-mapper 장치를 구성하는 방법은 두 가지입니다.

첫 번째 방법은 최소 userspace로 부팅하는 initial ramdisk를 만들고, 그 환경에서 장치를 구성한 다음 `pivot_root(8)`로 해당 장치에 루트 파일시스템을 전환하는 것입니다.

두 번째 방법은 커널 부팅 명령줄에서 `dm-mod.create=` 모듈 매개변수를 사용해 하나 이상의 device-mapper 장치를 만드는 것입니다.

이 문자열은 쉼표와 선택적인 세미콜론으로 구분합니다. 쉼표는 한 장치 안의 `name`, `uuid`, `minor`, `flags`, `table` 필드를 나누고, 세미콜론은 서로 다른 장치를 나눕니다. 따라서 전체 형식은 다음과 같습니다.

 dm-mod.create=<name>,<uuid>,<minor>,<flags>,<table>[,<table>+][;<name>,<uuid>,<minor>,<flags>,<table>[,<table>+]+]
dm-mod.create 필드 문법
필드허용 값과 의미
`<name>`장치 이름
`<uuid>``xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx` 형식의 UUID 또는 빈 문자열
`<minor>`장치 minor 번호 또는 빈 문자열
`<flags>`읽기 전용 `ro` 또는 읽기/쓰기 `rw`
`<table>``<start_sector> <num_sectors> <target_type> <target_args>`
`<target_type>``verity`, `linear` 등을 포함한 지원 target 종류
undefinedundefined
undefinedundefined

한 장치의 식별 정보와 table을 쉼표로 연결하고 여러 장치는 세미콜론으로 분리합니다.

	<name>		::= The device name.
	<uuid>		::= xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx | ""
	<minor>		::= The device minor number | ""
	<flags>		::= "ro" | "rw"
	<table>		::= <start_sector> <num_sectors> <target_type> <target_args>
	<target_type>	::= "verity" | "linear" | ... (see list below)

이 DM 행은 `dmsetup --concise`에서 사용하는 행과 동등해야 합니다.

부팅 시 사용할 수 있는 target 종류와 제약

37-67

모든 target을 조기 활성화할 수 있는 것은 아닙니다. 일부 DM target은 userspace 도구가 관련 metadata의 유효성을 먼저 검사하지 않은 채 활성화하면 심각한 위험이 있으므로 제약됩니다.

dm-init target 허용 수준
Target상태와 이유
`cache`제약: userspace가 cache 장치를 검증해야 함
`crypt`허용
`delay`허용
`era`제약: userspace가 metadata 장치를 검증해야 함
`flakey`제약: 테스트용
`linear`허용
`log-writes`제약: userspace가 metadata 장치를 검증해야 함
`mirror`제약: userspace가 주 장치와 mirror 장치를 검증해야 함
`raid`제약: userspace가 metadata 장치를 검증해야 함
`snapshot`제약: userspace가 source와 destination 장치를 검증해야 함
`snapshot-origin`허용
`snapshot-merge`제약: userspace가 source와 destination 장치를 검증해야 함
`striped`허용
`switch`제약: userspace가 장치 경로를 검증해야 함
`thin`제약: userspace의 DM target 메시지가 필요함
`thin-pool`제약: userspace의 DM target 메시지가 필요함
`verity`허용
`writecache`제약: userspace가 cache 장치를 검증해야 함
`zero`제약: rootfs 용도가 아님

허용 target은 바로 만들 수 있고, 제약 target은 userspace 검증이나 후속 메시지가 필요합니다.

======================= =======================================================
`cache`			constrained, userspace should verify cache device
`crypt`			allowed
`delay`			allowed
`era`			constrained, userspace should verify metadata device
`flakey`		constrained, meant for test
`linear`		allowed
`log-writes`		constrained, userspace should verify metadata device
`mirror`		constrained, userspace should verify main/mirror device
`raid`			constrained, userspace should verify metadata device
`snapshot`		constrained, userspace should verify src/dst device
`snapshot-origin`	allowed
`snapshot-merge`	constrained, userspace should verify src/dst device
`striped`		allowed
`switch`		constrained, userspace should verify dev path
`thin`			constrained, requires dm target message from userspace
`thin-pool`		constrained, requires dm target message from userspace
`verity`		allowed
`writecache`		constrained, userspace should verify cache device
`zero`			constrained, not meant for rootfs
======================= =======================================================

위 목록에 없는 target은 테스트되지 않았으므로 기본적으로 제약된 것으로 취급합니다.

단일 linear 루트와 여러 매핑 장치 예제

68-89

다음은 user-mode Linux block 장치로 구성한 linear 배열을 루트 장치로 부팅하는 예입니다.

  dm-mod.create="lroot,,,rw, 0 4096 linear 98:16 0, 4096 4096 linear 98:32 0" root=/dev/dm-0

이 명령은 major:minor 번호가 `98:16`과 `98:32`인 두 block 장치에 각각 4096 sector를 배치해 총 8192 sector인 읽기/쓰기 `dm-linear` target으로 부팅합니다. 부팅 후 udev 규칙에 따라 이 target의 이름은 `/dev/mapper/lroot`로 바뀔 수 있습니다. UUID는 지정하지 않았습니다.

여러 device-mapper 장치를 한 번에 선언할 수도 있습니다. 다음 `dm-mod.create="..."` 내용은 읽기 쉽도록 여러 줄로 나눈 것이며, 실제 장치 정의는 세미콜론으로 구분됩니다.

  dm-linear,,1,rw,
    0 32768 linear 8:1 0,
    32768 1024000 linear 8:2 0;
  dm-verity,,3,ro,
    0 1638400 verity 1 /dev/sdc1 /dev/sdc2 4096 4096 204800 1 sha256
    ac87db56303c9c1da433d7209b5a6ef3e4779df141200cbd7c157dcb8dd89c42
    5ebfe87f7df3235b80a117ebc4078e44f55045487ad4a96581d1adb564615b51
여러 조기 매핑 장치의 생성
`dm-linear`, minor 1, `rw`두 linear table 구간`/dev/dm-1` 생성
`dm-verity`, minor 3, `ro`data/hash 장치와 digest 검증`/dev/dm-3` 생성

부팅 문자열에서 장치 정의를 분리하고 각 table을 적재한 뒤 지정 minor에 장치를 생성합니다.

target별 dm-mod.create 예제

90-126

다음은 지원 target별 장치 정의 예입니다. 각 예는 장치 이름, 선택적인 UUID와 minor, `ro` 또는 `rw` flag, 그리고 해당 target의 table 인자를 차례로 제공합니다.

`crypt` 예는 `aes-xts-plain64` cipher, 512-bit key 문자열, `/dev/sda`, `allow_discards` 옵션으로 읽기 전용 암호화 매핑을 만듭니다.

  dm-crypt,,8,ro,
    0 1048576 crypt aes-xts-plain64
    babebabebabebabebabebabebabebabebabebabebabebabebabebabebabebabe 0
    /dev/sda 0 1 allow_discards

`delay` 예는 `/dev/sda1`의 sector 0부터 읽고 500 ms 지연을 적용하는 409600-sector 매핑을 만듭니다.

  dm-delay,,4,ro,0 409600 delay /dev/sda1 0 500

`linear` 예는 `/dev/sda1`부터 `/dev/sda4`까지 네 구간을 연속적인 읽기/쓰기 논리 장치로 연결합니다.

  dm-linear,,,rw,
    0 32768 linear /dev/sda1 0,
    32768 1024000 linear /dev/sda2 0,
    1056768 204800 linear /dev/sda3 0,
    1261568 512000 linear /dev/sda4 0

`snapshot-origin` 예는 `8:2` 장치를 origin으로 사용하는 409600-sector 읽기 전용 매핑을 만듭니다.

  dm-snap-orig,,4,ro,0 409600 snapshot-origin 8:2

`striped` 예는 네 장치와 4096-sector chunk 크기를 사용해 1638400 sector를 stripe합니다.

  dm-striped,,4,ro,0 1638400 striped 4 4096
  /dev/sda1 0 /dev/sda2 0 /dev/sda3 0 /dev/sda4 0

`verity` 예는 data 장치 `8:1`, hash 장치 `8:2`, 4096-byte block 크기, SHA-256 root digest와 salt를 사용해 읽기 전용 검증 장치를 만듭니다.

  dm-verity,,4,ro,
    0 1638400 verity 1 8:1 8:2 4096 4096 204800 1 sha256
    fb1a5a0f00deb908d8b53cb270858975e76cf64105d412ce764225d53b8f3cfd
    51934789604d1b92399c52e7cb149d1b3a1b74bbbcb103b2a0aaacbed5c08584
target 예제의 핵심 구성
Target핵심 인자결과
`crypt`cipher, key, IV offset, backing device, discard option암호화된 읽기 전용 장치
`delay`backing device, offset, delayI/O 지연 장치
`linear`네 backing device와 연속 sector 구간연결된 읽기/쓰기 장치
`snapshot-origin`origin 장치 `8:2`snapshot origin 매핑
`striped`4개 stripe, chunk 4096 sectorstriped 읽기 전용 장치
`verity`data/hash 장치, block 크기, SHA-256 digest와 salt무결성 검증 읽기 전용 장치

각 예제가 보여 주는 table 인자와 부팅 시 용도를 비교합니다.

비동기 probe 장치를 기다리는 dm-mod.waitfor

127-133

MMC나 USB처럼 비동기로 probe되는 block 장치 위에 device-mapper를 구성하면, backing 장치가 나타나기 전에 table 설정이 시작될 수 있습니다. 이 경우 `dm-init`에 장치가 준비될 때까지 명시적으로 기다리도록 지시해야 할 수 있습니다.

`dm-mod.waitfor=` 모듈 매개변수는 기다릴 장치 목록을 쉼표로 구분해 받습니다.

  dm-mod.waitfor=<device1>[,..,<deviceN>]
비동기 backing 장치 대기
커널 부팅`dm-mod.waitfor=` 목록 확인MMC·USB 장치 probe 완료 대기`dm-mod.create=` table 설정루트 장치 사용

필요한 block 장치가 준비된 뒤에만 device-mapper table을 설정합니다.