parent
03e12b5f7c
commit
525a507d3f
@ -1,34 +1,51 @@
|
|||||||
#!/bin/bash
|
#!/bin/sh
|
||||||
|
set -e
|
||||||
|
|
||||||
|
MOUNT_LINE=$(cat /etc/mtab | grep ' / ' | grep -v '^rootfs')
|
||||||
|
DEVICE=$(echo "$MOUNT_LINE" | cut -d' ' -f1)
|
||||||
|
FSTYPE=$(echo "$MOUNT_LINE" | cut -d' ' -f3)
|
||||||
GROWPART=$(which growpart)
|
GROWPART=$(which growpart)
|
||||||
if [[ ${?} -ne 0 ]]
|
|
||||||
then
|
|
||||||
echo "Skipping growfs, growpart command is missing"
|
|
||||||
else
|
|
||||||
MOUNT_LINE=$(cat /etc/mtab | grep ' / ' | grep -v '^rootfs')
|
|
||||||
|
|
||||||
DEVICE=$(echo "$MOUNT_LINE" | cut -d' ' -f1)
|
if [ $? -ne 0 ]; then
|
||||||
DEVICE=$(readlink -f "$DEVICE")
|
echo "growpart command is missing"
|
||||||
FSTYPE=$(echo "$MOUNT_LINE" | cut -d' ' -f3)
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ $(grep mapper /etc/fstab |grep ' / ' |wc -l) -eq 0 ]; then
|
||||||
|
DEVICE=$(readlink -f "$DEVICE")
|
||||||
DISK=$(echo "$DEVICE" | sed 's/.$//')
|
DISK=$(echo "$DEVICE" | sed 's/.$//')
|
||||||
PARTITION=$(echo "$DEVICE" | sed "s|^$DISK||")
|
PARTITION=$(echo "$DEVICE" | sed "s|^$DISK||")
|
||||||
|
LVM="no"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ "${LVM}" != "no" ]; then
|
||||||
|
PVRESIZE=$(which pvresize)
|
||||||
|
LVEXTEND=$(which lvextend)
|
||||||
|
DISK=$(pvdisplay |grep "PV Name"|awk '{print $3}'|sed 's/.$//')
|
||||||
|
PARTITION=$(pvdisplay |grep "PV Name"|awk '{print $3}'| sed "s|^${DISK}||")
|
||||||
|
PV=$(pvdisplay |grep "PV Name"|awk '{print $3}')
|
||||||
|
LV=$(lvdisplay ${DEVICE} |grep "LV Path"|awk '{print $3}')
|
||||||
|
fi
|
||||||
|
|
||||||
if [ -n $DEBUG ]; then
|
if [ -n "$DEBUG" ]; then
|
||||||
echo DEVICE: $DEVICE
|
echo DEVICE: ${DEVICE}
|
||||||
echo FSTYPE: $FSTYPE
|
echo FSTYPE: ${FSTYPE}
|
||||||
echo DISK: $DISK
|
echo DISK: ${DISK}
|
||||||
echo PARTITION: $PARTITION
|
echo PARTITION: ${PARTITION}
|
||||||
fi
|
|
||||||
|
|
||||||
growpart "$DISK" "$PARTITION"
|
|
||||||
|
|
||||||
case "$FSTYPE" in
|
|
||||||
ext2|ext3|ext4)
|
|
||||||
resize2fs "$DEVICE"
|
|
||||||
;;
|
|
||||||
xfs)
|
|
||||||
xfs_growfs /
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
${GROWPART} ${DISK} ${PARTITION}
|
||||||
|
|
||||||
|
if [ "${LVM}" != "no" ]; then
|
||||||
|
${PVRESIZE} ${PV}
|
||||||
|
${LVEXTEND} -l +100%FREE ${LV}
|
||||||
|
fi
|
||||||
|
|
||||||
|
case "${FSTYPE}" in
|
||||||
|
ext2|ext3|ext4)
|
||||||
|
resize2fs ${DEVICE}
|
||||||
|
;;
|
||||||
|
xfs)
|
||||||
|
xfs_growfs /
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
Loading…
Reference in new issue