[linux-lvm] -l 100%FREE doesn't work with RAID1

Bryan Larsen bryan at larsen.st
Wed Jan 20 18:55:25 UTC 2016


On Wed, 20 Jan 2016 at 13:29 Fran Garcia <franchu.garcia at gmail.com> wrote:

> On 20 January 2016 at 13:19, Bryan Larsen <bryan at larsen.st> wrote:
> > I'm setting up some provisioning scripts, so I don't know the actual
> sizes
> > of the hard drives
> >
> > $ sudo lvcreate --type raid1 -m 1 -l 100%FREE -n backups hdd_vg
> >   Insufficient free space: 781320 extents needed, but only 390658
> available
> > $ sudo lvcreate --type raid1 -m 1 -l 50%FREE -n backups hdd_vg
> >   Insufficient free space: 390662 extents needed, but only 390658
> available
>
> the quick and dirty solution... :
>
> EXTENTS=$(sudo vgs -o vg_all --noheadings hdd_vg | awk '{print $12/2}')
> lvcreate --type raid1 -m 1 -l $EXTENTS -n backups hdd_vg
>
> :-)
>

Two problems with that.

1: I had to replace $12 with $9 to get things to work with my version.   So
probably best to use -o vg_free_count instead of -o vg_all

2: but more importantly, it has the same problem as -l 50%FREE:

  Insufficient free space: 390662 extents needed, but only 390658 available

This works for me:

EXTENTS=$((`sudo vgs -o vg_free_count --noheading hdd_vg`/2 - 2))
sudo lvcreate --type raid1 -m 1 -l $EXTENTS -n backups hdd_vg

Bryan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://listman.redhat.com/archives/linux-lvm/attachments/20160120/4d5d3c5f/attachment.htm>


More information about the linux-lvm mailing list