Skip to content

Commit 0c6d194

Browse files
committed
devmapper: add README and minor fixes
Signed-off-by: Maksym Pavlenko <[email protected]>
1 parent 2218275 commit 0c6d194

3 files changed

Lines changed: 54 additions & 7 deletions

File tree

snapshots/devmapper/README.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
## Devmapper snapshotter
2+
3+
Devmapper is a `containerd` snapshotter plugin that stores snapshots in ext4-formatted filesystem images
4+
in a devicemapper thin pool.
5+
6+
## Setup
7+
8+
To make it work you need to prepare `thin-pool` in advance and update containerd's configuration file.
9+
This file is typically located at `/etc/containerd/config.toml`.
10+
11+
Here's minimal sample entry that can be made in the configuration file:
12+
13+
```
14+
[plugins]
15+
...
16+
[plugins.devmapper]
17+
pool_name = "containerd-pool"
18+
base_image_size = "128MB"
19+
...
20+
```
21+
22+
The following configuration flags are supported:
23+
* `root_path` - a directory where the metadata will be available (if empty
24+
default location for `containerd` plugins will be used)
25+
* `pool_name` - a name to use for the devicemapper thin pool. Pool name
26+
should be the same as in `/dev/mapper/` directory
27+
* `data_device` - path to the data volume that should be used by the thin pool
28+
* `meta_device` - path to the metadata volume that should be used by the thin-pool
29+
* `data_block_size` - the size of allocation chunks in data file, between 128
30+
sectors (64KB) and and 2097152 sectors (1GB) and a multiple of 128 sectors (64KB)
31+
* `base_image_size` - defines how much space to allocate when creating the base device
32+
33+
Pool name and base image size are required snapshotter parameters.
34+
35+
## Run
36+
Give it a try with the following commands:
37+
38+
```bash
39+
ctr images pull --snapshotter devmapper docker.io/library/hello-world:latest
40+
ctr run --snapshotter devmapper docker.io/library/hello-world:latest test
41+
```
42+
43+
## Requirements
44+
45+
The devicemapper snapshotter requires `dmsetup` command line tool to be installed and available on your computer.
46+
On Ubuntu, it can be installed with `apt-get install dmsetup` command.

snapshots/devmapper/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ type Config struct {
6565
BaseImageSizeBytes uint64 `toml:"-"`
6666
}
6767

68-
// LoadConfig reads devmapper configuration file JSON format from disk
68+
// LoadConfig reads devmapper configuration file from disk in TOML format
6969
func LoadConfig(path string) (*Config, error) {
7070
if _, err := os.Stat(path); err != nil {
7171
if os.IsNotExist(err) {

snapshots/devmapper/snapshotter.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,12 +39,9 @@ import (
3939

4040
func init() {
4141
plugin.Register(&plugin.Registration{
42-
Type: plugin.SnapshotPlugin,
43-
ID: "devmapper",
44-
Config: &Config{
45-
PoolName: "containerd-pool",
46-
BaseImageSize: "128Mb",
47-
},
42+
Type: plugin.SnapshotPlugin,
43+
ID: "devmapper",
44+
Config: &Config{},
4845
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
4946
ic.Meta.Platforms = append(ic.Meta.Platforms, ocispec.Platform{
5047
OS: "linux",
@@ -56,6 +53,10 @@ func init() {
5653
return nil, errors.New("invalid devmapper configuration")
5754
}
5855

56+
if config.PoolName == "" {
57+
return nil, errors.New("devmapper not configured")
58+
}
59+
5960
if config.RootPath == "" {
6061
config.RootPath = ic.Root
6162
}

0 commit comments

Comments
 (0)