@@ -136,9 +136,9 @@ state = "/run/firecracker-containerd"
136
136
[grpc ]
137
137
address = " /run/firecracker-containerd/containerd.sock"
138
138
[proxy_plugins ]
139
- [proxy_plugins .firecracker-naive ]
139
+ [proxy_plugins .firecracker-devmapper ]
140
140
type = " snapshot"
141
- address = " /var/run/firecracker-containerd/naive -snapshotter.sock"
141
+ address = " /var/run/firecracker-containerd/devmapper -snapshotter.sock"
142
142
143
143
[debug ]
144
144
level = " debug"
@@ -150,6 +150,76 @@ from the same version of containerd as `firecracker-containerd`, which ensures t
150
150
binaries are in sync with one another. While other builds of ` ctr ` may work with
151
151
` firecracker-containerd ` , use of ` firecracker-ctr ` will ensure compatibility.
152
152
153
+ ### Prepare and configure snapshotter
154
+
155
+ The devmapper snapshotter requires a thinpool to exist.
156
+ Below is a script to create a thinpool as well as an example config file.
157
+
158
+ ` Note: The configuration with loopback devices is slow and not intended for use in production. `
159
+
160
+ <details >
161
+ <summary >Script to setup thinpool with dmsetup.</summary >
162
+
163
+ ``` bash
164
+ #! /bin/bash
165
+
166
+ # Sets up a devicemapper thin pool with loop devices in
167
+ # /var/lib/firecracker-containerd/snapshotter/devmapper
168
+
169
+ set -ex
170
+
171
+ DIR=/var/lib/firecracker-containerd/snapshotter/devmapper
172
+ POOL=fc-dev-thinpool
173
+
174
+ if [[ ! -f " ${DIR} /data" ]]; then
175
+ touch " ${DIR} /data"
176
+ truncate -s 100G " ${DIR} /data"
177
+ fi
178
+
179
+ if [[ ! -f " ${DIR} /metadata" ]]; then
180
+ touch " ${DIR} /metadata"
181
+ truncate -s 2G " ${DIR} /metadata"
182
+ fi
183
+
184
+ DATADEV=" $( losetup --output NAME --noheadings --associated ${DIR} /data) "
185
+ if [[ -z " ${DATADEV} " ]]; then
186
+ DATADEV=" $( losetup --find --show ${DIR} /data) "
187
+ fi
188
+
189
+ METADEV=" $( losetup --output NAME --noheadings --associated ${DIR} /metadata) "
190
+ if [[ -z " ${METADEV} " ]]; then
191
+ METADEV=" $( losetup --find --show ${DIR} /metadata) "
192
+ fi
193
+
194
+ SECTORSIZE=512
195
+ DATASIZE=" $( blockdev --getsize64 -q ${DATADEV} ) "
196
+ LENGTH_SECTORS=$( bc <<< " ${DATASIZE}/${SECTORSIZE}" )
197
+ DATA_BLOCK_SIZE=128 # see https://www.kernel.org/doc/Documentation/device-mapper/thin-provisioning.txt
198
+ LOW_WATER_MARK=32768 # picked arbitrarily
199
+ THINP_TABLE=" 0 ${LENGTH_SECTORS} thin-pool ${METADEV} ${DATADEV} ${DATA_BLOCK_SIZE} ${LOW_WATER_MARK} 1 skip_block_zeroing"
200
+ echo " ${THINP_TABLE} "
201
+
202
+ if ! $( dmsetup reload " ${POOL} " --table " ${THINP_TABLE} " ) ; then
203
+ dmsetup create " ${POOL} " --table " ${THINP_TABLE} "
204
+ fi
205
+ ```
206
+ </details >
207
+
208
+ <details >
209
+ <summary >Snappshotter config file example.</summary >
210
+
211
+ ``` json
212
+ {
213
+ "base_image_size" : " 10GB" ,
214
+ "root_path" : " /var/lib/firecracker-containerd/snapshotter/devmapper" ,
215
+ "pool_name" : " fc-dev-thinpool"
216
+ }
217
+ ```
218
+
219
+ </details >
220
+
221
+ A reasonable location for this file is at ` /etc/firecracker-dm-snapshotter/config.json ` .
222
+
153
223
### Configure containerd runtime plugin
154
224
155
225
The runtime expects a JSON-formatted configuration file to be located either in
@@ -210,10 +280,12 @@ configuration file has the following fields:
210
280
Start the containerd snapshotter
211
281
212
282
``` bash
213
- $ ./naive_snapshotter \
214
- -address /var/run/firecracker-containerd/naive-snapshotter.sock \
215
- -path /tmp/fc-snapshot
283
+ $ ./devmapper_snapshotter \
284
+ -address /var/run/firecracker-containerd/devmapper-snapshotter.sock \
285
+ -path /tmp/fc-snapshot \
286
+ -config /etc/firecracker-dm-snapshotter/config.json
216
287
```
288
+ ` note: The path for -config needs to match the location used when configuring the devmapper snapshotter. `
217
289
218
290
In another terminal, start containerd
219
291
@@ -226,15 +298,15 @@ Pull an image
226
298
227
299
``` bash
228
300
$ sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock images \
229
- pull --snapshotter firecracker-naive \
301
+ pull --snapshotter firecracker-devmapper \
230
302
docker.io/library/busybox:latest
231
303
```
232
304
233
305
And start a container!
234
306
235
307
``` bash
236
308
$ sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock \
237
- run --snapshotter firecracker-naive --runtime aws.firecracker \
309
+ run --snapshotter firecracker-devmapper --runtime aws.firecracker \
238
310
--rm --tty --net-host \
239
311
docker.io/library/busybox:latest busybox-test
240
312
```
@@ -249,7 +321,7 @@ $ sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock \
249
321
$ sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock \
250
322
namespaces label fc \
251
323
containerd.io/defaults/runtime=aws.firecracker \
252
- containerd.io/defaults/snapshotter=firecracker-naive
324
+ containerd.io/defaults/snapshotter=firecracker-devmapper
253
325
254
326
$ sudo firecracker-ctr --address /run/firecracker-containerd/containerd.sock \
255
327
-n fc \
0 commit comments