Skip to content

Instantly share code, notes, and snippets.

@swamibluedata
Last active September 8, 2016 15:30
Show Gist options
  • Save swamibluedata/6891c8b0b0d0f1b71a818cd299a6b5bb to your computer and use it in GitHub Desktop.
Save swamibluedata/6891c8b0b0d0f1b71a818cd299a6b5bb to your computer and use it in GitHub Desktop.
# Set this to the new size of the pool
NEW_SIZE_GB=200
NEW_SIZE=$(( $NEW_SIZE_GB*1024*1024*1024 ))
META_SIZE_GB=$(echo "$NEW_SIZE_GB*.02" | bc -l)
NEW_META_SIZE_GB=${META_SIZE_GB%.*}
POOL=$(docker info | grep pool | awk '{print $3}')
DEVMAPPER_POOL="/dev/mapper/$POOL"
DATA_LO_DEV=$(docker info | grep "Data file" | cut -d":" -f2)
META_LO_DEV=$(docker info | grep "Metadata file" | cut -d":" -f2)
# Increase the data and metadata device size.
dd if=/dev/zero of=/var/lib/docker/devicemapper/devicemapper/data bs=1G count=0 seek=$NEW_SIZE_GB
dd if=/dev/zero of=/var/lib/docker/devicemapper/devicemapper/metadata bs=1G count=0 seek=$NEW_META_SIZE_GB
# Reload loopback devices
losetup -c $DATA_LO_DEV
losetup -c $META_LO_DEV
dmsetup suspend $DEVMAPPER_POOL
dmsetup table $DEVMAPPER_POOL | sed "s/0 [0-9]* thin-pool/0 $(($NEW_SIZE/512)) thin-pool/" | dmsetup load $DEVMAPPER_POOL
dmsetup resume $DEVMAPPER_POOL
# Verify by docker info
docker info
blockdev --getsize64 $DATA_LO_DEV
blockdev --getsize64 $META_LO_DEV
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment