summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZach Marano <zmarano@google.com>2016-03-11 13:08:48 -0800
committerZach Marano <zmarano@google.com>2016-03-11 13:08:48 -0800
commit080c4cf6230c80e1cc2bc92eff8cbcaab448aa9a (patch)
tree2028c8c8f43baed9bc016381b1642f261e6cc013
parentdfeb1ceba49bc660ab9f5a813c1eec8618a755f2 (diff)
parent43dbebf973364f0933c7e3ddc862e86b60451f8b (diff)
downloadgoogle-compute-image-packages-080c4cf6230c80e1cc2bc92eff8cbcaab448aa9a.tar.gz
Merge pull request #211 from zmarano/upstream
Add package for EL7 disk expand.
-rw-r--r--disk-expand/README.md24
-rwxr-xr-xdisk-expand/build_package.sh39
-rwxr-xr-xdisk-expand/expand-root3
-rw-r--r--disk-expand/expand-root.service26
-rw-r--r--disk-expand/gce-disk-expand-el6.spec2
-rw-r--r--disk-expand/gce-disk-expand-el7.spec46
6 files changed, 108 insertions, 32 deletions
diff --git a/disk-expand/README.md b/disk-expand/README.md
index 51b14c6..d93917d 100644
--- a/disk-expand/README.md
+++ b/disk-expand/README.md
@@ -4,23 +4,19 @@ This package is intended to expand the root partition up to 2TB on a GCE VM. It
consists of several scripts from other packages that for various reasons are not
maintained by the distros; cloud-utils-growpart, dracut-modules-growroot, and an
upstream version of the growpart script. See below for details. This package is
-being provided on an experimental basis for GCE CentOS and RHEL 6 images only.
+being provided on an experimental basis for GCE CentOS and RHEL images only.
### Build the package
A script to build the package is provided for convenience.
`./build_package.sh /OUTPUT_DIR` will yield an rpm and an srpm in the
-defined output directory.
+defined output directory for EL6 and EL7.
### Package usage
-1. Update to the latest packages and reboot. If there is a kernel update,
- you need to be running the new kernel for dracut to update it properly.
- Alternativley, if there is not a kernel update you can just install the
- gce-disk-expand package in the next step.
- `yum -y update ; reboot`
-1. Install the gce-disk-expand package with yum and reboot:
- `yum -y install /PATH_TO/gce-disk-expand-el6-VER-DATE.x86_64.rpm ; reboot`
+Install the gce-disk-expand package for your distro with yum and reboot:
+ CentOS/RHEL 6: `yum -y install /PATH_TO/gce-disk-expand-el6-VER-DATE.x86_64.rpm ; reboot`
+ CentOS/RHEL 7: 'yum -y install /PATH_TO/gce-disk-expand-el7-VER-DATE.x86_64.rpm ; reboot`
Your root partition will now be expanded to the full size of your disk up to
2TB.
@@ -38,15 +34,17 @@ further upstream releases of this script. It is therefore not recommended that
you try to use the [0.27 growpart package](http://rpmfind.net/linux/RPM/epel/6/x86_64/cloud-utils-growpart-0.27-10.el6.x86_64.html)
from the EPEL repo.
-#### Dracut modules
+#### Dracut module for EL6
The dracut module is taken from the [dracut-modules-growroot](http://rpmfind.net/linux/RPM/epel/6/x86_64/dracut-modules-growroot-0.20-2.el6.noarch.html)
package in the EPEL 6 repo. The dracut module allows the partition table to be
-expanded on boot before / is mounted and prevents an additional reboot.
+expanded on boot before / is mounted and prevents an additional reboot in CentOS
+and RHEL 6. CentOS and RHEL 7 support live partition resizing by the kernel and
+do not need the dracut module.
-#### The expand-root init.d script
+#### The expand-root script
-The expand-root init.d script is derived from the
+The expand-root script is derived from the
[bootstrap-vz version](https://github.com/andsens/bootstrap-vz/blob/c682dab6ec51767b6e529c1589c5630f6295953a/bootstrapvz/common/assets/init.d/expand-root)
of this script used for Debian instances. Essentially, it just calls the proper
filesystem expansion utility to live resize the filesystem on first boot. The
diff --git a/disk-expand/build_package.sh b/disk-expand/build_package.sh
index 422386f..c3ef36b 100755
--- a/disk-expand/build_package.sh
+++ b/disk-expand/build_package.sh
@@ -21,25 +21,30 @@ else
fi
RPM_TOP=$(mktemp -d)
-SPEC_FILE="gce-disk-expand-el6.spec"
+SPEC_FILES="gce-disk-expand-el6.spec gce-disk-expand-el7.spec"
-echo "Setup"
-mkdir -p ${RPM_TOP}/SOURCES/etc/init.d
-mkdir -p ${RPM_TOP}/SOURCES/usr/bin
-mkdir -p ${RPM_TOP}/SOURCES/usr/share/dracut/modules.d/50growroot
+for spec_file in ${SPEC_FILES}; do
+ echo "Setup ${spec_file}"
+ mkdir -p ${RPM_TOP}/SOURCES/etc/init.d
+ mkdir -p ${RPM_TOP}/SOURCES/usr/bin
+ mkdir -p ${RPM_TOP}/SOURCES/usr/lib/systemd/system
+ mkdir -p ${RPM_TOP}/SOURCES/usr/share/dracut/modules.d/50growroot
-cp expand-root ${RPM_TOP}/SOURCES/etc/init.d
-cp third_party/cloud-utils/* ${RPM_TOP}/SOURCES/usr/bin
-cp third_party/dracut-modules-growroot/* \
- ${RPM_TOP}/SOURCES/usr/share/dracut/modules.d/50growroot
+ cp expand-root ${RPM_TOP}/SOURCES/etc/init.d
+ cp expand-root ${RPM_TOP}/SOURCES/usr/bin
+ cp third_party/cloud-utils/* ${RPM_TOP}/SOURCES/usr/bin
+ cp expand-root.service ${RPM_TOP}/SOURCES/usr/lib/systemd/system
+ cp third_party/dracut-modules-growroot/* \
+ ${RPM_TOP}/SOURCES/usr/share/dracut/modules.d/50growroot
-echo "Building"
-rpmbuild --define "_topdir ${RPM_TOP}" -ba ${SPEC_FILE}
+ echo "Building"
+ rpmbuild --define "_topdir ${RPM_TOP}" -ba ${spec_file}
-echo "Copying rpm's to ${RPM_DEST}"
-cp ${RPM_TOP}/RPMS/x86_64/*.rpm ${RPM_DEST}
-cp ${RPM_TOP}/SRPMS/*.rpm ${RPM_DEST}
-ls -l ${RPM_DEST}/*.rpm
+ echo "Copying rpm's to ${RPM_DEST}"
+ cp ${RPM_TOP}/RPMS/x86_64/*.rpm ${RPM_DEST}
+ cp ${RPM_TOP}/SRPMS/*.rpm ${RPM_DEST}
+ ls -l ${RPM_DEST}/*.rpm
-echo "Cleaning up"
-rm -Rf ${RPM_TOP}
+ echo "Cleaning up"
+ rm -Rf ${RPM_TOP}
+done
diff --git a/disk-expand/expand-root b/disk-expand/expand-root
index 8c4cc29..7b35ce3 100755
--- a/disk-expand/expand-root
+++ b/disk-expand/expand-root
@@ -19,7 +19,8 @@
# Description: Expand the filesystem of the mounted root volume/partition to its maximum possible size
### END INIT INFO
-filesystem=$(blkid -s TYPE -o value /dev/sda1)
+device_path="/dev/sda1"
+filesystem=$(blkid -s TYPE -o value $device_path)
case $filesystem in
xfs) xfs_growfs / ;;
diff --git a/disk-expand/expand-root.service b/disk-expand/expand-root.service
new file mode 100644
index 0000000..1ac38a6
--- /dev/null
+++ b/disk-expand/expand-root.service
@@ -0,0 +1,26 @@
+# 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.
+
+[Unit]
+Description=Disk expand for EL7
+After=local-fs.target
+Wants=local-fs.target
+
+[Service]
+ExecStart=/usr/bin/growpart /dev/sda 1
+ExecStop=/usr/bin/expand-root
+Type=oneshot
+
+[Install]
+WantedBy=multi-user.target
diff --git a/disk-expand/gce-disk-expand-el6.spec b/disk-expand/gce-disk-expand-el6.spec
index e8f0e12..a2366b9 100644
--- a/disk-expand/gce-disk-expand-el6.spec
+++ b/disk-expand/gce-disk-expand-el6.spec
@@ -13,7 +13,7 @@
# limitations under the License.
Name: gce-disk-expand
Summary: Google Compute Engine root disk expansion utilities for EL6
-Version: 0.9.0
+Version: 1.0.0
Release: %(date +%s).el6
License: GPLv3, Apache Software License
Group: System Environment/Base
diff --git a/disk-expand/gce-disk-expand-el7.spec b/disk-expand/gce-disk-expand-el7.spec
new file mode 100644
index 0000000..a49dbef
--- /dev/null
+++ b/disk-expand/gce-disk-expand-el7.spec
@@ -0,0 +1,46 @@
+# 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 utilities for EL7
+Version: 1.0.0
+Release: %(date +%s).el7
+License: GPLv3, Apache Software License
+Group: System Environment/Base
+URL: https://github.com/GoogleCloudPlatform/compute-image-packages
+Requires: gawk, e2fsprogs, file, grep, util-linux, gdisk
+Conflicts: cloud-utils-growpart, cloud-utils
+
+# Allow other files in the source that don't end up in the package.
+%define _unpackaged_files_terminate_build 0
+
+%description
+gce-disk-expand: Automatically resize the root partition on first boot.
+
+This package is adopted from cloud-utils.
+
+%install
+rm -rf $RPM_BUILD_ROOT
+mkdir -p $RPM_BUILD_ROOT
+cp -R $RPM_SOURCE_DIR/usr $RPM_BUILD_ROOT
+
+%files
+%attr(755,root,root) /usr/bin/expand-root
+%attr(755,root,root) /usr/bin/growpart
+%attr(644,root,root) /usr/lib/systemd/system/expand-root.service
+
+%post
+systemctl enable expand-root.service
+
+%postun
+systemctl disable expand-root.service