Skip to content

Instantly share code, notes, and snippets.

@omartrigui
Last active August 10, 2025 02:48
Show Gist options
  • Select an option

  • Save omartrigui/7d6ec92c8f2ef83ba15b80e30fb6a5be to your computer and use it in GitHub Desktop.

Select an option

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
Copy Markdown

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