20FilesystemResizeUnmounted.in 1.41 KB
Newer Older
1
#! /bin/bash
Nikos Skalkotos's avatar
Nikos Skalkotos committed
2

3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# Copyright (C) 2011 GRNET S.A. 
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
# General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.

Nikos Skalkotos's avatar
Nikos Skalkotos committed
20
### BEGIN TASK INFO
21
# Provides:		FilesystemResizeUnmounted
Nikos Skalkotos's avatar
Nikos Skalkotos committed
22
# RunBefore:		MountImage
23
# RunAfter:             FixPartitionTable
Nikos Skalkotos's avatar
Nikos Skalkotos committed
24
# Short-Description:	Resize filesystem to use all the available space
25
### END TASK INFO
Nikos Skalkotos's avatar
Nikos Skalkotos committed
26
27

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

30
if [ ! -b "$SNF_IMAGE_DEV" ]; then
31
    log_error "Device file:\`${SNF_IMAGE_DEV}' is not a block device"
Nikos Skalkotos's avatar
Nikos Skalkotos committed
32
fi
33
34
35
36
37

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

38
39
if [[ "$ptype" == ext[234] ]]; then
    device="${SNF_IMAGE_DEV}${id}"
40
    $E2FSCK -f -y "$device"
41
    $RESIZE2FS "$device"
42
fi
Nikos Skalkotos's avatar
Nikos Skalkotos committed
43
44

exit 0
45

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