diff options
author | cperciva <cperciva@FreeBSD.org> | 2014-11-21 07:57:07 +0800 |
---|---|---|
committer | cperciva <cperciva@FreeBSD.org> | 2014-11-21 07:57:07 +0800 |
commit | f73e3e29d6a81e73fe06c74f1f557dc065ddce50 (patch) | |
tree | 56b0aff2a8971fccf9002b508482688cf31c6f39 | |
parent | a94390dc03e3a298bd3f3e1e075b200067fc73fe (diff) | |
download | freebsd-ports-gnome-f73e3e29d6a81e73fe06c74f1f557dc065ddce50.tar.gz freebsd-ports-gnome-f73e3e29d6a81e73fe06c74f1f557dc065ddce50.tar.zst freebsd-ports-gnome-f73e3e29d6a81e73fe06c74f1f557dc065ddce50.zip |
Add firstboot-growfs port:
When the system first boots, resize the (GPT) partition holding the root
filesystem, then resize the (UFS) root filesystem. This is intended to be
used in virtual machines where a VM image is built with one size but may
be launched onto a larger disk.
This will be used in EC2 images in the near future.
-rw-r--r-- | sysutils/Makefile | 1 | ||||
-rw-r--r-- | sysutils/firstboot-growfs/Makefile | 26 | ||||
-rw-r--r-- | sysutils/firstboot-growfs/files/firstboot_growfs.in | 58 | ||||
-rw-r--r-- | sysutils/firstboot-growfs/pkg-descr | 4 |
4 files changed, 89 insertions, 0 deletions
diff --git a/sysutils/Makefile b/sysutils/Makefile index 097ed22745c1..2694e4b53d13 100644 --- a/sysutils/Makefile +++ b/sysutils/Makefile @@ -245,6 +245,7 @@ SUBDIR += filewatcherd SUBDIR += finfo SUBDIR += firstboot-freebsd-update + SUBDIR += firstboot-growfs SUBDIR += firstboot-pkgs SUBDIR += flasher SUBDIR += flashrom diff --git a/sysutils/firstboot-growfs/Makefile b/sysutils/firstboot-growfs/Makefile new file mode 100644 index 000000000000..c44d72d20409 --- /dev/null +++ b/sysutils/firstboot-growfs/Makefile @@ -0,0 +1,26 @@ +# $FreeBSD$ + +PORTNAME= firstboot-growfs +PORTVERSION= 1.0 +CATEGORIES= sysutils +MASTER_SITES= # none +DISTFILES= # none + +MAINTAINER= cperciva@FreeBSD.org +COMMENT= Expand / when the system first boots + +NO_WRKSUBDIR= yes +NO_BUILD= yes + +USE_RC_SUBR= firstboot_growfs + +.include <bsd.port.pre.mk> + +.if ${OSVERSION} < 902504 || ( ${OSVERSION} >= 1000000 && ${OSVERSION} < 1000100 ) || ( ${OSVERSION} >= 1000500 && ${OSVERSION} < 1000501 ) || (${OSVERSION} >= 1100000 && ${OSVERSION} < 1100001 ) +IGNORE= first boot rc.d scripts not supported on this version of FreeBSD +.endif + +do-fetch do-install: + @${DO_NADA} + +.include <bsd.port.post.mk> diff --git a/sysutils/firstboot-growfs/files/firstboot_growfs.in b/sysutils/firstboot-growfs/files/firstboot_growfs.in new file mode 100644 index 000000000000..7e56684cd67f --- /dev/null +++ b/sysutils/firstboot-growfs/files/firstboot_growfs.in @@ -0,0 +1,58 @@ +#!/bin/sh + +# $FreeBSD$ +# KEYWORD: firstboot +# PROVIDE: firstboot_growfs +# REQUIRE: NETWORKING +# BEFORE: LOGIN + +# Add the following lines to /etc/rc.conf.local or /etc/rc.conf (in the disk +# image, since this only runs on the first boot) to enable this: +# +# firstboot_growfs_enable="YES" + +. /etc/rc.subr + +: ${firstboot_growfs_enable:="NO"} +: ${firstboot_growfs_fs:="/"} + +name="firstboot_growfs" +rcvar=firstboot_growfs_enable +start_cmd="firstboot_growfs_run" +stop_cmd=":" + +firstboot_growfs_run() +{ + local FSTYPE DISK GPTLABEL GPART GDISK GPARTNO + + FSTYPE=`mount -p | awk "{ if (\\$2 == \"${firstboot_growfs_fs}\") print \\$3 }"` + case ${FSTYPE} in + ufs) + ;; + *) + echo "${firstboot_growfs_fs} is not a UFS volume, cannot resize" + ;; + esac + + DISK=`mount -p | awk "{ if (\\$2 == \"${firstboot_growfs_fs}\") print \\$1 }"` + case ${DISK} in + /dev/gpt/*) + GPTLABEL=${DISK##/dev/gpt/} + ;; + *) + echo "${firstboot_growfs_fs} is not on a GPT disk, cannot resize" + return 0 + ;; + esac + + GPART=`glabel status -s | awk "{ if (\\$1 == \"gpt/${GPTLABEL}\") print \\$3 }"` + GDISK=${GPART%p*} + GPARTNO=${GPART##*p} + + gpart recover ${GDISK} + gpart resize -i ${GPARTNO} ${GDISK} + growfs -y ${firstboot_growfs_fs} +} + +load_rc_config $name +run_rc_command "$1" diff --git a/sysutils/firstboot-growfs/pkg-descr b/sysutils/firstboot-growfs/pkg-descr new file mode 100644 index 000000000000..1c36bcfe9e0a --- /dev/null +++ b/sysutils/firstboot-growfs/pkg-descr @@ -0,0 +1,4 @@ +When the system first boots, resize the (GPT) partition holding the root +filesystem, then resize the (UFS) root filesystem. This is intended to be +used in virtual machines where a VM image is built with one size but may +be launched onto a larger disk. |