If you do not want to use `device_tool`, you can [resize the thin pool manually](#use-operating-system-utilities) instead.
1. To use the tool, clone the Github repository, change to the
`contrib/docker-device-tool`, and follow the instructions in the `README.md`
to compile the tool.
2. Use the tool. The following example resizes the thin pool to 200GB.
```console
$ ./device_tool resize 200GB
```
##### Use operating system utilities
If you do not want to [use the device-tool utility](#use-the-device_tool-utility),
you can resize a `loop-lvm` thin pool manually using the following procedure.
In `loop-lvm` mode, a loopback device is used to store the data, and another
to store the metadata. `loop-lvm` mode is only supported for testing, because
it has significant performance and stability drawbacks.
If you are using `loop-lvm` mode, the output of `docker info` shows file
paths for `Data loop file` and `Metadata loop file`:
```console
$ docker info |grep 'loop file'
Data loop file: /var/lib/docker/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/metadata
```
Follow these steps to increase the size of the thin pool. In this example, the
thin pool is 100 GB, and is increased to 200 GB.
1. List the sizes of the devices.
```console
$ sudo ls -lh /var/lib/docker/devicemapper/
total 1175492
-rw------- 1 root root 100G Mar 30 05:22 data
-rw------- 1 root root 2.0G Mar 31 11:17 metadata
```
2. Increase the size of the `data` file to 200 G using the `truncate` command,
which is used to increase **or** decrease the size of a file. Note that
decreasing the size is a destructive operation.
```console
$ sudo truncate -s 200G /var/lib/docker/devicemapper/data
```
3. Verify the file size changed.
```console
$ sudo ls -lh /var/lib/docker/devicemapper/
total 1.2G
-rw------- 1 root root 200G Apr 14 08:47 data
-rw------- 1 root root 2.0G Apr 19 13:27 metadata
```
4. The loopback file has changed on disk but not in memory. List the size of
the loopback device in memory, in GB. Reload it, then list the size again.
After the reload, the size is 200 GB.
```console
$ echo $[ $(sudo blockdev --getsize64 /dev/loop0) / 1024 / 1024 / 1024 ]
100
$ sudo losetup -c /dev/loop0
$ echo $[ $(sudo blockdev --getsize64 /dev/loop0) / 1024 / 1024 / 1024 ]
200
```
5. Reload the devicemapper thin pool.
a. Get the pool name first. The pool name is the first field, delimited by
`:`. This command extracts it.
```console
$ sudo dmsetup status | grep ' thin-pool ' | awk -F ': ' {'print $1'}
docker-8:1-123141-pool
```
b. Dump the device mapper table for the thin pool.
```console
$ sudo dmsetup table docker-8:1-123141-pool
0 209715200 thin-pool 7:1 7:0 128 32768 1 skip_block_zeroing
```
c. Calculate the total sectors of the thin pool using the second field
of the output. The number is expressed in 512-k sectors. A 100G file has
209715200 512-k sectors. If you double this number to 200G, you get
419430400 512-k sectors.
d. Reload the thin pool with the new sector number, using the following
three `dmsetup` commands.
```console
$ sudo dmsetup suspend docker-8:1-123141-pool
$ sudo dmsetup reload docker-8:1-123141-pool --table '0 419430400 thin-pool 7:1 7:0 128 32768 1 skip_block_zeroing'
$ sudo dmsetup resume docker-8:1-123141-pool
```
#### Resize a direct-lvm thin pool
To extend a `direct-lvm` thin pool, you need to first attach a new block device
to the Docker host, and make note of the name assigned to it by the kernel. In
this example, the new block device is `/dev/xvdg`.
Follow this procedure to extend a `direct-lvm` thin pool, substituting your
block device and other parameters to suit your situation.
1. Gather information about your volume group.
Use the `pvdisplay` command to find the physical block devices currently in