From b71ffcb7760e6ba823a581a742c014d0598c6c2478133b5a1476cc88ec27356f Mon Sep 17 00:00:00 2001 From: Robert Schweikert Date: Tue, 23 Jan 2018 13:48:13 +0000 Subject: [PATCH] - Update to version 0.30 (bsc#1064755) + improved error messages on failure. + ignore sfdisk failure in 2.28.1 when due to reread failing (LP: #1619285) + Add service file to start growpart via systemd + Add rootgrow script to wrap growpart OBS-URL: https://build.opensuse.org/package/show/Cloud:Tools/growpart?expand=0&rev=7 --- cloud-utils-0.29.tar.gz | 3 --- cloud-utils-0.30.tar.gz | 3 +++ growpart.changes | 10 ++++++++ growpart.spec | 24 ++++++++++++++--- rootgrow | 57 +++++++++++++++++++++++++++++++++++++++++ rootgrow.service | 11 ++++++++ 6 files changed, 101 insertions(+), 7 deletions(-) delete mode 100644 cloud-utils-0.29.tar.gz create mode 100644 cloud-utils-0.30.tar.gz create mode 100644 rootgrow create mode 100644 rootgrow.service diff --git a/cloud-utils-0.29.tar.gz b/cloud-utils-0.29.tar.gz deleted file mode 100644 index b2abc96..0000000 --- a/cloud-utils-0.29.tar.gz +++ /dev/null @@ -1,3 +0,0 @@ -version https://git-lfs.github.com/spec/v1 -oid sha256:9ea1b66f5a4798c8d6eeca48d908e11169a38e943efa433b7ec5dffa907e257c -size 419396 diff --git a/cloud-utils-0.30.tar.gz b/cloud-utils-0.30.tar.gz new file mode 100644 index 0000000..8156bab --- /dev/null +++ b/cloud-utils-0.30.tar.gz @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7360dd3d56aca48945a4a1943315f1633f82f3486ca5f065c6746bce274b8aa5 +size 58526 diff --git a/growpart.changes b/growpart.changes index 7db99c9..5858182 100644 --- a/growpart.changes +++ b/growpart.changes @@ -1,3 +1,13 @@ +------------------------------------------------------------------- +Mon Jan 22 21:12:33 UTC 2018 - rjschwei@suse.com + +- Update to version 0.30 (bsc#1064755) + + improved error messages on failure. + + ignore sfdisk failure in 2.28.1 when due to reread failing + (LP: #1619285) + + Add service file to start growpart via systemd + + Add rootgrow script to wrap growpart + ------------------------------------------------------------------- Tue Sep 13 20:53:26 UTC 2016 - rjschwei@suse.com diff --git a/growpart.spec b/growpart.spec index 5e14263..5939e79 100644 --- a/growpart.spec +++ b/growpart.spec @@ -1,7 +1,7 @@ # # spec file for package growpart # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2018 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,17 +17,24 @@ Name: growpart -Version: 0.29 +Version: 0.30 Release: 0 Summary: Grow a partition License: GPL-3.0 Group: System/Management Url: http://launchpad.net/cloud-utils Source0: cloud-utils-%{version}.tar.gz +Source1: rootgrow +Source2: rootgrow.service Patch: licenseGPLv3.patch Requires: util-linux -%if 0%{?suse_version} && 0%{?suse_version} >= 1220 +%if 0%{?suse_version} && 0%{?suse_version} > 1220 Requires: gptfdisk +Requires: python3 +Requires: systemd +# pkg-config is needed to find correct systemd unit dir +BuildRequires: pkg-config +BuildRequires: systemd %endif BuildRoot: %{_tmppath}/%{name}-%{version}-build BuildArch: noarch @@ -44,10 +51,15 @@ partition can be expanded to take up the additional size. %build %install -mkdir -p %{buildroot}/%{_sbindir} mkdir -p %{buildroot}/%{_mandir}/man1 +mkdir -p %{buildroot}/%{_sbindir} cp bin/growpart %{buildroot}/%{_sbindir} cp man/growpart.1 %{buildroot}/%{_mandir}/man1 +%if 0%{?suse_version} && 0%{?suse_version} > 1220 +mkdir -p %{buildroot}/usr/lib/systemd/system +cp %SOURCE1 %{buildroot}/%{_sbindir} +cp %SOURCE2 %{buildroot}/usr/lib/systemd/system +%endif %clean rm -rf $RPM_BUILD_ROOT @@ -57,5 +69,9 @@ rm -rf $RPM_BUILD_ROOT %doc LICENSE-GPLv3 %{_sbindir}/growpart %{_mandir}/man1/* +%if 0%{?suse_version} && 0%{?suse_version} > 1220 +%{_sbindir}/rootgrow +/usr/lib/systemd/system/rootgrow.service +%endif %changelog diff --git a/rootgrow b/rootgrow new file mode 100644 index 0000000..5497c9e --- /dev/null +++ b/rootgrow @@ -0,0 +1,57 @@ +#!/usr/bin/python3 +import os +import re +import syslog + +split_dev = re.compile('([a-z/]*)(\d*)') +mounts = open('/proc/mounts' ,'r').readlines() + +def get_mount_point(device): + for mount in mounts: + if mount.startswith(device): + return mount.split(' ')[1] + +def resize_fs(fs_type, device): + if fs_type.startswith('ext'): + cmd = 'resize2fs %s' % device + syslog.syslog( + syslog.LOG_INFO, + 'Resizing: "%s"' %cmd + ) + os.system(cmd) + elif fs_type == 'xfs': + mnt_point = get_mount_point(device) + cmd = 'xfs_growfs %s' % mnt_point + syslog.syslog( + syslog.LOG_INFO, + 'Resizing: "%s"' %cmd + ) + os.system(cmd) + + +for mount in mounts: + if ' / ' in mount: + mount_dev = mount.split(' ')[0] + fs = mount.split(' ')[2] + try: + dev, partition = split_dev.match(mount_dev).groups() + except: + syslog.syslog( + syslog.LOG_ERR, + 'match exception for "%s"' % mount + ) + break + if dev and partition: + cmd = '/usr/sbin/growpart %s %s' %(dev, partition) + syslog.syslog( + syslog.LOG_INFO, + 'Executing: "%s"' % cmd + ) + os.system(cmd) + resize_fs(fs, mount_dev) + else: + syslog.syslog( + syslog.LOG_ERR, + 'could not match device and partition in "%s"' % mount + ) + diff --git a/rootgrow.service b/rootgrow.service new file mode 100644 index 0000000..23c62f9 --- /dev/null +++ b/rootgrow.service @@ -0,0 +1,11 @@ +[Unit] +Description=Grow the root partition +After=local-fs.target +Wants=local-fs.target + +[Service] +ExecStart=/usr/sbin/rootgrow +Type=oneshot + +[Install] +WantedBy=multi-user.target