2016-08-17 21:47:22 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
2017-09-30 04:45:31 +02:00
|
|
|
read -r disk_name
|
2016-08-17 21:47:22 +02:00
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
case $disk_name in
|
|
|
|
private)
|
|
|
|
# force some read to refresh device size
|
|
|
|
head /dev/xvdb > /dev/null
|
|
|
|
resize2fs /dev/xvdb
|
|
|
|
;;
|
|
|
|
root)
|
|
|
|
# force some read to refresh device size
|
|
|
|
head /dev/xvda > /dev/null
|
2017-10-02 19:42:00 +02:00
|
|
|
if [ "$(stat -Lc %t /dev/mapper/dmroot)" != "ca" ]; then
|
|
|
|
new_size=$(cat /sys/block/xvda/size)
|
|
|
|
ro=$(/sys/block/xvda/ro)
|
|
|
|
if [ "$ro" -eq 1 ]; then
|
|
|
|
new_table="0 $new_size snapshot /dev/xvda /dev/xvdc2 N 16"
|
|
|
|
else
|
|
|
|
new_table="0 $new_size linear /dev/xvda 0"
|
|
|
|
fi
|
|
|
|
dmsetup load dmroot --table "$new_table"
|
|
|
|
dmsetup resume dmroot
|
2016-08-17 21:47:22 +02:00
|
|
|
fi
|
|
|
|
resize2fs /dev/mapper/dmroot
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Automatic resize of '$disk_name' not supported" >&2
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|