Index: head/etc/rc.d/Makefile =================================================================== --- head/etc/rc.d/Makefile (revision 273954) +++ head/etc/rc.d/Makefile (revision 273955) @@ -1,221 +1,222 @@ # $FreeBSD$ .include FILES= DAEMON \ FILESYSTEMS \ LOGIN \ NETWORKING \ SERVERS \ abi \ accounting \ addswap \ adjkerntz \ amd \ apm \ apmd \ archdep \ atm1 \ atm2 \ atm3 \ auditd \ auditdistd \ automount \ automountd \ autounmountd \ bgfsck \ ${_bluetooth} \ bootparams \ bridge \ bsnmpd \ ${_bthidd} \ ${_casperd} \ ccd \ cleanvar \ cleartmp \ cron \ ctld \ ddb \ defaultroute \ devd \ devfs \ dhclient \ dmesg \ dumpon \ faith \ fsck \ ftpd \ gbde \ geli \ geli2 \ gptboot \ + growfs \ gssd \ hastd \ ${_hcsecd} \ hostapd \ hostid \ hostid_save \ hostname \ inetd \ ip6addrctl \ ipfilter \ ipfs \ ipfw \ ipmon \ ipnat \ ipropd_master \ ipropd_slave \ ipsec \ iscsictl \ iscsid \ jail \ ${_kadmind} \ ${_kdc} \ ${_kfd} \ kld \ kldxref \ ${_kpasswdd} \ ldconfig \ local \ localpkg \ lockd \ lpd \ mixer \ motd \ mountcritlocal \ mountcritremote \ mountlate \ mdconfig \ mdconfig2 \ mountd \ moused \ mroute6d \ mrouted \ msgs \ natd \ netif \ netoptions \ netwait \ newsyslog \ nfsclient \ nfscbd \ nfsd \ nfsuserd \ nisdomain \ ${_nscd} \ nsswitch \ ntpd \ ntpdate \ ${_opensm} \ othermta \ pf \ pflog \ pfsync \ postrandom \ powerd \ power_profile \ ppp \ pppoed \ pwcheck \ quota \ random \ rarpd \ rctl \ resolv \ rfcomm_pppd_server \ root \ route6d \ routed \ routing \ rpcbind \ rtadvd \ rtsold \ savecore \ sdpd \ securelevel \ sendmail \ serial \ sppp \ ${_sshd} \ statd \ static_arp \ static_ndp \ stf \ swap \ swaplate \ syscons \ sysctl \ syslogd \ timed \ tmp \ ${_ubthidhci} \ ugidfw \ ${_unbound} \ ${_utx} \ var \ virecover \ watchdogd \ wpa_supplicant \ ypbind \ yppasswdd \ ypserv \ ypset \ ypupdated \ ypxfrd \ zfs \ zvol .if ${MK_BLUETOOTH} != "no" _bluetooth= bluetooth _bthidd= bthidd _hcsecd= hcsecd _ubthidhci= ubthidhci .endif .if ${MK_CASPER} != "no" _casperd= casperd .endif .if ${MK_NS_CACHING} != "no" _nscd= nscd .endif .if ${MK_KERBEROS} != "no" _kadmind= kadmind _kdc= kdc _kfd= kfd _kpasswdd= kpasswdd .endif .if ${MK_OFED} != "no" _opensm= opensm .endif .if ${MK_OPENSSL} != "no" FILES+= keyserv .endif .if ${MK_OPENSSH} != "no" _sshd= sshd .endif .if ${MK_PF} != "no" FILES+= ftp-proxy .endif .if ${MK_RCMDS} != "no" FILES+= rwho .endif .if ${MK_UNBOUND} != "no" _unbound= local_unbound .endif .if ${MK_UTMPX} != "no" _utx= utx .endif FILESDIR= /etc/rc.d FILESMODE= ${BINMODE} .include Index: head/etc/rc.d/growfs =================================================================== --- head/etc/rc.d/growfs (nonexistent) +++ head/etc/rc.d/growfs (revision 273955) @@ -0,0 +1,98 @@ +#!/bin/sh +# +# Copyright 2014 John-Mark Gurney +# All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in the +# documentation and/or other materials provided with the distribution. +# +# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +# ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +# SUCH DAMAGE. +# +# $FreeBSD$ +# + +# PROVIDE: growfs +# BEFORE: sysctl +# KEYWORD: firstboot + +# This allows us to distribute a image +# and have it work on essentially any size drive. +# +# TODO: Figure out where this should really be ordered. +# I suspect it should go just after fsck but before mountcritlocal +# but it's hard to tell for sure because of the bug described +# below. +# + +. /etc/rc.subr + +name="growfs" +start_cmd="growfs_start" +stop_cmd=":" +rcvar="growfs_enable" + +growfs_start () +{ + echo "Growing root partition to fill device" + rootdev=$(df / | tail -n 1 | awk '{ sub("/dev/", "", $1); print $1 }') + if [ x"$rootdev" = x"${rootdev%/*}" ]; then + # raw device + rawdev="$rootdev" + else + rawdev=$(glabel status | awk '$1 == "'"$rootdev"'" { print $3 }') + if [ x"$rawdev" = x"" ]; then + echo "Can't figure out device for: $rootdev" + return + fi + fi + + sysctl -b kern.geom.conftxt | awk ' +{ + lvl=$1 + device[lvl] = $3 + type[lvl] = $2 + idx[lvl] = $7 + parttype[lvl] = $13 + if (dev == $3) { + for (i = 1; i <= lvl; i++) { + # resize + if (type[i] == "PART") { + pdev = device[i - 1] + cmd[i] = "gpart resize -i " idx[i] " " pdev + if (parttype[i] == "GPT") + cmd[i] = "gpart recover " pdev " ; " cmd[i] + } else if (type[i] == "LABEL") { + continue + } else { + print "unhandled type: " type[i] + exit 1 + } + } + for (i = 1; i <= lvl; i++) { + if (cmd[i]) + system(cmd[i]) + } + exit 0 + } +}' dev="$rawdev" + growfs -y /dev/"$rootdev" +} + +load_rc_config $name +run_rc_command "$1" Property changes on: head/etc/rc.d/growfs ___________________________________________________________________ Added: svn:executable ## -0,0 +1 ## +* \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Index: head/share/man/man7/Makefile =================================================================== --- head/share/man/man7/Makefile (revision 273954) +++ head/share/man/man7/Makefile (revision 273955) @@ -1,51 +1,52 @@ # @(#)Makefile 8.1 (Berkeley) 6/5/93 # $FreeBSD$ .include #MISSING: eqnchar.7 ms.7 term.7 MAN= adding_user.7 \ ascii.7 \ bsd.snmpmod.mk.7 \ build.7 \ clocks.7 \ c99.7 \ development.7 \ environ.7 \ ffs.7 \ firewall.7 \ + growfs.7 \ hier.7 \ hostname.7 \ intro.7 \ maclabel.7 \ mailaddr.7 \ operator.7 \ ports.7 \ release.7 \ sdoc.7 \ security.7 \ sprog.7 \ stdint.7 \ sticky.7 \ tests.7 \ tuning.7 MLINKS= intro.7 miscellaneous.7 MLINKS+= security.7 securelevel.7 MLINKS+= c99.7 c.7 MLINKS+= c99.7 c78.7 MLINKS+= c99.7 c89.7 MLINKS+= c99.7 c90.7 .if ${MK_TESTS} != "no" ATF= ${.CURDIR}/../../../contrib/atf .PATH: ${ATF}/doc MAN+= atf.7 CLEANFILES+= atf.7 atf.7: atf.7.in sed -e 's,__DOCDIR__,/usr/share/doc/atf,g' \ <"${ATF}/doc/atf.7.in" >atf.7 .endif .include Index: head/share/man/man7/growfs.7 =================================================================== --- head/share/man/man7/growfs.7 (nonexistent) +++ head/share/man/man7/growfs.7 (revision 273955) @@ -0,0 +1,64 @@ +.\" Copyright 2014 John-Mark Gurney +.\" All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND +.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE +.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE +.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS +.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) +.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY +.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF +.\" SUCH DAMAGE. +.\" +.\" $FreeBSD$ +.\" +.Dd November 1, 2014 +.Dt GROWFS 7 +.Os +.Sh NAME +.Nm growfs +.Nd start up script to grow the root file-system. +.Sh DESCRIPTION +The following options in +.Pa /etc/rc.conf +control the behavior of +.Nm : +.Bl -tag -width ".Va growfs_enable" -offset indent +.It Va growfs_enable +.Pq Dq Li NO +If set to +.Dq Li YES , +the first time the machine boots, the root file-system will be automatically +expanded, if possible, to fill up all available space after it. +.El +.Pp +To expand the root file-system with-out rebooting, run the following command: +.Dl % /etc/rc.d/growfs onestart +.Sh IMPLEMENTATION NOTES +The script requires that +.Pa awk +be present and on the path. +This usually means that +.Pa /usr +should be mounted prior to running the script. +.Sh FILES +.Pa /etc/rc.conf +.Sh EXIT STATUS +.Ex -std +.Sh SEE ALSO +.Xr rc.conf 5 +.Sh AUTHORS +The man page and script were written by +.An John-Mark Gurney Aq Mt jmg@FreeBSD.org . Property changes on: head/share/man/man7/growfs.7 ___________________________________________________________________ Added: svn:eol-style ## -0,0 +1 ## +native \ No newline at end of property Added: svn:keywords ## -0,0 +1 ## +FreeBSD=%H \ No newline at end of property Added: svn:mime-type ## -0,0 +1 ## +text/plain \ No newline at end of property