Files
shell-scripts/常用脚本/adding_rootvg-lvswap_To_rootvg-lvroot.sh
2024-11-27 10:33:20 +08:00

30 lines
1.0 KiB
Bash
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/bin/bash
echo "-----------------------------------------------------------------------"
RootVolumeSizeBefore=$(df -TH | grep -w "/dev/mapper/rootvg-lvroot" | awk '{print $3}')
echo "扩容之前的root目录的容量为${RootVolumeSizeBefore}"
echo "y
" | lvremove /dev/rootvg/lvswap
freepesize=$(vgdisplay rootvg | grep 'Free PE' | awk '{print $5}')
lvextend -l+${freepesize} /dev/rootvg/lvroot
## #自动扩展XFS文件系统到最大的可用大小
xfs_growfs /dev/rootvg/lvroot
df -TH | grep -w "/dev/mapper/rootvg-lvroot" | awk '{print $3}'
echo "-----------------------------------------------------------------------"
RootVolumeSizeAfter=$(df -TH | grep -w "/dev/mapper/rootvg-lvroot" | awk '{print $3}')
echo "扩容之后的root目录的容量为${RootVolumeSizeAfter}"
RootVolumeSizeBeforeNum=$(echo $RootVolumeSizeBefore | cut -d "G" -f1)
RootVolumeSizeAfterNum=$(echo $RootVolumeSizeAfter | cut -d "G" -f1)
echo "恭喜您的root目录容量增加了+++++++$(( ${RootVolumeSizeAfterNum}-${RootVolumeSizeBeforeNum} ))GB+++++"