Resize the logical volume even if there is not file system on it. Signed-off-by: Lukas Czerner <lczerner@redhat.com> --- scripts/fsadm.sh | 28 ++++++++++++++++++++-------- 1 files changed, 20 insertions(+), 8 deletions(-) diff --git a/scripts/fsadm.sh b/scripts/fsadm.sh index 3b47a21..112ad62 100755 --- a/scripts/fsadm.sh +++ b/scripts/fsadm.sh @@ -630,10 +630,18 @@ resize() { # only one of those variable should be set, so it is safe to do that decode_size $extend $shrink $new_size 1 detect_fs $lvname - detect_fs_size + # What if there is not file system on the volume + if [ -z $FSTYP ]; then + total=$(LANG=C $LVM lvs -o lv_size --separator ' ' --noheadings --units k $lvname 2> /dev/null) + total=${total%%.*} + else + detect_fs_size + fi + [ -z $total ] && error "Could not determine the size of the volume" [ "$extend" ] && size=$(($total + $NEWSIZE)) [ "$shrink" ] && size=$(($total - $NEWSIZE)) if [ "$new_size" ]; then + # NEWSIZE is decoded new_size [ $NEWSIZE -ge $total ] && extend=1 || shrink=1 size=$NEWSIZE fi @@ -641,15 +649,19 @@ resize() { # Do the actual resize if [ "$shrink" ]; then - resize_fs $lvname $size - # The file system might decide to alight the size a bit, so we - # have to resize the volume to the exact size of the file system - # so we do not corrupt it. - detect_fs_size - resize_lvolume $lvname $total + if [ "$FSTYPE" ]; then + resize_fs $lvname $size + # The file system might decide to alight the size a bit, so we + # have to resize the volume to the exact size of the file system + # so we do not corrupt it. + detect_fs_size + fi + resize_lvolume $lvname $size elif [ "$extend" ]; then resize_lvolume $lvname $size - resize_fs $lvname + if [ "$FSTYPE" ]; then + resize_fs $lvname + fi fi } -- 1.7.4.4 _______________________________________________ linux-lvm mailing list linux-lvm@redhat.com https://www.redhat.com/mailman/listinfo/linux-lvm read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/