From 34f9b61a3f4fbfb3235fa89252b4f0749c2d47d2 Mon Sep 17 00:00:00 2001 From: Liam Hopkins Date: Tue, 5 May 2020 15:52:38 -0700 Subject: move disk expand (#893) --- packages/gce-disk-expand/README.md | 13 +- packages/gce-disk-expand/dracut6_7.sh | 34 ----- .../gce-disk-expand/packaging/debian/changelog | 18 --- packages/gce-disk-expand/packaging/debian/compat | 1 - packages/gce-disk-expand/packaging/debian/control | 15 -- .../gce-disk-expand/packaging/debian/copyright | 27 ---- packages/gce-disk-expand/packaging/debian/install | 2 - packages/gce-disk-expand/packaging/debian/postinst | 26 ---- packages/gce-disk-expand/packaging/debian/rules | 4 - .../gce-disk-expand/packaging/gce-disk-expand.spec | 55 -------- packages/gce-disk-expand/packaging/setup_deb.sh | 41 ------ packages/gce-disk-expand/packaging/setup_rpm.sh | 37 ----- packages/gce-disk-expand/src/expandfs-lib.sh | 151 --------------------- .../share/dracut/modules.d/50expand_rootfs/check | 16 --- .../modules.d/50expand_rootfs/expand_rootfs.sh | 85 ------------ .../50expand_rootfs/expand_rootfs_dummy.sh | 3 - .../share/dracut/modules.d/50expand_rootfs/install | 31 ----- .../dracut/modules.d/50expand_rootfs/xfs_growfs.sh | 43 ------ .../usr/share/initramfs-tools/hooks/expand-rootfs | 40 ------ .../scripts/local-bottom/xfs_growfs | 57 -------- .../scripts/local-premount/expand_rootfs | 67 --------- 21 files changed, 3 insertions(+), 763 deletions(-) delete mode 100755 packages/gce-disk-expand/dracut6_7.sh delete mode 100644 packages/gce-disk-expand/packaging/debian/changelog delete mode 100644 packages/gce-disk-expand/packaging/debian/compat delete mode 100644 packages/gce-disk-expand/packaging/debian/control delete mode 100644 packages/gce-disk-expand/packaging/debian/copyright delete mode 100644 packages/gce-disk-expand/packaging/debian/install delete mode 100644 packages/gce-disk-expand/packaging/debian/postinst delete mode 100755 packages/gce-disk-expand/packaging/debian/rules delete mode 100644 packages/gce-disk-expand/packaging/gce-disk-expand.spec delete mode 100755 packages/gce-disk-expand/packaging/setup_deb.sh delete mode 100755 packages/gce-disk-expand/packaging/setup_rpm.sh delete mode 100755 packages/gce-disk-expand/src/expandfs-lib.sh delete mode 100755 packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/check delete mode 100755 packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs.sh delete mode 100755 packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs_dummy.sh delete mode 100755 packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/install delete mode 100755 packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/xfs_growfs.sh delete mode 100755 packages/gce-disk-expand/src/usr/share/initramfs-tools/hooks/expand-rootfs delete mode 100755 packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-bottom/xfs_growfs delete mode 100755 packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-premount/expand_rootfs (limited to 'packages') diff --git a/packages/gce-disk-expand/README.md b/packages/gce-disk-expand/README.md index f224ba5..44c51fe 100644 --- a/packages/gce-disk-expand/README.md +++ b/packages/gce-disk-expand/README.md @@ -1,11 +1,4 @@ -## gce-disk-expand package for CentOS/RHEL and Debian +## Google Compute Engine root disk expansion utility -This package is intended to expand the root partition up to 2TB on a GCE VM -without a GPT partition table and over 2TB on GPT partitioned UEFI enabled -images. - -This package has been tested on the following distros and versions. - -* RHEL/CentOS 7.4+ -* RHEL 8+ -* Debian 10+ +**This package has moved. The gce-disk-expand package is now located in the +[guest-diskexpand](https://github.com/GoogleCloudPlatform/guest-diskexpand) repo** diff --git a/packages/gce-disk-expand/dracut6_7.sh b/packages/gce-disk-expand/dracut6_7.sh deleted file mode 100755 index e414670..0000000 --- a/packages/gce-disk-expand/dracut6_7.sh +++ /dev/null @@ -1,34 +0,0 @@ -#!/bin/bash -# 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. - -# Modifies rhel6 dracut for rhel7. - -mv src/usr/share src/usr/lib -pushd src/usr/lib/dracut/modules.d/50expand_rootfs - -cat >module-setup.sh < Tue, 28 Apr 2020 10:24:07 -0700 - -gce-disk-expand (1:20190708.00-g1) stable; urgency=medium - - * Update disk expand to fix bugs with GPT. - - -- Google Cloud Team Mon, 08 Jul 2019 10:20:47 -0700 - -gce-disk-expand (2.0.0-1) stable; urgency=low - - * Initial debian package import. - * Standardize on initramfs scripts for disk resizing. - - -- Google Cloud Team Mon, 26 Nov 2018 12:00:00 -0700 diff --git a/packages/gce-disk-expand/packaging/debian/compat b/packages/gce-disk-expand/packaging/debian/compat deleted file mode 100644 index ec63514..0000000 --- a/packages/gce-disk-expand/packaging/debian/compat +++ /dev/null @@ -1 +0,0 @@ -9 diff --git a/packages/gce-disk-expand/packaging/debian/control b/packages/gce-disk-expand/packaging/debian/control deleted file mode 100644 index 92f2e1b..0000000 --- a/packages/gce-disk-expand/packaging/debian/control +++ /dev/null @@ -1,15 +0,0 @@ -Source: gce-disk-expand -Section: admin -Priority: optional -Maintainer: Google Cloud Team -Build-Depends: debhelper (>= 10) -Standards-Version: 3.9.8 -Homepage: https://github.com/GoogleCloudPlatform/compute-image-packages - -Package: gce-disk-expand -Architecture: all -Depends: parted, - gdisk, - ${misc:Depends} -Description: Automatically resize the root partition on first boot. - This package resizes the root partition on first boot using parted. diff --git a/packages/gce-disk-expand/packaging/debian/copyright b/packages/gce-disk-expand/packaging/debian/copyright deleted file mode 100644 index 14d05cc..0000000 --- a/packages/gce-disk-expand/packaging/debian/copyright +++ /dev/null @@ -1,27 +0,0 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: gce-disk-expand -Upstream-Contact: gc-team@google.com - -Files: * -Copyright: Copyright 2017 Google Inc. -License: Apache-2.0 - -Files: debian/* -Copyright: Copyright 2017 Google Inc. -License: Apache-2.0 - -License: Apache-2.0 - 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. - . - On Debian systems, the complete text of the Apache version 2.0 license - can be found in "/usr/share/common-licenses/Apache-2.0". diff --git a/packages/gce-disk-expand/packaging/debian/install b/packages/gce-disk-expand/packaging/debian/install deleted file mode 100644 index 976acf1..0000000 --- a/packages/gce-disk-expand/packaging/debian/install +++ /dev/null @@ -1,2 +0,0 @@ -src/usr/share/initramfs-tools usr/share/ -src/expandfs-lib.sh usr/share/initramfs-tools/scripts/ diff --git a/packages/gce-disk-expand/packaging/debian/postinst b/packages/gce-disk-expand/packaging/debian/postinst deleted file mode 100644 index 00f5b1e..0000000 --- a/packages/gce-disk-expand/packaging/debian/postinst +++ /dev/null @@ -1,26 +0,0 @@ -#!/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. - -#DEBHELPER# - -set -e - -case "$1" in - configure) - if which /usr/sbin/update-initramfs > /dev/null; then - update-initramfs -u - fi - ;; -esac diff --git a/packages/gce-disk-expand/packaging/debian/rules b/packages/gce-disk-expand/packaging/debian/rules deleted file mode 100755 index 2d33f6a..0000000 --- a/packages/gce-disk-expand/packaging/debian/rules +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/make -f - -%: - dh $@ diff --git a/packages/gce-disk-expand/packaging/gce-disk-expand.spec b/packages/gce-disk-expand/packaging/gce-disk-expand.spec deleted file mode 100644 index 3f6c0dc..0000000 --- a/packages/gce-disk-expand/packaging/gce-disk-expand.spec +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright 2016 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. -Name: gce-disk-expand -Summary: Google Compute Engine root disk expansion module -Epoch: 1 -Version: %{_version} -Release: g1 -License: Apache Software License -Group: System Environment/Base -URL: https://github.com/GoogleCloudPlatform/compute-image-packages -Source0: %{name}_%{version}.orig.tar.gz -Requires: e2fsprogs, dracut, grep, util-linux, parted, gdisk -Conflicts: dracut-modules-growroot - -BuildRequires: rsync - -# Allow other files in the source that don't end up in the package. -%define _unpackaged_files_terminate_build 0 - -%description -This package resizes the root partition on first boot using parted. - -%prep -%autosetup - -%install -mv src/expandfs-lib.sh src/usr/share/dracut/modules.d/50expand_rootfs/ -%if 0%{?rhel} >= 7 - ./dracut6_7.sh -%endif -rsync -Pravz src/ %{buildroot} - -%files -%if 0%{?rhel} >= 7 - %attr(755,root,root) /usr/lib/dracut/modules.d/50expand_rootfs/* -%else - %attr(755,root,root) /usr/share/dracut/modules.d/50expand_rootfs/* -%endif - -%post -dracut --force - -%postun -dracut --force diff --git a/packages/gce-disk-expand/packaging/setup_deb.sh b/packages/gce-disk-expand/packaging/setup_deb.sh deleted file mode 100755 index 1fc0a61..0000000 --- a/packages/gce-disk-expand/packaging/setup_deb.sh +++ /dev/null @@ -1,41 +0,0 @@ -#!/bin/bash -# 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. - -NAME="gce-disk-expand" -VERSION="20200428.00" - -working_dir=${PWD} -if [[ $(basename "$working_dir") != $NAME ]]; then - echo "Packaging scripts must be run from top of package dir." - exit 1 -fi - -# Build dependencies. -sudo apt-get -y install dh-systemd - -# DEB creation tools. -sudo apt-get -y install debhelper devscripts build-essential rsync - -rm -rf /tmp/debpackage -mkdir /tmp/debpackage -tar czvf /tmp/debpackage/${NAME}_${VERSION}.orig.tar.gz --exclude .git --exclude packaging --transform "s/^\./${NAME}-${VERSION}/" . - -cd /tmp/debpackage -tar xzvf ${NAME}_${VERSION}.orig.tar.gz - -cd ${NAME}-${VERSION} -cp -r ${working_dir}/packaging/debian ./ - -debuild -us -uc diff --git a/packages/gce-disk-expand/packaging/setup_rpm.sh b/packages/gce-disk-expand/packaging/setup_rpm.sh deleted file mode 100755 index 8a28e52..0000000 --- a/packages/gce-disk-expand/packaging/setup_rpm.sh +++ /dev/null @@ -1,37 +0,0 @@ -#!/bin/bash -# 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. - -NAME="gce-disk-expand" -VERSION="20200428.00" - -rpm_working_dir=/tmp/rpmpackage/ -working_dir=${PWD} -if [[ $(basename "$working_dir") != $NAME ]]; then - echo "Packaging scripts must be run from top of package dir." - exit 1 -fi - -# RPM creation tools. -sudo yum -y install rpmdevtools rsync - -rm -rf ${rpm_working_dir} -mkdir -p ${rpm_working_dir}/{SOURCES,SPECS} -cp packaging/${NAME}.spec ${rpm_working_dir}/SPECS/ - -tar czvf ${rpm_working_dir}/SOURCES/${NAME}_${VERSION}.orig.tar.gz \ - --exclude .git --exclude packaging --transform "s/^\./${NAME}-${VERSION}/" . - -rpmbuild --define "_topdir ${rpm_working_dir}/" --define "_version ${VERSION}" \ - -ba ${rpm_working_dir}/SPECS/${NAME}.spec diff --git a/packages/gce-disk-expand/src/expandfs-lib.sh b/packages/gce-disk-expand/src/expandfs-lib.sh deleted file mode 100755 index 657dcfa..0000000 --- a/packages/gce-disk-expand/src/expandfs-lib.sh +++ /dev/null @@ -1,151 +0,0 @@ -#!/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. - -kmsg() { - echo "gce-disk-expand: $@" > /dev/kmsg -} - -resize_filesystem() { - local disk="$1" fs_type="" - - if ! fs_type=$(blkid_get_fstype "$disk"); then - echo "$fs_type" - return 1 - fi - - case "${fs_type}" in - xfs) - kmsg "XFS filesystems must be mounted to be resized, deferring." - echo "true" > /tmp/xfs_resize - return 1 - ;; - ext*) - if ! out=$(e2fsck -pf "$disk"); then - local ret=$? - kmsg "Calling e2fsck \"${disk}\" failed: ${out} exit code ${ret}" - fi - if ! out=$(resize2fs "$disk"); then - kmsg "Calling resize2fs \"${disk}\" failed: ${out}" - return 1 - fi - ;; - *) - kmsg "Unsupported filesystem type ${fs_type}, unable to expand size." - return 1 - ;; - esac -} - -blkid_get_fstype() ( - local root="$1" - - kmsg "Getting fstype for $root with blkid." - if ! out=$(blkid -o udev "$root"); then - kmsg "Detecting fstype by blkid failed: ${out}" - return 1 - fi - - eval "$out" - if [ -z "$ID_FS_TYPE" ]; then - kmsg "No ID_FS_TYPE from blkid." - return 1 - fi - echo $ID_FS_TYPE -) - -sgdisk_get_label() { - local root="$1" - [ -z "$root" ] && return 0 - - kmsg "Getting $root label with sgdisk." - if sgdisk -p "$root" | grep -q "Found invalid GPT and valid MBR"; then - echo "mbr" - else - echo "gpt" - fi -} - -sgdisk_fix_gpt() { - local disk="$1" - [ -z "$disk" ] && return - - local label=$(sgdisk_get_label "$disk") - [ "$label" != "gpt" ] && return - - kmsg "Moving GPT header for $disk with sgdisk." - sgdisk --move-second-header "$disk" -} - -# Returns "disk:partition", supporting multiple block types. -split_partition() { - local root="$1" disk="" partnum="" - [ -z "$root" ] && return 0 - - if [ -e /sys/block/${root##*/} ]; then - kmsg "Root is not a partition, skipping partition resize." - return 1 - fi - - disk=${root%%p[0-9]*} - [ "$disk" = "$root" ] && disk=${root%%[0-9]} - - partnum=${root#${disk}} - partnum=${partnum#p} - - echo "${disk}:${partnum}" -} - -# Checks if partition needs resizing. -parted_needresize() { - local disk="$1" partnum="$2" disksize="" partend="" - if [ -z "$disk" ] || [ -z "$partnum" ]; then - kmsg "invalid args to parted_needresize" - return 1 - fi - - kmsg "Check if $disk partition $partnum needs resize with parted." - if ! out=$(parted -sm "$disk" unit b print 2>&1); then - kmsg "Failed to get disk details: ${out}" - return 1 - fi - - if ! printf "$out" | sed '$!d' | grep -q "^${partnum}:"; then - kmsg "Root partition is not final partition on disk. Not resizing." - return 1 - fi - - disksize=$(printf "$out" | grep "^${disk}" | cut -d: -f2) - partend=$(printf "$out" | sed '$!d' | cut -d: -f4) - [ -n "$disksize" -a -n "$partend" ] || return 1 - - disksize=${disksize%%B} - partend=${partend%%B} - - # Check if the distance is > .5GB - [ $((disksize-partend)) -gt 536870912 ] - return -} - -# Resizes partition using 'resizepart' command. -parted_resizepart() { - local disk="$1" partnum="$2" - [ -z "$disk" -o -z "$partnum" ] && return - - kmsg "Resizing $disk partition $partnum with parted." - if ! out=$(parted -sm "$disk" -- resizepart $partnum -1 2>&1); then - kmsg "Unable to resize ${disk}${partnum}: ${out}" - return 1 - fi -} diff --git a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/check b/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/check deleted file mode 100755 index 7f7d65c..0000000 --- a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/check +++ /dev/null @@ -1,16 +0,0 @@ -#!/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. - -command -v parted >/dev/null 2>&1 diff --git a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs.sh b/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs.sh deleted file mode 100755 index 41cc6da..0000000 --- a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/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. - -# Contains dracut-specific logic for detecting disk, then calls appropriate -# library functions. - -# Notes for developing dracut modules: this module must never exit with anything -# other than a 0 exit code. That means no use of set -e or traps on err, and -# every command must be defensively written so that errors are caught and -# logged, rather than causing end of execution. Note that error handling in the -# main() function always calls return 0 - -main() { - local rootdev="" disk="" partnum="" - - # Remove 'block:' prefix and find the root device. - if ! rootdev=$(readlink -f "${root#block:}") || [ -z "${rootdev}" ]; then - kmsg "Unable to find root device." - return - fi - - if ! out=$(split_partition "$rootdev"); then - kmsg "Failed to detect disk and partition info: ${out}" - return - fi - - disk=${out%:*} - partnum=${out#*:} - - ( - # If we can't obtain an exclusive lock on FD 9 (which is associated in this - # subshell with the root device we're modifying), then exit. This is needed - # to prevent systemd from issuing udev re-enumerations and fsck calls before - # we're done. See https://systemd.io/BLOCK_DEVICE_LOCKING/ - - if ! flock -n 9; then - kmsg "couldn't obtain lock on ${rootdev}" - exit - fi - - if ! parted_needresize "$disk" "$partnum"; then - kmsg "Disk ${rootdev} doesn't need resizing" - exit - fi - - if ! parted --help | grep -q 'resizepart'; then - kmsg "No 'resizepart' command in this parted" - exit - fi - - kmsg "Resizing disk ${rootdev}" - - # First, move the secondary GPT to the end. - if ! out=$(sgdisk_fix_gpt "$disk"); then - kmsg "Failed to fix GPT: ${out}" - fi - - if ! out=$(parted_resizepart "$disk" "$partnum"); then - kmsg "Failed to resize partition: ${out}" - exit - fi - - if ! out=$(resize_filesystem "$rootdev"); then - kmsg "Failed to resize filesystem: ${out}" - exit - fi - ) 9<$rootdev -} - -. /lib/expandfs-lib.sh -udevadm settle -main -udevadm settle diff --git a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs_dummy.sh b/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs_dummy.sh deleted file mode 100755 index c037109..0000000 --- a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs_dummy.sh +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh -# Dummy script, to make sure systemd executes the cmdline stage (which exports -# the 'root' variable required for expand_root) diff --git a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/install b/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/install deleted file mode 100755 index 4fa6a5b..0000000 --- a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/install +++ /dev/null @@ -1,31 +0,0 @@ -#!/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. - -# Dracut install script for RHEL/CentOS - -inst "$moddir/expandfs-lib.sh" "/lib/expandfs-lib.sh" -inst_hook cmdline 50 "$moddir/expand_rootfs_dummy.sh" -inst_hook pre-mount 50 "$moddir/expand_rootfs.sh" -inst_hook pre-pivot 99 "$moddir/xfs_growfs.sh" - -dracut_install parted -dracut_install sgdisk -dracut_install cut -dracut_install sed -dracut_install grep -dracut_install resize2fs -dracut_install e2fsck -dracut_install udevadm -dracut_install -o xfs_growfs diff --git a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/xfs_growfs.sh b/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/xfs_growfs.sh deleted file mode 100755 index f4013f6..0000000 --- a/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/xfs_growfs.sh +++ /dev/null @@ -1,43 +0,0 @@ -#!/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. - -kmsg() { - echo "xfs_growfs: $@" >/dev/kmsg -} - -main() { - if [ ! -e /tmp/xfs_resize ]; then - return - fi - - if ! type xfs_growfs >/dev/null; then - kmsg "XFS resize requested, but xfs_growfs not installed." - return - fi - - kmsg "Mounting filesystem rw for resize." - if ! $(mount -o rw,remount /sysroot); then - kmsg "Remount failed." - return - fi - - kmsg "Resizing XFS filesystem" - if ! out=$(xfs_growfs -d /sysroot); then - kmsg "Failed to resize: ${out}" - fi - mount -o ro,remount /sysroot -} - -main diff --git a/packages/gce-disk-expand/src/usr/share/initramfs-tools/hooks/expand-rootfs b/packages/gce-disk-expand/src/usr/share/initramfs-tools/hooks/expand-rootfs deleted file mode 100755 index a463ea5..0000000 --- a/packages/gce-disk-expand/src/usr/share/initramfs-tools/hooks/expand-rootfs +++ /dev/null @@ -1,40 +0,0 @@ -#!/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. - -PREREQS="" -prereqs() -{ - echo "$PREREQS" -} - -case $1 in - prereqs) - prereqs - exit 0 - ;; -esac - -. /usr/share/initramfs-tools/hook-functions - -copy_exec /sbin/parted /bin -copy_exec /bin/grep /bin -copy_exec /bin/sed /bin -copy_exec /usr/bin/cut /bin -copy_exec /sbin/e2fsck /bin -copy_exec /sbin/blkid /bin -copy_exec /sbin/resize2fs /bin -copy_exec /bin/udevadm /bin -copy_exec /usr/sbin/dmidecode /bin -copy_exec /sbin/sgdisk /bin diff --git a/packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-bottom/xfs_growfs b/packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-bottom/xfs_growfs deleted file mode 100755 index f27fb13..0000000 --- a/packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-bottom/xfs_growfs +++ /dev/null @@ -1,57 +0,0 @@ -#!/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 diff --git a/packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-premount/expand_rootfs b/packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-premount/expand_rootfs deleted file mode 100755 index 9b59b20..0000000 --- a/packages/gce-disk-expand/src/usr/share/initramfs-tools/scripts/local-premount/expand_rootfs +++ /dev/null @@ -1,67 +0,0 @@ -#!/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 -. /scripts/expandfs-lib.sh - -if ! rootdev=$(resolve_device "${ROOT}"); then - log_failure_msg "Failed to resolve root device for \"${ROOT}\"" -fi - -if ! fs_type=$(get_fstype "${rootdev}"); then - log_failure_msg "Failed to determine fstype for \"${rootdev}\"" -fi - -if ! out=$(split_partition "$rootdev"); then - log_failure_msg "Failed to detect disk and partition info: ${out}" - exit 0 -fi - -disk=${out%:*} -partnum=${out#*:} - -if ! parted_needresize "${disk}" "${partnum}"; then - log_success_msg "Disk ${rootdev} doesn't need resizing." - exit 0 -fi - -if ! out=$(sgdisk_fix_gpt "$disk"); then - log_failure_msg "Failed to fix GPT: ${out}" - exit 0 -fi - -echo "Resizing partition on ${rootdev}" -if ! out=$(parted_resizepart "${disk}" "${partnum}"); then - log_failure_msg "Failed to resize partition: ${out}" - exit 0 -fi - -echo "Resizing filesystem on ${rootdev}" -if ! out=$(resize_filesystem "${rootdev}"); then - log_failure_msg "Failed to resize filesystem: ${out}" - exit 0 -fi -- cgit v1.2.1