Merge pull request #43 from laurencegill/master

Chaned to handle lvm and regular partitions
pull/49/head
Javi Fontan 9 years ago
commit 4ebe19e082

@ -1,34 +1,54 @@
#!/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 [ -n $DEBUG ]; then
echo DEVICE: $DEVICE
echo FSTYPE: $FSTYPE
echo DISK: $DISK
echo PARTITION: $PARTITION
if [ "${LVM}" != "no" ]; then
if [ -f /etc/debian_version ]; then
DEVICE=$(mount | grep ' / ' | grep -v '^rootfs'|cut -d' ' -f1)
fi
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"
${GROWPART} ${DISK} ${PARTITION}
case "$FSTYPE" in
ext2|ext3|ext4)
resize2fs "$DEVICE"
;;
xfs)
xfs_growfs /
;;
esac
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…
Cancel
Save