[linux-lvm] [PATCH 21/35] fsadm: Use DEFAULT_POOL when creating volume group
Lukas Czerner
lczerner at redhat.com
Wed Sep 21 16:45:40 UTC 2011
I user did not specified group, use DEFAULT_POOL from configuration
file.
Signed-off-by: Lukas Czerner <lczerner at redhat.com>
---
scripts/fsadm.sh | 58 ++++++-----------------------------------------------
1 files changed, 7 insertions(+), 51 deletions(-)
diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh
index 1968ee3..a66abd1 100755
--- a/scripts/fsadm.sh
+++ b/scripts/fsadm.sh
@@ -748,49 +748,13 @@ create() {
vgname=$GROUP
fi
- # Devices are not in any group so we should find some.
- # Either create a new one, or use the existing one, if
- # there is only one vgroup, or use the one with enough
- # free space in it
if [ -z "$vgname" ]; then
- vgroups=$($LVM vgs -o vg_name,vg_free --separator ' ' --noheadings --units k 2> /dev/null)
- lines=$($LVM vgs -o vg_name,vg_free --separator ' ' --noheadings --units k 2> /dev/null | wc -l)
-
- if [ $lines -eq 1 ]; then
- vgname=$(echo $vgroups | sed -e 's/^ *//' | cut -d' ' -f1)
- elif [ $lines -gt 1 ]; then
- if [ -z $size ]; then
- error "Not enough information to create" \
- "logical volume"
- fi
- decode_size $size 1
- new_size=$NEWBLOCKCOUNT
- IFS=$NL
- for i in $vgroups; do
- vgsize=$(echo $i | sed -e 's/^ *//' | cut -d' ' -f2)
- vgsize=${vgsize%%B}
- if [ $vgsize -ge $new_size ]; then
- vgname=$(echo $i | sed -e 's/^ *//' | cut -d' ' -f1)
- break;
- fi
- done
+ vgname=$DEFAULT_POOL
+ $LVM vgs $vgname &> /dev/null
+ if [ $? -ne 0 ]; then
+ vg_create=1
fi
fi
- IFS=$IFS_OLD
-
- if [ -z "$vgname" ]; then
- [ $devcount -eq 0 ] && error "No suitable device specified."
- for i in $(seq -w $MAX_VGS); do
- $LVM vgs vg${i} &> /dev/null
- if [ $? -ne 0 ]; then
- vgname="vg${i}"
- break;
- fi
- done
- vg_create=1
- fi
-
- [ -z "$vgname" ] && error "No suitable name for volume group found."
if [ "$stripesize" ] || [ "$stripes" ]; then
if [ -z "$stripesize" ]; then
@@ -1242,17 +1206,9 @@ add() {
$LVM vgs -o vg_name --separator ' ' --noheadings | sed -e 's/^ *//' > $tmp
if [ -z "$vgname" ]; then
- lines=$(wc -l $tmp)
- lines=${lines%% *}
-
- if [ $lines -eq 1 ]; then
- vgname=$(cut -d' ' -f1 $tmp)
- elif [ $lines -gt 1 ]; then
- list_pool
- rm -f $tmp
- error "Please, specify group you want to add the device into"
- elif [ $lines -eq 0 ]; then
- vgname="vg001"
+ vgname=$DEFAULT_POOL
+ grep $vgname $tmp &> /dev/null
+ if [ $? -ne 0 ]; then
vg_create=1
fi
else
--
1.7.4.4
More information about the linux-lvm
mailing list