50FilesystemResizeMounted.in 1.76 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:		FilesystemResizeMounted
Nikos Skalkotos's avatar
Nikos Skalkotos committed
22
# RunBefore:            UmountImage
23
# RunAfter:		InstallUnattend
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
31
32
# Check if the task should be prevented from running.
check_if_excluded

Nikos Skalkotos's avatar
Nikos Skalkotos committed
33
if [ ! -d "$SNF_IMAGE_TARGET" ]; then
34
    log_error "Target directory \`$SNF_IMAGE_TARGET' is missing"
Nikos Skalkotos's avatar
Nikos Skalkotos committed
35
36
fi

37
38
39
40
if [ "$SNF_IMAGE_PROPERTY_OSFAMILY" != "windows" ]; then
    exit 0
fi

41
42
table=$(get_partition_table "$SNF_IMAGE_DEV")
last_partition=$(get_last_partition "$table")
43
44
45
46
id=$(echo "$last_partition" | cut -d: -f1)
ptype=$(echo "$last_partition" | cut -d: -f5)

if [ "$ptype" = "ntfs" ]; then
47
48
49
    # Write a diskpart script to %SystemDrive%\Windows\SnfScripts. Sysprep will
    # try to execute this script during the specialize pass.
    cat > "$SNF_IMAGE_TARGET/Windows/SnfScripts/ExtendFilesystem" <<EOF
Nikos Skalkotos's avatar
Nikos Skalkotos committed
50
select disk 0
51
select volume $id
Nikos Skalkotos's avatar
Nikos Skalkotos committed
52
53
54
extend filesystem
exit
EOF
55
fi
Nikos Skalkotos's avatar
Nikos Skalkotos committed
56
57
58
59

exit 0

# vim: set sta sts=4 shiftwidth=4 sw=4 et ai :