summarylogtreecommitdiffstats
diff options
context:
space:
mode:
authorLorenzo Castelli2018-10-23 13:12:48 -0700
committerLorenzo Castelli2018-10-23 13:12:48 -0700
commit9b0b39f7ebff7c847d67bc4b76e79216d90ee048 (patch)
treec24286e96b8f32cf47254cac88bb90dbff9cc18c
downloadaur-9b0b39f7ebff7c847d67bc4b76e79216d90ee048.tar.gz
Adds a pacman package definition for growpart (part of cloud-utils).
This package has a minimal dependency footprint as it includes growpart only (rather than the entire cloud-utils suite). It also includes a wrapper script 'growpartfs' to grow both a partition and the file system in it, and a systemd service that can be used to automatically grow a file system on boot.
-rw-r--r--.SRCINFO18
-rw-r--r--PKGBUILD39
-rwxr-xr-xgrowpartfs44
-rw-r--r--growpartfs@.service9
4 files changed, 110 insertions, 0 deletions
diff --git a/.SRCINFO b/.SRCINFO
new file mode 100644
index 00000000000..510bd5184ea
--- /dev/null
+++ b/.SRCINFO
@@ -0,0 +1,18 @@
+# Generated by makepkg 5.1.1
+# Tue Oct 23 19:53:20 UTC 2018
+pkgbase = growpart
+ pkgdesc = Extends a partition to fill available space
+ pkgver = 0.30
+ pkgrel = 1
+ url = https://launchpad.net/cloud-utils
+ arch = any
+ license = GPL3
+ source = https://launchpad.net/cloud-utils/trunk/0.3/+download/cloud-utils-0.30.tar.gz
+ source = growpartfs
+ source = growpartfs@.service
+ sha256sums = 7360dd3d56aca48945a4a1943315f1633f82f3486ca5f065c6746bce274b8aa5
+ sha256sums = 01576833fe3034c38f57b57b498f24ffe06263f6bcec25f79e57481aa854ac9b
+ sha256sums = abb9633ea0a2bef1ae7c91b15267c1d901d63bb1d2f3caab76ecacc47a4b9c10
+
+pkgname = growpart
+
diff --git a/PKGBUILD b/PKGBUILD
new file mode 100644
index 00000000000..846434db498
--- /dev/null
+++ b/PKGBUILD
@@ -0,0 +1,39 @@
+# Copyright 2018 Google Inc. All Rights Reserved.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+# Maintainer: Lorenzo Castelli <lcastelli@gmail.com>
+# Maintainer: Samuel Littley <samuellittley@google.com>
+
+pkgname='growpart'
+pkgver=0.30
+pkgrel=1
+pkgdesc='Extends a partition to fill available space'
+arch=('any')
+url='https://launchpad.net/cloud-utils'
+license=('GPL3')
+source=("https://launchpad.net/cloud-utils/trunk/0.3/+download/cloud-utils-$pkgver.tar.gz"
+ 'growpartfs'
+ 'growpartfs@.service')
+sha256sums=('7360dd3d56aca48945a4a1943315f1633f82f3486ca5f065c6746bce274b8aa5'
+ '01576833fe3034c38f57b57b498f24ffe06263f6bcec25f79e57481aa854ac9b'
+ 'abb9633ea0a2bef1ae7c91b15267c1d901d63bb1d2f3caab76ecacc47a4b9c10')
+
+package() {
+ install -m755 -Dt "$pkgdir/usr/bin/" growpartfs
+ install -m644 -Dt "$pkgdir/usr/lib/systemd/system/" growpartfs@.service
+
+ cd "cloud-utils-$pkgver"
+ install -m755 -Dt "$pkgdir/usr/bin/" bin/growpart
+ install -m644 -Dt "$pkgdir/usr/share/man/man1/" man/growpart.1
+}
diff --git a/growpartfs b/growpartfs
new file mode 100755
index 00000000000..272bb5fb1c9
--- /dev/null
+++ b/growpartfs
@@ -0,0 +1,44 @@
+#!/bin/sh
+# Copyright 2018 Google Inc. All Rights Reserved.
+#
+# This program is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, version 3 of the License.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program. If not, see <https://www.gnu.org/licenses/>.
+
+# Expands a filesystem and its corresponding partition (if it exists) to fill
+# all available disk space. Takes as an argument the mountpoint or device to
+# expand, with any specification supported by findmnt.
+[ $# -ne 1 ] && { echo "Usage: $0 device|mountpoint"; exit 1; }
+
+# Find the device to expand.
+if [ -b "$1" ]; then
+ dev="$1"
+else
+ dev="$(findmnt -nfvo SOURCE -- "$1")"
+ [ -b "$dev" ] || { echo "Cannot find device for '$1'"; exit 1; }
+fi
+
+# If it's a partition, expand that first using growpart.
+if [ "$(lsblk -ndo TYPE -- "$dev")" = part ]; then
+ disk="$(lsblk -ndpo PKNAME -- "$dev")"
+ partnum="${dev##*[!0-9]}"
+ growpart "$disk" "$partnum" || { [ $? -ne 1 ] && exit 1; }
+fi
+
+# Expand the filesystem.
+fs="$(lsblk -ndo FSTYPE -- "$dev")"
+mnt="$(lsblk -ndo MOUNTPOINT -- "$dev")"
+case "$fs" in
+ btrfs) btrfs filesystem resize max "$mnt" || exit 1 ;;
+ ext[2-4]) resize2fs -- "$dev" || exit 1 ;;
+ xfs) xfs_growfs "$mnt" || exit 1 ;;
+ *) echo "Unsupported filesystem type '$fs'"; exit 1 ;;
+esac
diff --git a/growpartfs@.service b/growpartfs@.service
new file mode 100644
index 00000000000..df2fa0b55b7
--- /dev/null
+++ b/growpartfs@.service
@@ -0,0 +1,9 @@
+[Unit]
+Description=Grows the filesystem and partition at %I
+
+[Service]
+Type=oneshot
+ExecStart=/usr/bin/growpartfs %I
+
+[Install]
+WantedBy=multi-user.target