Skip to content

Instantly share code, notes, and snippets.

@omartrigui
Last active March 25, 2021 17:04
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save omartrigui/7d6ec92c8f2ef83ba15b80e30fb6a5be to your computer and use it in GitHub Desktop.
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.
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
@thiagosanches
Copy link

thiagosanches commented Feb 27, 2018

It worked, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment