#! /bin/sh #---------------------------------------------------------------------------- # system-devices-lv-resize - resize logical volumes # # Copyright (c) 2008 The Eisfair Team # # Creation : 02.09.2009 schlotze # Last Update: $Id$ # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. #---------------------------------------------------------------------------- . /var/install/include/eislib echo #exec 2> /tmp/system-devices-lv-resize-trace$$.log #set -x modprobe dm_mod mecho -info "Resize volume groups" mecho mecho mecho -info "Available logical volumes" mecho techo begin 4 27 32 8 9r techo row -info No. -info "LV" -info "VG" -info "Attr" -info "VSize" mecho -info "================================================================================" idx=1 lvs > /tmp/tmp_lvs$$ while read line do set -- $line if [ "$1" != "LV" ] then eval lv_$idx='"$1"' eval vg_$idx='"$2"' techo row $idx $1 $2 $3 $4 idx=`expr $idx + 1` fi done < /tmp/tmp_lvs$$ rm /tmp/tmp_lvs$$ mecho idx=`expr $idx - 1` nolvdevice=`/var/install/bin/ask "Please choose a volume which you want to resize" "" "1-$idx" "0=Exit"` if [ "$nolvdevice" != "0" ] then eval "lvdevice"='$lv_'$nolvdevice eval "vgdevice"='$vg_'$nolvdevice # check if lv is mounted if mount | grep -q "/dev/${vgdevice}/${lvdevice}" then mecho -error "You cannot resize a mounted logical volume!" exit 1 else if mount | grep -q "/dev/mapper/${vgdevice}-${lvdevice}" then mecho -error "You cannot resize a mounted logical volume!" exit 1 fi fi extend=`/var/install/bin/ask "Do you want to expand the logical volume?" "no"` mecho if [ "$extend" = "no" ] then reduce=`/var/install/bin/ask "Do you want to reduce the logical volume?" "no"` if [ "$reduce" = "yes" ] then size=`/var/install/bin/ask "Please enter the size you want to reduce the logical volume in megabyte (e.g. 100)" "" "1-999999" "0=Exit"` if [ "$size" != "0" ] then lvreduce -L-$size /dev/$vgdevice/$lvdevice fi fi else size=`/var/install/bin/ask "Please enter the size you want to expand the logical volume in megabyte (e.g. 100)" "" "1-999999" "0=Exit"` if [ "$size" != "0" ] then lvextend -L+$size /dev/$vgdevice/$lvdevice fi fi #umount #e2fsck -f /dev/$vgdevice/$lvdevice #resize2fs /dev/$vgdevice/$lvdevice mecho -warn "You have to check and resize the filesystem manually!" mecho "You can do this by running:" mecho "e2fsck -f /dev/$vgdevice/$lvdevice" mecho "resize2fs /dev/$vgdevice/$lvdevice" fi echo anykey exit 0