1.\" Copyright 2014 John-Mark Gurney 2.\" All rights reserved. 3.\" 4.\" Redistribution and use in source and binary forms, with or without 5.\" modification, are permitted provided that the following conditions 6.\" are met: 7.\" 1. Redistributions of source code must retain the above copyright 8.\" notice, this list of conditions and the following disclaimer. 9.\" 2. Redistributions in binary form must reproduce the above copyright 10.\" notice, this list of conditions and the following disclaimer in the 11.\" documentation and/or other materials provided with the distribution. 12.\" 13.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 14.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 15.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 16.\" ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 17.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 18.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 19.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 20.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 21.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 22.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 23.\" SUCH DAMAGE. 24.\" 25.\" $FreeBSD$ 26.\" 27.Dd November 22, 2022 28.Dt GROWFS 7 29.Os 30.Sh NAME 31.Nm growfs , 32.Nm growfs_fstab 33.Nd start up scripts to grow the root file system and add swap 34.Sh DESCRIPTION 35The 36.Nm 37script normally runs at the first boot after system installation. 38If the boot disk is larger than the root file system and boot partitions, 39and the root file system is in the last partition, 40.Nm 41can expand the root file system. 42It can also add a swap partition, with a default size of 10% of the boot disk. 43Swap is limited to twice the memory size up to 4 GB, 448 GB up to 8 GB of memory, and memory size over 8 GB. 45It is also limited to the 46.Xr sysctl 8 47value of 48.Li vm.swap_maxpages 49divided by 2. 50By default, no swap partition is created if an existing swap partition is found 51or is listed in 52.Pa /etc/fstab , 53or the disk is under 15 GB. 54The 55.Nm growfs_fstab 56script adds any new swap partition to 57.Pa /etc/fstab 58after the root file system is made writable, 59and enables its use as a dump partition. 60.Pp 61The following options in 62.Pa /etc/rc.conf 63control the behavior of 64.Nm : 65.Bl -tag -width ".Va growfs_swap_size" -offset indent 66.It Va growfs_enable 67.Pq Dq Li NO 68If set to 69.Dq Li YES , 70the first time the machine boots, the root file system will be automatically 71expanded, if possible, to fill up all available space after it, 72after optionally adding a swap device at the end. 73.It Va growfs_swap_size 74.Pq Dq Li \& 75If set to 76.Dq Li 0 , 77the addition of a swap partition is disabled. 78An empty value 79.Pq Dq Li \& 80allows the creation of a swap partition with the default size. 81If set to another value, 82the swap partition will be created with the specified size in bytes, 83even if another swap partition is detected. 84.El 85.Pp 86A setting for 87.Va growfs_swap_size 88can be set in the kernel environment, in which case it overrides 89the value from 90.Pa /etc/rc.conf . 91.Pp 92To expand the root file system without rebooting, run the following command: 93.Dl % /etc/rc.d/growfs onestart 94In addition, if a swap partition is added, run the command: 95.Dl % /etc/rc.d/growfs_fstab onestart 96Note that if a disk is expanded again, 97and if the root file system had previously been expanded 98and a swap partition added, it is necessary to delete the swap 99partition before this procedure 100in order to expand the root file system to the new size. 101A new swap partition can be created during the expansion. 102.Sh IMPLEMENTATION NOTES 103The 104.Nm 105script only attempts to expand the root file system, 106and free space must be available immediately after the root partition. 107It is normally used on images that have a single file system. 108The script requires that 109.Xr awk 1 110be present and in the path. 111This usually means that 112.Pa /usr 113must be available prior to running the script. 114.Sh FILES 115.Bl -tag -compact -width Pa 116.It Pa /etc/fstab 117.It Pa /etc/rc.conf 118.El 119.Sh EXIT STATUS 120.Ex -std 121.Sh SEE ALSO 122.Xr fstab 5 , 123.Xr rc.conf 5 , 124.Xr growfs 8 , 125.Xr zpool 8 126.Sh HISTORY 127The 128.Nm 129manual page first appeared in 130.Fx 10.1 . 131The ability to add a swap partition was added in 132.Fx 14.0 . 133.Sh AUTHORS 134The man page and script were written by 135.An John-Mark Gurney Aq Mt jmg@FreeBSD.org . 136The ability to create a swap partition was added by 137.An Michael Karels Aq Mt karels@FreeBSD.org . 138