您的位置:首页 > 运维架构 > Docker

docker devicemapper loop pool 扩容

2016-06-03 16:37 901 查看
1.List the sizes of the devices.

$ sudo ls -lh /var/lib/docker/devicemapper/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.Truncate data file to the size of the metadata file (approximage 200GB).

$ sudo truncate -s 214748364800 /var/lib/docker/devicemapper/devicemapper/data


3.Verify the file size changed.

$ sudo ls -lh /var/lib/docker/devicemapper/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.Reload data loop device

$ sudo blockdev --getsize64 /dev/loop0
107374182400
$ sudo losetup -c /dev/loop0
$ sudo blockdev --getsize64 /dev/loop0
214748364800


5.Reload devicemapper thin pool.

a. Get the pool name first.

$ sudo dmsetup status | grep pool
docker-8:1-123141-pool: 0 209715200 thin-pool 91
422/524288 18338/1638400 - rw discard_passdown queue_if_no_space -
The name is the string before the colon.


b. Dump the device mapper table first.

$ 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 real total sectors of the thin pool now.

Change the second number of the table info (i.e. the disk end sector)
as the new loop size is 200GB, change the second number to 419430400.
419430400=1024*1024*1024*200/512 块扇区


d. Reload the thin pool with the new sector number

$ 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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  docker loop-pool