containers / docker-lvm-plugin

Docker volume plugin for LVM volumes
GNU Lesser General Public License v3.0
155 stars 64 forks source link

extension of logical volume does not increase volume size #17

Closed capi1O closed 8 years ago

capi1O commented 8 years ago

Hello, I have created a docker named volume using LVM thanks to your driver :

docker volume create -d lvm --name my-named-lvm-volume --opt size=500G

This works great, I can see the logical volume is created using sudo lvdisplay :

  --- Logical volume ---
  LV Path                /dev/my-volume-group/my-named-lvm-volume
  LV Name                my-named-lvm-volume
  VG Name               my-volume-group
...
  LV Size                500 GiB
...

And as soon as I docker rm my-named-lvm-volume the logical volume disappear, quite easy ;-)

However I then tried to extend the logical volume, for example to add 100GB : sudo lvextend -L+100G /dev/my-volume-group/my-named-lvm-volume.

The operations is successful (lvdisplay shows correct new size) however the docker volume still use the initial space set (500GB). I could remove and recreate the named volume but I already have a lot of data on it.

Is there a way to extend the named volume ? Apologies if I'm missing something obvious...

capi1O commented 8 years ago

ok I actually forgot the basics : partition (in this case, the logical volume) ≠ filesystem.

What happens with lvextend is that the logical volume is expanded, however the filesystem is not. I did not think about the filesystem because everything is handled by docker-lvm-plugin and we have never to deal with it.

To find out what is the filesystem used by docker-lvm-plugin I used mount :

/dev/mapper/my--volume--group-my--named--lvm--volume on /var/lib/docker-lvm-plugin/my-named-lvm-volume type xfs (rw,relatime,attr2,inode64,noquota)

And to extend the filesystem (to the maximum possible) just use sudo xfs_growfs /dev/mapper/my--volume--group-my--named--lvm--volume.

Note : this can be done while the docker volume is in use, no problem.

shishir-a412ed commented 8 years ago

@monkeydri Yes this is correct. You need to extend both the logical volume and the XFS filesystem. Since xfs_growfs only allows online resizing, the filesystem must be mounted before it can grown.

Shishir