Page MenuHomeFreeBSD

growfs_fstab: add new /etc/rc.d script to add swap to fstab
ClosedPublic

Authored by • karels on Nov 22 2022, 7:03 PM.
Tags
None
Referenced Files
Unknown Object (File)
Wed, Sep 9, 10:19 PM
Unknown Object (File)
Sun, Sep 6, 3:10 PM
Unknown Object (File)
Sun, Sep 6, 2:58 PM
Unknown Object (File)
Sun, Sep 6, 10:37 AM
Unknown Object (File)
Sun, Sep 6, 5:38 AM
Unknown Object (File)
Sun, Sep 6, 1:43 AM
Unknown Object (File)
Sun, Sep 6, 1:43 AM
Unknown Object (File)
Sat, Sep 5, 4:20 PM
Subscribers

Details

Summary

The growfs_fstab script is a helper for the growfs script to add any
new swap partition to /etc/fstab on first boot. If growfs adds a
swap partition, it sets growfs_swap_added=1 in the kenv. In this
case, after the root file system is read/write, if there is no swap
partition in the fstab, growfs_fstab labels the swap partition as
growfs_swap, and adds that as a swap partition to the fstab. Also,
if there is no dumpdev line in /etc/rc.conf, it adds dumpdev="AUTO"
to rc.conf and runs dumpon (as this happened earlier in the startup
sequence).

Diff Detail

Repository
rG FreeBSD src repository
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

• karels created this revision.
jlduran added inline comments.
libexec/rc/rc.d/growfs_fstab
64–68

I wonder if sysrc(8) may simplify/improve this block. As dumpdev may be somewhere else (rc.conf(5)).

libexec/rc/rc.d/growfs_fstab
64–68

While looking at this, I discovered that the default value of dumpdev is AUTO (/etc/defaults/rc.conf), so adding to /etc/rc.conf is unneeded. I'll redo this using sysrc to check for AUTO, then do the dumpon. Thanks!

Is there a reason not to just do this in the growfs script, when it creates the swap partition?

Yes, the root filesystem is read-only when growfs runs (BEFORE: root), and this runs after it is made read/write. The swap part could now be done earlier (previously it modified rc.conf), although it doesn't really matter.

No need to add dumpdev to /etc/rc.conf; the default is AUTO.

Just use $dumpdev, and enable dump if AUTO is the current value.

Move the code to find and label the swap partition to growfs.
Change the kenv variable that is used to growfs_swap_pdev, as this
is used internally in growfs. No need to add dumpdev="AUTO" to
rc.conf, as that is the default; just check for it before adding
dumpdev.

libexec/rc/rc.d/growfs_fstab
64–68

I think it is worth noting that dumpdev="AUTO" is the default only for -CURRENT, not for RELEASE branches.

libexec/rc/rc.d/growfs_fstab
64–68

Thanks. I have no intention to MFC this currently. If that changes, I might reconsider this, although it might be best to leave the default in place here.

This revision was not accepted when it landed; it landed in state Needs Review.Dec 10 2022, 7:42 PM
This revision was automatically updated to reflect the committed changes.