devmapper: add README and minor fixes
Signed-off-by: Maksym Pavlenko <makpav@amazon.com>
This commit is contained in:
parent
2218275ec9
commit
0c6d194cce
46
snapshots/devmapper/README.md
Normal file
46
snapshots/devmapper/README.md
Normal file
@ -0,0 +1,46 @@
|
||||
## Devmapper snapshotter
|
||||
|
||||
Devmapper is a `containerd` snapshotter plugin that stores snapshots in ext4-formatted filesystem images
|
||||
in a devicemapper thin pool.
|
||||
|
||||
## Setup
|
||||
|
||||
To make it work you need to prepare `thin-pool` in advance and update containerd's configuration file.
|
||||
This file is typically located at `/etc/containerd/config.toml`.
|
||||
|
||||
Here's minimal sample entry that can be made in the configuration file:
|
||||
|
||||
```
|
||||
[plugins]
|
||||
...
|
||||
[plugins.devmapper]
|
||||
pool_name = "containerd-pool"
|
||||
base_image_size = "128MB"
|
||||
...
|
||||
```
|
||||
|
||||
The following configuration flags are supported:
|
||||
* `root_path` - a directory where the metadata will be available (if empty
|
||||
default location for `containerd` plugins will be used)
|
||||
* `pool_name` - a name to use for the devicemapper thin pool. Pool name
|
||||
should be the same as in `/dev/mapper/` directory
|
||||
* `data_device` - path to the data volume that should be used by the thin pool
|
||||
* `meta_device` - path to the metadata volume that should be used by the thin-pool
|
||||
* `data_block_size` - the size of allocation chunks in data file, between 128
|
||||
sectors (64KB) and and 2097152 sectors (1GB) and a multiple of 128 sectors (64KB)
|
||||
* `base_image_size` - defines how much space to allocate when creating the base device
|
||||
|
||||
Pool name and base image size are required snapshotter parameters.
|
||||
|
||||
## Run
|
||||
Give it a try with the following commands:
|
||||
|
||||
```bash
|
||||
ctr images pull --snapshotter devmapper docker.io/library/hello-world:latest
|
||||
ctr run --snapshotter devmapper docker.io/library/hello-world:latest test
|
||||
```
|
||||
|
||||
## Requirements
|
||||
|
||||
The devicemapper snapshotter requires `dmsetup` command line tool to be installed and available on your computer.
|
||||
On Ubuntu, it can be installed with `apt-get install dmsetup` command.
|
@ -65,7 +65,7 @@ type Config struct {
|
||||
BaseImageSizeBytes uint64 `toml:"-"`
|
||||
}
|
||||
|
||||
// LoadConfig reads devmapper configuration file JSON format from disk
|
||||
// LoadConfig reads devmapper configuration file from disk in TOML format
|
||||
func LoadConfig(path string) (*Config, error) {
|
||||
if _, err := os.Stat(path); err != nil {
|
||||
if os.IsNotExist(err) {
|
||||
|
@ -39,12 +39,9 @@ import (
|
||||
|
||||
func init() {
|
||||
plugin.Register(&plugin.Registration{
|
||||
Type: plugin.SnapshotPlugin,
|
||||
ID: "devmapper",
|
||||
Config: &Config{
|
||||
PoolName: "containerd-pool",
|
||||
BaseImageSize: "128Mb",
|
||||
},
|
||||
Type: plugin.SnapshotPlugin,
|
||||
ID: "devmapper",
|
||||
Config: &Config{},
|
||||
InitFn: func(ic *plugin.InitContext) (interface{}, error) {
|
||||
ic.Meta.Platforms = append(ic.Meta.Platforms, ocispec.Platform{
|
||||
OS: "linux",
|
||||
@ -56,6 +53,10 @@ func init() {
|
||||
return nil, errors.New("invalid devmapper configuration")
|
||||
}
|
||||
|
||||
if config.PoolName == "" {
|
||||
return nil, errors.New("devmapper not configured")
|
||||
}
|
||||
|
||||
if config.RootPath == "" {
|
||||
config.RootPath = ic.Root
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user