Page MenuHomeFreeBSD

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

Authored by karels on Tue, Nov 22, 7:03 PM.

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 Passed
Unit
No Test Coverage
Build Status
Buildable 48504
Build 45390: arc lint + arc unit

Event Timeline

karels created this revision.
jlduran_gmail.com 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.