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