Discussion:
[linux-lvm] -l 100%FREE doesn't work with RAID1
Bryan Larsen
2016-01-20 12:19:13 UTC
Permalink
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

thoughts?

thanks,
Bryan
Fran Garcia
2016-01-20 18:17:43 UTC
Permalink
Post by Bryan Larsen
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

:-)
Bryan Larsen
2016-01-20 18:55:25 UTC
Permalink
Post by Bryan Larsen
Post by Bryan Larsen
I'm setting up some provisioning scripts, so I don't know the actual
sizes
Post by Bryan Larsen
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
Post by Bryan Larsen
$ sudo lvcreate --type raid1 -m 1 -l 50%FREE -n backups hdd_vg
Insufficient free space: 390662 extents needed, but only 390658
available
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

Alasdair G Kergon
2016-01-20 19:16:26 UTC
Permalink
Post by Bryan Larsen
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
Works for me here.

Perhaps you're using an old version?
When run with -vvvv, the key line for me is this one
metadata/lv_manip.c:3036 Found fewer allocatable extents for logical volume lvol1 than requested: using 48 extents (reduced by 142).

Alasdair
Continue reading on narkive:
Loading...