From owner-svn-ports-all@FreeBSD.ORG Thu Nov 20 23:57:09 2014 Return-Path: Delivered-To: svn-ports-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 2467614F; Thu, 20 Nov 2014 23:57:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 0F8A014B; Thu, 20 Nov 2014 23:57:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAKNv8gd093672; Thu, 20 Nov 2014 23:57:08 GMT (envelope-from cperciva@FreeBSD.org) Received: (from cperciva@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAKNv8lK093654; Thu, 20 Nov 2014 23:57:08 GMT (envelope-from cperciva@FreeBSD.org) Message-Id: <201411202357.sAKNv8lK093654@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: cperciva set sender to cperciva@FreeBSD.org using -f From: Colin Percival Date: Thu, 20 Nov 2014 23:57:08 +0000 (UTC) To: ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org Subject: svn commit: r372970 - in head/sysutils: . firstboot-growfs firstboot-growfs/files X-SVN-Group: ports-head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-ports-all@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for the ports tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 20 Nov 2014 23:57:09 -0000 Author: cperciva Date: Thu Nov 20 23:57:07 2014 New Revision: 372970 URL: https://svnweb.freebsd.org/changeset/ports/372970 QAT: https://qat.redports.org/buildarchive/r372970/ Log: 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. Added: head/sysutils/firstboot-growfs/ head/sysutils/firstboot-growfs/Makefile (contents, props changed) head/sysutils/firstboot-growfs/files/ head/sysutils/firstboot-growfs/files/firstboot_growfs.in (contents, props changed) head/sysutils/firstboot-growfs/pkg-descr (contents, props changed) Modified: head/sysutils/Makefile Modified: head/sysutils/Makefile ============================================================================== --- head/sysutils/Makefile Thu Nov 20 23:38:33 2014 (r372969) +++ head/sysutils/Makefile Thu Nov 20 23:57:07 2014 (r372970) @@ -245,6 +245,7 @@ SUBDIR += filewatcherd SUBDIR += finfo SUBDIR += firstboot-freebsd-update + SUBDIR += firstboot-growfs SUBDIR += firstboot-pkgs SUBDIR += flasher SUBDIR += flashrom Added: head/sysutils/firstboot-growfs/Makefile ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/firstboot-growfs/Makefile Thu Nov 20 23:57:07 2014 (r372970) @@ -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 + +.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 Added: head/sysutils/firstboot-growfs/files/firstboot_growfs.in ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/firstboot-growfs/files/firstboot_growfs.in Thu Nov 20 23:57:07 2014 (r372970) @@ -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" Added: head/sysutils/firstboot-growfs/pkg-descr ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ head/sysutils/firstboot-growfs/pkg-descr Thu Nov 20 23:57:07 2014 (r372970) @@ -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.