summaryrefslogtreecommitdiff
path: root/packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-bottom/xfs_growfs
blob: f27fb13fad8f314fe773b0f84dbf1c634d077c3e (plain)
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/bin/sh
# Copyright 2018 Google Inc. All Rights Reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

PREREQ=""
prereqs()
{
  echo "$PREREQ"
}

case $1 in
  prereqs)
    prereqs
    exit 0
    ;;
esac

. /scripts/functions

if ! real_root=$(resolve_device "${ROOT}"); then
  log_failure_message "Failed to resolve root device for \"${ROOT}\""
fi

if ! fs_type=$(get_fstype "${real_root}"); then
  log_failure_message "Failed to determine fstype for \"${real_root}\""
fi

if [ $fs_type != "xfs" ]; then
  exit 0
fi

if ! command -v xfs_growfs >/dev/null; then
  echo "XFS resize requested, but xfs_growfs not installed."
  exit 0
fi

if xfs_growfs -d -n /; then
  log_begin_msg "Resizing xfs filesystem on ${real_root}"
  if ! out=$(xfs_growfs -d /); then
    log_failure_msg "Failed to resize ${real_root}: ${out}"
    exit 1
  fi
  log_end_msg
fi

exit 0