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

Linux 6.18.37 · Administration / Device Mapper

dm-zero

Read에서 zero를 반환하고 write를 버리는 dm-zero와 dm-snapshot COW를 결합한 sparse device 예제를 설명합니다.

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

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

1. 요약·해설

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

Zero target

zero.rst:1-19

Parameter 없는 deterministic zero block device와 sparse snapshot origin 용도를 설명합니다.

Sparse example

zero.rst:20-37

10TB logical zero origin과 10GB COW partition으로 sparse device를 만드는 명령을 보존합니다.

2. 영어 원문 전체

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

원문 전체 펼치기
1 =======
2 dm-zero
3 =======
4
5 Device-Mapper's "zero" target provides a block-device that always returns
6 zero'd data on reads and silently drops writes. This is similar behavior to
7 /dev/zero, but as a block-device instead of a character-device.
8
9 Dm-zero has no target-specific parameters.
10
11 One very interesting use of dm-zero is for creating "sparse" devices in
12 conjunction with dm-snapshot. A sparse device reports a device-size larger
13 than the amount of actual storage space available for that device. A user can
14 write data anywhere within the sparse device and read it back like a normal
15 device. Reads to previously unwritten areas will return a zero'd buffer. When
16 enough data has been written to fill up the actual storage space, the sparse
17 device is deactivated. This can be very useful for testing device and
18 filesystem limitations.
19
20 To create a sparse device, start by creating a dm-zero device that's the
21 desired size of the sparse device. For this example, we'll assume a 10TB
22 sparse device::
23
24 TEN_TERABYTES=`expr 10 \* 1024 \* 1024 \* 1024 \* 2` # 10 TB in sectors
25 echo "0 $TEN_TERABYTES zero" | dmsetup create zero1
26
27 Then create a snapshot of the zero device, using any available block-device as
28 the COW device. The size of the COW device will determine the amount of real
29 space available to the sparse device. For this example, we'll assume /dev/sdb1
30 is an available 10GB partition::
31
32 echo "0 $TEN_TERABYTES snapshot /dev/mapper/zero1 /dev/sdb1 p 128" | \
33 dmsetup create sparse1
34
35 This will create a 10TB sparse device called /dev/mapper/sparse1 that has
36 10GB of actual storage space available. If more than 10GB of data is written
37 to this device, it will start returning I/O errors.
38

3. 한국어 전문 번역

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

항상 zero를 반환하는 block target

1-10

Device-Mapper의 `zero` target은 read에서 항상 zero-filled data를 반환하고 write는 조용히 버리는 block device를 제공합니다. Character device가 아니라 block device라는 점을 제외하면 `/dev/zero`와 비슷합니다.

dm-zero에는 target-specific parameter가 없습니다.

dm-zero I/O semantics
Operation결과
ReadZero-filled buffer 반환
WriteData를 저장하지 않고 폐기
Target parameter없음

Storage를 소비하지 않는 deterministic block target입니다.

dm-snapshot과 sparse device

11-19

dm-zero의 흥미로운 용도는 dm-snapshot과 결합해 `sparse` device를 만드는 것입니다. Sparse device는 실제 사용 가능한 storage보다 큰 device size를 보고합니다. 사용자는 sparse device 어디든 data를 쓰고 일반 device처럼 다시 읽을 수 있습니다. 아직 쓰지 않은 영역의 read는 zero-filled buffer를 반환합니다.

실제 storage가 가득 찰 만큼 data를 쓰면 sparse device를 deactivate합니다. Device와 filesystem limit를 시험할 때 매우 유용합니다.

Sparse device composition
Large dm-zero origindm-snapshotSmall real COW deviceLarge apparent sparse device

거대한 zero origin과 작은 COW device를 snapshot target으로 결합합니다.

10TB sparse device 예제

20-37

원하는 sparse device size와 같은 dm-zero device를 먼저 만듭니다. 예제는 sector 수로 계산한 10TB zero device입니다.

  TEN_TERABYTES=`expr 10 \* 1024 \* 1024 \* 1024 \* 2`   # 10 TB in sectors
  echo "0 $TEN_TERABYTES zero" | dmsetup create zero1

그런 다음 사용 가능한 block device를 COW device로 사용하여 zero device snapshot을 만듭니다. COW device size가 sparse device에 실제로 사용할 수 있는 공간을 결정합니다. 예제에서는 `/dev/sdb1`이 사용 가능한 10GB partition이라고 가정합니다.

  echo "0 $TEN_TERABYTES snapshot /dev/mapper/zero1 /dev/sdb1 p 128" | \
     dmsetup create sparse1

결과는 실제 storage 10GB를 가진 10TB sparse device `/dev/mapper/sparse1`입니다. 이 device에 10GB보다 많은 data를 쓰면 I/O error를 반환하기 시작합니다.

예제 capacity
LayerCapacity
`/dev/mapper/zero1` origin10TB logical, 실제 data storage 없음
`/dev/sdb1` COW10GB actual storage
`/dev/mapper/sparse1`10TB reported, write budget 10GB

Reported capacity와 실제 COW capacity가 분리됩니다.