脚本新增未扩展磁盘容量

Posted ssslinppp

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了脚本新增未扩展磁盘容量相关的知识,希望对你有一定的参考价值。

当前物理存储容量


  1. df -h /data | grep data | awk ‘{print$(NF-4)}‘


新增未扩展磁盘容量


  1. #!/bin/bash
  2. #################################################
  3. # Create by liulin
  4. # 2016912 17:37:57
  5. ##################################################
  6. log_getUnExtendDisk="/data/logs/log_getUnExtendDisk.log"
  7. echo "====================================================" > $log_getUnExtendDisk
  8. echo "Begin to get UnExtendDisk storage at `date "+%Y-%m-%d %H:%M:%S"`" >> $log_getUnExtendDisk
  9. diskSizeCount="0"
  10. fdisk_tmp="/data/fdisk_tmp"
  11. pvs_tmp="/data/pvs_tmp"
  12. diffSet_tmp="/data/diffSet_tmp"
  13. getUnLvmDisk()
  14. {
  15. fdisk -l | grep /dev/[sh]d.: | awk -F ‘ ‘ ‘{print $2}‘ | awk -F ‘:‘ ‘{print $1}‘ > $fdisk_tmp
  16. # pvs | grep /dev/[sh]d. | awk -F ‘ ‘ ‘{print $1}‘ > $pvs_tmp
  17. pvscan | grep /dev/[sh]d. | awk -F ‘ ‘ ‘{print $2}‘ > $pvs_tmp
  18. #get Difference set
  19. # sort $fdisk_tmp $pvs_tmp $pvs_tmp | uniq -u > $diffSet_tmp
  20. grep -F -v -f $pvs_tmp $fdisk_tmp > $diffSet_tmp
  21. echo "-----------------------------" >> $log_getUnExtendDisk
  22. echo "fdisk_info is :" >> $log_getUnExtendDisk
  23. cat $fdisk_tmp >> $log_getUnExtendDisk
  24. echo "pvs_info is :" >> $log_getUnExtendDisk
  25. cat $pvs_tmp >> $log_getUnExtendDisk
  26. echo "diffSet is:" >> $log_getUnExtendDisk
  27. cat $diffSet_tmp >> $log_getUnExtendDisk
  28. echo "----------------------------" >> $log_getUnExtendDisk
  29. rm -rf $fdisk_tmp
  30. rm -rf $pvs_tmp
  31. }
  32. getUnLvmDisk
  33. content=`cat $diffSet_tmp`
  34. for dev_disk in $content then;
  35. do
  36. if [ $dev_disk != "/dev/sda" ] && [ $dev_disk != "/dev/hda" ] && [ `echo $dev_disk | wc -L` == 8 ];then
  37. # echo "+++++++++++++++++ [$dev_disk]"
  38. diskSize=`fdisk -l $dev_disk | grep /dev/[sh]d.: | awk ‘{print $3}‘ | awk -F ‘.‘ ‘{print $1}‘`
  39. echo " [$dev_disk] size is: $diskSize" >> $log_getUnExtendDisk
  40. diskSizeCount=$[ diskSizeCount + diskSize ]
  41. echo "curr diskSizeCount is: [$diskSizeCount]" >> $log_getUnExtendDisk
  42. fi
  43. done
  44. echo -e "----------------------------\n diskSizeCount : $diskSizeCount" >> $log_getUnExtendDisk
  45. echo $diskSizeCount

















附件列表

     

    以上是关于脚本新增未扩展磁盘容量的主要内容,如果未能解决你的问题,请参考以下文章

    如何扩展ESXi虚拟机磁盘容量

    Linux扩展分区和文件系统

    df、du、磁盘分区

    (10)横向扩展ceph集群

    vmware中ubuntu系统扩展磁盘

    qcow2 磁盘在线扩容方法