20FilesystemResizeUnmounted.in 673 Bytes
Newer Older
1
#! /bin/bash
Nikos Skalkotos's avatar
Nikos Skalkotos committed
2
3

### BEGIN TASK INFO
4
# Provides:		FilesystemResizeUnmounted
Nikos Skalkotos's avatar
Nikos Skalkotos committed
5
# RunBefore:		MountImage
6
# RunAfter:             FixPartitionTable
Nikos Skalkotos's avatar
Nikos Skalkotos committed
7
# Short-Description:	Resize filesystem to use all the available space
8
### END TASK INFO
Nikos Skalkotos's avatar
Nikos Skalkotos committed
9
10

set -e
11
. "@commondir@/common.sh"
Nikos Skalkotos's avatar
Nikos Skalkotos committed
12

13
if [ ! -b "$SNF_IMAGE_DEV" ]; then
14
    log_error "Device file:\`${SNF_IMAGE_DEV}' is not a block device"
Nikos Skalkotos's avatar
Nikos Skalkotos committed
15
fi
16
17
18
19
20

last_partition=$(get_last_partition "$SNF_IMAGE_DEV")
id=$(echo "$last_partition" | cut -d: -f1)
ptype=$(echo "$last_partition" | cut -d: -f5)

21
22
if [[ "$ptype" == ext[234] ]]; then
    device="${SNF_IMAGE_DEV}${id}"
23
24
    "$RESIZE2FS" "$device"
fi
Nikos Skalkotos's avatar
Nikos Skalkotos committed
25
26

exit 0
27

Nikos Skalkotos's avatar
Nikos Skalkotos committed
28
# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :