Last active
March 25, 2021 17:04
-
-
Save omartrigui/7d6ec92c8f2ef83ba15b80e30fb6a5be to your computer and use it in GitHub Desktop.
Expanding (resize) persistent & mounted Centos 7 disk size in Custom Google Compute Image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sudo yum install -y cloud-utils-growpart | |
# You can use lsblk command to check the total available space of you disk. | |
# growpart is used to to expand a partition to the whole disk (expand sda1 to sda) | |
# xfs_growfs is used to resize and apply the changes | |
# df -h | |
# For more informations : https://blog.myduniahosting.com/how-to-resize-your-root-diskpartition-online-for-linux/ | |
part=`df --output=source / |grep "/dev/"` | |
if [ ! -z "$part" ] ; then | |
len=${#part} | |
p=`echo $part|cut -c$len` | |
d=`echo $part|cut -c1-$(($len-1))` | |
growpart "$d" "$p" | |
xfs_growfs "$part" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It worked, thanks!