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)
|
||||
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)
|
||||
DEVICE=$(readlink -f "$DEVICE")
|
||||
FSTYPE=$(echo "$MOUNT_LINE" | cut -d' ' -f3)
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "growpart command is missing"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ $(grep mapper /etc/fstab |grep ' / ' |wc -l) -eq 0 ]; then
|
||||
DEVICE=$(readlink -f "$DEVICE")
|
||||
DISK=$(echo "$DEVICE" | sed 's/.$//')
|
||||
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
|
||||
echo DEVICE: $DEVICE
|
||||
echo FSTYPE: $FSTYPE
|
||||
echo DISK: $DISK
|
||||
echo PARTITION: $PARTITION
|
||||
fi
|
||||
|
||||
growpart "$DISK" "$PARTITION"
|
||||
|
||||
case "$FSTYPE" in
|
||||
ext2|ext3|ext4)
|
||||
resize2fs "$DEVICE"
|
||||
;;
|
||||
xfs)
|
||||
xfs_growfs /
|
||||
;;
|
||||
esac
|
||||
if [ -n "$DEBUG" ]; then
|
||||
echo DEVICE: ${DEVICE}
|
||||
echo FSTYPE: ${FSTYPE}
|
||||
echo DISK: ${DISK}
|
||||
echo PARTITION: ${PARTITION}
|
||||
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