summaryrefslogtreecommitdiff
path: root/localresizediskvol
blob: 36fa2858a3cb346157092a4f3076d0effe4a59e8 (plain)
  1. #!/bin/sh
  2. set -e
  3. dev=$1
  4. newsize=$2
  5. lowsize=$3
  6. [ -n "$dev" ] || (echo "Device not provided"; exit 1)
  7. [ -n "$newsize" ] || (echo "New size not provided"; exit 1)
  8. #TODO: Get maxsize (from lvm) and oldsize (from fs), and check that...
  9. # maxsize >= newsize > oldsize
  10. # or
  11. # lowsize defined and lowsize < newsize < oldsize
  12. #TODO: Use getopts to enable onlineresize
  13. #TODO: Check if filesystem supports online resizing if requested
  14. [ "$onlineresize" = "yes" ] || umount $dev
  15. [ "$onlineresize" = "yes" ] || e2fsck -f $dev
  16. [ -n "$lowsize" ] && resize2fs $dev $lowsize
  17. lvresize -L $newsize $dev
  18. resize2fs $dev
  19. [ "$onlineresize" = "yes" ] || mount $dev