2017-10-18 16:57:39 +02:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Possibly resize root device (partition, filesystem), if underlying device was
|
|
|
|
# enlarged.
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# if underlying root device is read-only, don't do anything
|
|
|
|
if [ "$(blockdev --getro /dev/xvda)" -eq "1" ]; then
|
|
|
|
echo "xvda is read-only, not resizing" >&2
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
sysfs_xvda="/sys/class/block/xvda"
|
|
|
|
|
|
|
|
# if root filesystem use already (almost) the whole dis
|
2018-12-01 05:59:42 +01:00
|
|
|
size_margin=$(( 250 * 1024 * 2 ))
|
2018-12-01 05:53:45 +01:00
|
|
|
rootfs_size=$(df --block-size=512 --output=size / | tail -n 1 | tr -d ' ')
|
2018-12-01 22:18:06 +01:00
|
|
|
if [ $(cat $sysfs_xvda/size) -lt \
|
2018-12-01 05:59:42 +01:00
|
|
|
$(( size_margin + rootfs_size )) ]; then
|
2018-09-04 17:43:49 +02:00
|
|
|
echo "root filesystem already at $rootfs_size blocks" >&2
|
2017-10-18 16:57:39 +02:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
|
|
|
# resize needed, do it
|
|
|
|
/usr/lib/qubes/resize-rootfs
|