Skip to content

Commit 8b3bcaf

Browse files
authored
Merge pull request #1126 from chrisx8/master
Automatically expand filesystem on mounted volumes when they have grown
2 parents 49ee9b7 + b150b7d commit 8b3bcaf

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pkg/cidata/cidata.TEMPLATE.d/boot/05-persistent-data-volume.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,15 @@ DATADIRS="/etc /home /root /tmp /usr/local /var/lib"
1414
if [ "$(awk '$2 == "/" {print $3}' /proc/mounts)" == "tmpfs" ]; then
1515
mkdir -p /mnt/data
1616
if [ -e /dev/disk/by-label/data-volume ]; then
17+
# Find which disk is data volume on
18+
DATA_DISK=$(blkid | grep "data-volume" | awk '{split($0,s,":"); sub(/\d$/, "", s[1]); print s[1]};')
19+
# Automatically expand the data volume filesystem
20+
growpart "$DATA_DISK" 1 || true
21+
# Only resize when filesystem is in a healthy state
22+
if e2fsck -f -p /dev/disk/by-label/data-volume; then
23+
resize2fs /dev/disk/by-label/data-volume
24+
fi
25+
# Mount data volume
1726
mount -t ext4 /dev/disk/by-label/data-volume /mnt/data
1827
else
1928
# Find an unpartitioned disk and create data-volume

0 commit comments

Comments
 (0)