-
Notifications
You must be signed in to change notification settings - Fork 2
/
expand.sh
executable file
·41 lines (32 loc) · 1.08 KB
/
expand.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/sh
#
# This file's responsibility is to expand the file system on the first run.
#
# This script will be executed once on each box, if the file in $SHOULD_AUTO_EXPAND
# exists. After that, it will not run
#
DIR="$(cd "$(dirname "$0")" && pwd)"
SHOULD_AUTO_EXPAND=/boot/auto_expand
NEED_AUTO_EXPAND="$DIR/../expanded"
. $DIR/util.sh
if [ ! -e $NEED_AUTO_EXPAND ]; then
if [ -e $SHOULD_AUTO_EXPAND ]; then
message "Checking if Filesystem needs expanding..."
SIZE=$(df --output=size,target | grep /$ | sed -e /Size/d | sed 's: /$::g')
if [ "$SIZE" -lt "2000000" ]; then
message "Expanding Filesystem..."
sudo raspi-config --expand-rootfs
touch $NEED_AUTO_EXPAND
message "Rebooting..."
sleep 1
sudo reboot
else
message "Filesystem already bigger than 2GB, assuming expansion already took place and continuing."
touch $NEED_AUTO_EXPAND
fi
else
message "$SHOULD_AUTO_EXPAND not present, will not automatically expand filesystem!"
fi
else
message "Filesystem already marked as expanded, nothing to do here..."
fi