Skip to content

Commit

Permalink
Handle XFS resizing.
Browse files Browse the repository at this point in the history
XFS resizing is now handled as expected. Additionally, a bug has been
corrected where ext2/3/4 resizing would not have worked due to rc.local not
executing on RHEL/CentOS 7.

(cherry picked from commit aae2ba01d85066a20cb35e5d9f26859a801469c8)
  • Loading branch information
Michael Wilson authored and Bill Havanki committed Jun 18, 2018
1 parent 2c264ea commit c8eed95
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ df -h

ROOT_PARTITION_DEVICE=$(findmnt -n --evaluate -o SOURCE --target /)
ROOT_DEVICE=$(echo $ROOT_PARTITION_DEVICE | sed -e "s/\(p\|\)[0-9]*$//")
ROOT_DEVICE_TYPE=$(findmnt -n --evaluate -o FSTYPE --target /)

# If the root partition is already using 95% or more of the root device skip the resize operation

Expand Down Expand Up @@ -71,12 +72,6 @@ ${START_SECTOR},,,${BOOTABLE}
0,0
EOF

# To complete the process resize2fs needs to be called after reboot (if there is no cloud-init)

if ! hash cloud-init; then
echo "resize2fs \"${ROOT_PARTITION}\"" >> /etc/rc.local
fi

else

# GPT partitions require gdisk for resizing.
Expand All @@ -100,4 +95,16 @@ else

fi

# cloud-init does not guarantee the resizing of an instance, so we will attempt to grow the
# instance after a reboot.

if [ "$ROOT_DEVICE_TYPE" = "xfs" ]; then
echo "xfs_growfs /" >> /etc/rc.local
else
echo "resize2fs \"${ROOT_PARTITION_DEVICE}\"" >> /etc/rc.local
fi

# /etc/rc.local is not necessarily marked executable on RHEL/CentOS 7, so we ensure that it is
chmod +x /etc/rc.local

exit 0

0 comments on commit c8eed95

Please sign in to comment.