Skip to content

Instantly share code, notes, and snippets.

@aderumier
Created November 19, 2022 15:38
Show Gist options
  • Save aderumier/d06677cbb16602a9a4a3f6c5772028df to your computer and use it in GitHub Desktop.
Save aderumier/d06677cbb16602a9a4a3f6c5772028df to your computer and use it in GitHub Desktop.
/etc/udev/rules.d/90-resizefs.rules
-----------------------------------
ACTION=="change", SUBSYSTEM=="block", ENV{DEVTYPE}=="disk", RUN+="/usr/local/bin/resizefs.sh"
/usr/local/bin/resizefs.sh
--------------------------
#!/bin/bash
if [ -n "$DEVNAME" ]; then
if [ "$ID_FS_TYPE" == "ext4" ] || [ "$ID_FS_TYPE" == "ext3" ]; then
resize2fs $DEVNAME
fi
if [ "$ID_FS_TYPE" == "xfs" ]; then
MOUNTPOINT=`lsblk -o MOUNTPOINT -nr $DEVNAME`
if [ -n "$MOUNTPOINT" ]; then
xfs_growfs $MOUNTPOINT
fi
fi
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment