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.Dd November 22, 2022 26.Dt GROWFS 7 27.Os 28.Sh NAME 29.Nm growfs , 30.Nm growfs_fstab 31.Nd start up scripts to grow the root file system and add swap 32.Sh DESCRIPTION 33The 34.Nm 35script normally runs at the first boot after system installation. 36If the boot disk is larger than the root file system and boot partitions, 37and the root file system is in the last partition, 38.Nm 39can expand the root file system. 40It can also add a swap partition, with a default size of 10% of the boot disk. 41Swap is limited to twice the memory size up to 4 GB, 428 GB up to 8 GB of memory, and memory size over 8 GB. 43It is also limited to the 44.Xr sysctl 8 45value of 46.Li vm.swap_maxpages 47divided by 2. 48By default, no swap partition is created if an existing swap partition is found 49or is listed in 50.Pa /etc/fstab , 51or the disk is under 15 GB. 52The 53.Nm growfs_fstab 54script adds any new swap partition to 55.Pa /etc/fstab 56after the root file system is made writable, 57and enables its use as a dump partition if the 58.Va dumpdev 59variable from 60.Xr rc.conf 5 61is set to 62.Li AUTO . 63.Pp 64The following options in 65.Pa /etc/rc.conf 66control the behavior of 67.Nm : 68.Bl -tag -width ".Va growfs_swap_size" -offset indent 69.It Va growfs_enable 70.Pq Dq Li NO 71If set to 72.Dq Li YES , 73the first time the machine boots, the root file system will be automatically 74expanded, if possible, to fill up all available space after it, 75after optionally adding a swap device at the end. 76.It Va growfs_swap_size 77.Pq Dq Li \& 78If set to 79.Dq Li 0 , 80the addition of a swap partition is disabled. 81An empty value 82.Pq Dq Li \& 83allows the creation of a swap partition with the default size. 84If set to another value, 85the swap partition will be created with the specified size in bytes, 86even if another swap partition is detected. 87.El 88.Pp 89A setting for 90.Va growfs_swap_size 91can be set in the kernel environment, in which case it overrides 92the value from 93.Pa /etc/rc.conf . 94.Pp 95To expand the root file system without rebooting, run the following command: 96.Dl % /etc/rc.d/growfs onestart 97In addition, if a swap partition is added, run the command: 98.Dl % /etc/rc.d/growfs_fstab onestart 99Note that if a disk is expanded again, 100and if the root file system had previously been expanded 101and a swap partition added, it is necessary to delete the swap 102partition before this procedure 103in order to expand the root file system to the new size. 104A new swap partition can be created during the expansion. 105.Sh IMPLEMENTATION NOTES 106The 107.Nm 108script only attempts to expand the root file system, 109and free space must be available immediately after the root partition. 110It is normally used on images that have a single file system. 111The script requires that 112.Xr awk 1 113be present and in the path. 114This usually means that 115.Pa /usr 116must be available prior to running the script. 117.Sh FILES 118.Bl -tag -compact -width Pa 119.It Pa /etc/fstab 120.It Pa /etc/rc.conf 121.El 122.Sh EXIT STATUS 123.Ex -std 124.Sh SEE ALSO 125.Xr fstab 5 , 126.Xr rc.conf 5 , 127.Xr growfs 8 , 128.Xr zpool 8 129.Sh HISTORY 130The 131.Nm 132manual page first appeared in 133.Fx 10.1 . 134The ability to add a swap partition was added in 135.Fx 14.0 . 136.Sh AUTHORS 137The man page and script were written by 138.An John-Mark Gurney Aq Mt jmg@FreeBSD.org . 139The ability to create a swap partition was added by 140.An Michael Karels Aq Mt karels@FreeBSD.org . 141