docker devicemapper loop pool 扩容

本文介绍了如何扩容Docker的devicemapper loop pool。步骤包括检查设备大小、调整数据文件至元数据大小、验证文件变化、重新加载数据loop设备以及更新devicemapper thin pool的扇区数。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值