docker devicemapper loop pool 擴容

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
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章