Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: correctly select root disk partition #1244

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions ansible/files/admin_api_scripts/grow_fs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,27 @@ if pgrep resizefs; then
exit 1
fi

# Parses the output of lsblk to get the root partition number
# Example output:
# NAME MOUNTPOINT
# nvme0n1
# ├─nvme0n1p1 /boot
# └─nvme0n1p3 /
# nvme1n1 /data
#
# Resulting in:
# └─nvme0n1p3 / -> nvme0n1p3 -> 3
ROOT_PARTITION_NUMBER=$(lsblk -no NAME,MOUNTPOINT | grep ' /$' | awk '{print $1;}' | sed 's/.*nvme[0-9]n[0-9]p//g')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe add a sanity check on the extracted value?


if [ -b /dev/nvme1n1 ] ; then
if [[ "${VOLUME_TYPE}" == "data" ]]; then
resize2fs /dev/nvme1n1

elif [[ "${VOLUME_TYPE}" == "root" ]] ; then
PLACEHOLDER_FL=/home/ubuntu/50M_PLACEHOLDER
rm -f "${PLACEHOLDER_FL}" || true
growpart /dev/nvme0n1 2
resize2fs /dev/nvme0n1p2
growpart /dev/nvme0n1 "${ROOT_PARTITION_NUMBER}"
resize2fs "/dev/nvme0n1p${ROOT_PARTITION_NUMBER}"
if [[ ! -f "${PLACEHOLDER_FL}" ]] ; then
fallocate -l50M "${PLACEHOLDER_FL}"
fi
Expand All @@ -26,7 +38,7 @@ if [ -b /dev/nvme1n1 ] ; then
exit 1
fi
else
growpart /dev/nvme0n1 2
resize2fs /dev/nvme0n1p2
growpart /dev/nvme0n1 "${ROOT_PARTITION_NUMBER}"
resize2fs "/dev/nvme0n1p${ROOT_PARTITION_NUMBER}"
fi
echo "Done resizing disk"
Loading