Sometimes while we do any docker operation or build docker images, we might encounter devmapper: Thin Pool space issue.
daemon: devmapper: Thin Pool has 132480 free data blocks which is less than minimum required 163840 free data blocks. Create more free space in thin
pool or use dm.min_free_space option to change behavior |
We can resize a loop-lvm thin pool manually without any device-tool utility.
1. First grep the location of Data loop file.
$ sudo docker info | grep loop WARNING: Usage of loopback devices is strongly discouraged for production use. Use `--storage-opt dm.thinpooldev` to specify a custom block storage device.
Data file: /dev/loop0
Metadata file: /dev/loop1
Data loop file: /var/lib/docker/devicemapper/devicemapper/data
Metadata loop file: /var/lib/docker/devicemapper/devicemapper/metadata |
2. Check the total size of loop0 device.
$ echo $[ $(sudo blockdev --getsize64 /dev/loop0) / 1024 / 1024 / 1024 ]
100 |
3. We will add 100GB in Data file: /dev/loop0, file path as per the above output:- /var/lib/docker/devicemapper/devicemapper/data
$ sudo truncate -s +100G /var/lib/docker/devicemapper/devicemapper/data |
4. set up and control loop devices and force loop driver to reread size of the file associated with the specified loop device
$ sudo losetup -c /dev/loop0 |
5. Check the size of Data file.
$ ls -lhtr /var/lib/docker/devicemapper/devicemapper/data
-rw-rw-rw- 1 root root 200G Jan 27 05:06 /var/lib/docker/devicemapper/devicemapper/data |
6. Now check the total size of loop0 device.
$ echo $[ $(sudo blockdev --getsize64 /dev/loop0) / 1024 / 1024 / 1024 ]
200 |
7. Get the pool name first which we will used to update its table.
$ sudo dmsetup status |grep 'thin-pool' |awk -F ': ' {'print $1'}
docker-202:81-14418666-pool |
8. use low level logical volume management to outputs the current table for the device in a format that can be fed back in using the create or load commands.
$ sudo dmsetup table docker-202:81-14418666-pool
0 209715200 thin-pool 7:1 7:0 128 32768 1 skip_block_zeroing |
The second number (209715200) is the size of the device, which will need next to calculate the actual size of volume.
9. Let’s compute how many sectors we need for a 100 GB volume. Per sector 512-bytes in a volume or Disk drive hence we will use first three 1024 for Giga bytes (GB) and divided by 512 bytes.
$ echo $((100*1024*1024*1024/512))
209715200 |
10. Now add both the value of step 8 and step 9.
209715200 | +209715200 = 419430400 |
11# The old table was 0 209715200 thin-pool 7:1 7:0 128 32768 1 skip_block_zeroing. We will change the second number, and be extremely careful about leaving everything else exactly as it is.
$ echo 0 419430400 thin-pool 7:1 7:0 128 32768 1 skip_block_zeroing | sudo dmsetup load docker-202:81-14418666-pool |
If you face any permission error with above command then please execute it with root user.
12. Run the following command to activate new table.
$ sudo dmsetup resume docker-202:81-14418666-pool |
13# Run the below command to check the table output.
$ sudo dmsetup table docker-202:81-14418666-pool |
14. Run command docker info to see the actual Data size.
$ sudo docker info | grep Data Data file: /dev/loop0
Data Space Used: 102.9GB
Data Space Total: 204.8GB
Data Space Available: 101.9GB
Data loop file: /var/lib/docker/devicemapper/devicemapper/data |
Comments
Post a Comment