diff options
author | Zach Marano <zmarano@google.com> | 2019-05-03 13:59:36 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-05-03 13:59:36 -0700 |
commit | 49d2969bb81ecc1061f475ce304e6316b5980273 (patch) | |
tree | 48a349c5a26aa9c10168f33ed691a08b2e4d6633 /packages/gce-disk-expand | |
parent | fd564de77d393ac6ed078075e888737f0aa57e65 (diff) | |
download | google-compute-image-packages-49d2969bb81ecc1061f475ce304e6316b5980273.tar.gz |
RHEL 8 packages for google-compute-engine. (#753)
* RHEL 8 packages for google-compute-engine.
Diffstat (limited to 'packages/gce-disk-expand')
8 files changed, 22 insertions, 16 deletions
diff --git a/packages/gce-disk-expand/packaging/gce-disk-expand.spec b/packages/gce-disk-expand/packaging/gce-disk-expand.spec index d34b08d..a1fb6dd 100644 --- a/packages/gce-disk-expand/packaging/gce-disk-expand.spec +++ b/packages/gce-disk-expand/packaging/gce-disk-expand.spec @@ -33,13 +33,13 @@ This package resizes the root partition on first boot using parted. %install mv src/expandfs-lib.sh src/usr/share/dracut/modules.d/50expand_rootfs/ -%if 0%{?rhel} == 7 +%if 0%{?rhel} >= 7 ./dracut6_7.sh %endif rsync -Pravz src/ %{buildroot} %files -%if 0%{?rhel} == 7 +%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/* diff --git a/packages/gce-disk-expand/packaging/setup_deb.sh b/packages/gce-disk-expand/packaging/setup_deb.sh index 8880efe..ca5be92 100755 --- a/packages/gce-disk-expand/packaging/setup_deb.sh +++ b/packages/gce-disk-expand/packaging/setup_deb.sh @@ -26,7 +26,7 @@ fi sudo apt-get -y install dh-systemd # DEB creation tools. -sudo apt-get -y install debhelper devscripts build-essential +sudo apt-get -y install debhelper devscripts build-essential rsync rm -rf /tmp/debpackage mkdir /tmp/debpackage diff --git a/packages/gce-disk-expand/packaging/setup_rpm.sh b/packages/gce-disk-expand/packaging/setup_rpm.sh index 52f6a36..106aa6f 100755 --- a/packages/gce-disk-expand/packaging/setup_rpm.sh +++ b/packages/gce-disk-expand/packaging/setup_rpm.sh @@ -24,7 +24,7 @@ if [[ $(basename "$working_dir") != $NAME ]]; then fi # RPM creation tools. -sudo yum -y install rpmdevtools +sudo yum -y install rpmdevtools rsync rm -rf ${rpm_working_dir} mkdir -p ${rpm_working_dir}/{SOURCES,SPECS} diff --git a/packages/gce-disk-expand/src/expandfs-lib.sh b/packages/gce-disk-expand/src/expandfs-lib.sh index 5126602..92e9ed5 100755 --- a/packages/gce-disk-expand/src/expandfs-lib.sh +++ b/packages/gce-disk-expand/src/expandfs-lib.sh @@ -24,7 +24,7 @@ resize_filesystem() { case "${fs_type}" in xfs) echo "XFS filesystems must be mounted to be resized, deferring." - expand_xfs="true" + echo "true" > /tmp/xfs_resize return 1 ;; ext*) @@ -136,6 +136,7 @@ parted_resizepart() { echo "Unable to resize ${disk}${partnum}: ${out}" return 1 fi + udevadm settle } # Resizes partition by deleting and recreating with end position. @@ -184,4 +185,5 @@ parted_resize_mkpart() ( return 1 fi done + udevadm settle ) 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 index 055f083..cc831b3 100755 --- 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 @@ -13,8 +13,6 @@ # See the License for the specific language governing permissions and # limitations under the License. -expand_xfs="" # Global to message next script. - # Contains dracut-specific logic for detecting disk, then calls appropriate # library functions. main() { @@ -26,11 +24,7 @@ main() { return fi - # Wait for any of the initial udev events to finish otherwise growpart - # might fail. - udevsettle - - if ! out=$(get_partition "$rootdev"); then + if ! out=$(split_partition "$rootdev"); then echo "Failed to detect disk and partition info: ${out}" return fi @@ -63,8 +57,6 @@ main() { fi fi - udevsettle - if ! out=$(resize_filesystem "$rootdev"); then echo "Failed to resize filesystem: ${out}" return 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 new file mode 100755 index 0000000..c037109 --- /dev/null +++ b/packages/gce-disk-expand/src/usr/share/dracut/modules.d/50expand_rootfs/expand_rootfs_dummy.sh @@ -0,0 +1,3 @@ +#!/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 index 4b68069..cdd021d 100755 --- 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 @@ -16,8 +16,9 @@ # 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 50 "$moddir/xfs_growfs.sh" +inst_hook pre-pivot 99 "$moddir/xfs_growfs.sh" dracut_install parted dracut_install cut @@ -25,4 +26,5 @@ 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 index af8d05d..0e77185 100755 --- 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 @@ -14,7 +14,7 @@ # limitations under the License. main() { - if [ -z "$expand_xfs" ]; then + if [ ! -e /tmp/xfs_resize ]; then return fi @@ -23,11 +23,18 @@ main() { return fi if xfs_growfs -d -n /sysroot; then + echo "Mounting filesystem rw." + if ! $(mount -o rw,remount /sysroot); then + echo "Remount failed." + return + fi echo "Resizing XFS filesystem" if ! out=$(xfs_growfs -d /sysroot); then echo "Failed to resize: ${out}" + mount -o ro,remount /sysroot return fi + mount -o ro,remount /sysroot fi } |