Bug 204215 - [patch] [feature-request] make rc.initdiskless more embedded-friendly and support auxiliary NVRAM
Summary: [patch] [feature-request] make rc.initdiskless more embedded-friendly and sup...
Status: Closed FIXED
Alias: None
Product: Base System
Classification: Unclassified
Component: conf (show other bugs)
Version: CURRENT
Hardware: Any Any
: --- Affects Some People
Assignee: Eugene Grosbein
URL:
Keywords: patch
Depends on:
Blocks:
 
Reported: 2015-11-02 09:21 UTC by Eugene Grosbein
Modified: 2018-11-19 07:01 UTC (History)
2 users (show)

See Also:
eugen: mfc-stable10+
eugen: mfc-stable11+
eugen: mfc-stable12+


Attachments
support for auxiliary NVRAM (1.66 KB, patch)
2015-11-02 09:21 UTC, Eugene Grosbein
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Eugene Grosbein 2015-11-02 09:21:00 UTC
Created attachment 162691 [details]
support for auxiliary NVRAM

/etc/rc.initdiskless makes excellent job for initial configuration for diskless systems and systems with read-only boot media. It is used, for example, with nanobsd(8).

Currently, rc.inidiskless assumes that local system configuration changes are kept in some mountable file system. Nanobsd uses dedicated partition mounted as /cfg for this. However, small embedded devices like MIPS routers may have no enough flash space to keep full-blown file system but have only one or couple of small flash blocks for persistent configuration.

The following patch extends rc.initdiskless and introduces ability to run auxiliary command /conf/T/M/extract that is supposed to extract configuration overrides from such local storage.

For example, the command /conf/default/etc/extract may contain something like:

'cd "$1" && bsdcpio --quiet -idu < /dev/map/cfg'

Assuming the storage is exposed by a kernel as /dev/map/cfg to userland, bsdcpio command extracts compressed archive from the storage to /etc.
Comment 1 Enji Cooper freebsd_committer 2015-11-02 09:26:25 UTC
Is there any reason why mdconfig/mdconfig2 can't be used instead? We have a lot of interfaces for doing X with rc to mount file systems in memory. I'd really like to simplify things...
Comment 2 Eugene Grosbein 2015-11-02 09:35:22 UTC
The reason is that /etc/rc.initdiskless runs very early at boot, take a look at /etc/rc. Its duty is extract /etc/rc.conf from NVRAM, for example. 

load_rc_config and rcorder run later.
Comment 3 Eugene Grosbein freebsd_committer 2017-09-19 17:33:40 UTC
My PR.
Comment 4 commit-hook freebsd_committer 2018-10-20 18:14:25 UTC
A commit references this bug:

Author: eugen
Date: Sat Oct 20 18:13:51 UTC 2018
New revision: 339465
URL: https://svnweb.freebsd.org/changeset/base/339465

Log:
  rc.initdiskless: add support for auxiliary NVRAM.

  Currently, rc.inidiskless assumes that local system configuration
  changes are kept in some mountable file system. For example,
  nanobsd uses dedicated partition mounted as /cfg for this.

  However, small embedded devices like MIPS routers may have no enough flash
  space to keep full-blown file system but have only one or couple
  small flash blocks to keep persistent local configuration overrides.

  This change extends rc.initdiskless and introduces ability to run auxiliary
  command /conf/T/M/extract that is supposed to extract configuration overrides
  from such local storage.

  For example, the command /conf/default/etc/extract may contain something like:

  cd "$1" && bsdcpio --quiet -idu < /dev/map/cfg

  bsdcpio command extracts compressed archive from the storage to /etc
  assuming the storage is exposed by the kernel as /dev/map/cfg to userland.

  PR:		204215
  MFC after:	1 month

Changes:
  head/libexec/rc/rc.initdiskless
Comment 5 commit-hook freebsd_committer 2018-11-19 06:34:34 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov 19 06:33:38 UTC 2018
New revision: 340610
URL: https://svnweb.freebsd.org/changeset/base/340610

Log:
  MFC r339465: rc.initdiskless: add support for auxiliary NVRAM.

    Currently, rc.inidiskless assumes that local system configuration
    changes are kept in some mountable file system. For example,
    nanobsd uses dedicated partition mounted as /cfg for this.

    However, small embedded devices like MIPS routers may have no enough flash
    space to keep full-blown file system but have only one or couple
    small flash blocks to keep persistent local configuration overrides.

    This change extends rc.initdiskless and introduces ability to run auxiliary
    command /conf/T/M/extract that is supposed to extract configuration overrides
    from such local storage.

    For example, the command /conf/default/etc/extract may contain something like:

    cd "$1" && bsdcpio --quiet -idu < /dev/map/cfg

    bsdcpio command extracts compressed archive from the storage to /etc
    assuming the storage is exposed by the kernel as /dev/map/cfg to userland.

  PR:		204215

Changes:
_U  stable/12/
  stable/12/libexec/rc/rc.initdiskless
Comment 6 commit-hook freebsd_committer 2018-11-19 06:38:40 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov 19 06:37:39 UTC 2018
New revision: 340611
URL: https://svnweb.freebsd.org/changeset/base/340611

Log:
  MFC r339465: rc.initdiskless: add support for auxiliary NVRAM.

    Currently, rc.inidiskless assumes that local system configuration
    changes are kept in some mountable file system. For example,
    nanobsd uses dedicated partition mounted as /cfg for this.

    However, small embedded devices like MIPS routers may have no enough flash
    space to keep full-blown file system but have only one or couple
    small flash blocks to keep persistent local configuration overrides.

    This change extends rc.initdiskless and introduces ability to run auxiliary
    command /conf/T/M/extract that is supposed to extract configuration overrides
    from such local storage.

    For example, the command /conf/default/etc/extract may contain something like:

    cd "$1" && bsdcpio --quiet -idu < /dev/map/cfg

    bsdcpio command extracts compressed archive from the storage to /etc
    assuming the storage is exposed by the kernel as /dev/map/cfg to userland.

  PR:		204215

Changes:
_U  stable/11/
  stable/11/etc/rc.initdiskless
Comment 7 commit-hook freebsd_committer 2018-11-19 06:39:43 UTC
A commit references this bug:

Author: eugen
Date: Mon Nov 19 06:39:00 UTC 2018
New revision: 340612
URL: https://svnweb.freebsd.org/changeset/base/340612

Log:
  MFC r339465: rc.initdiskless: add support for auxiliary NVRAM.

    Currently, rc.inidiskless assumes that local system configuration
    changes are kept in some mountable file system. For example,
    nanobsd uses dedicated partition mounted as /cfg for this.

    However, small embedded devices like MIPS routers may have no enough flash
    space to keep full-blown file system but have only one or couple
    small flash blocks to keep persistent local configuration overrides.

    This change extends rc.initdiskless and introduces ability to run auxiliary
    command /conf/T/M/extract that is supposed to extract configuration overrides
    from such local storage.

    For example, the command /conf/default/etc/extract may contain something like:

    cd "$1" && bsdcpio --quiet -idu < /dev/map/cfg

    bsdcpio command extracts compressed archive from the storage to /etc
    assuming the storage is exposed by the kernel as /dev/map/cfg to userland.

  PR:		204215

Changes:
  stable/10/etc/rc.initdiskless