The translation is temporarily closed for contributions due to maintenance, please come back later.

Source string Read only

(itstool) path: sect1/para
Context English State
Redistribution and use in source (XML DocBook) and 'compiled' forms (XML, HTML, PDF, PostScript, RTF and so forth) with or without modification, are permitted provided that the following conditions are met:
Redistributions of source code (XML DocBook) must retain the above copyright notice, this list of conditions and the following disclaimer as the first lines of this file unmodified.
Redistributions in compiled form (transformed to other DTDs, converted to PDF, PostScript, RTF and other formats) must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
THIS DOCUMENTATION IS PROVIDED BY THE FREEBSD DOCUMENTATION PROJECT "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FREEBSD DOCUMENTATION PROJECT BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS DOCUMENTATION, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
$FreeBSD$
This article covers the use of solid state disk devices in FreeBSD to create embedded systems.
Embedded systems have the advantage of increased stability due to the lack of integral moving parts (hard drives). Account must be taken, however, for the generally low disk space available in the system and the durability of the storage medium.
Specific topics to be covered include the types and attributes of solid state media suitable for disk use in FreeBSD, kernel options that are of interest in such an environment, the <filename>rc.initdiskless</filename> mechanisms that automate the initialization of such systems and the need for read-only filesystems, and building filesystems from scratch. The article will conclude with some general strategies for small and read-only FreeBSD environments.
Solid State Disk Devices
The scope of this article will be limited to solid state disk devices made from flash memory. Flash memory is a solid state memory (no moving parts) that is non-volatile (the memory maintains data even after all power sources have been disconnected). Flash memory can withstand tremendous physical shock and is reasonably fast (the flash memory solutions covered in this article are slightly slower than a EIDE hard disk for write operations, and much faster for read operations). One very important aspect of flash memory, the ramifications of which will be discussed later in this article, is that each sector has a limited rewrite capacity. You can only write, erase, and write again to a sector of flash memory a certain number of times before the sector becomes permanently unusable. Although many flash memory products automatically map bad blocks, and although some even distribute write operations evenly throughout the unit, the fact remains that there exists a limit to the amount of writing that can be done to the device. Competitive units have between 1,000,000 and 10,000,000 writes per sector in their specification. This figure varies due to the temperature of the environment.
Specifically, we will be discussing ATA compatible compact-flash units, which are quite popular as storage media for digital cameras. Of particular interest is the fact that they pin out directly to the IDE bus and are compatible with the ATA command set. Therefore, with a very simple and low-cost adaptor, these devices can be attached directly to an IDE bus in a computer. Once implemented in this manner, operating systems such as FreeBSD see the device as a normal hard disk (albeit small).
Other solid state disk solutions do exist, but their expense, obscurity, and relative unease of use places them beyond the scope of this article.
Kernel Options
A few kernel options are of specific interest to those creating an embedded FreeBSD system.
All embedded FreeBSD systems that use flash memory as system disk will be interested in memory disks and memory filesystems. As a result of the limited number of writes that can be done to flash memory, the disk and the filesystems on the disk will most likely be mounted read-only. In this environment, filesystems such as <filename>/tmp</filename> and <filename>/var</filename> are mounted as memory filesystems to allow the system to create logs and update counters and temporary files. Memory filesystems are a critical component to a successful solid state FreeBSD implementation.
You should make sure the following lines exist in your kernel configuration file:
options MFS # Memory Filesystem
options MD_ROOT # md device usable as a potential root device
pseudo-device md # memory disk
The <literal>rc</literal> Subsystem and Read-Only Filesystems
The post-boot initialization of an embedded FreeBSD system is controlled by <filename>/etc/rc.initdiskless</filename>.
<filename>/etc/rc.d/var</filename> mounts <filename>/var</filename> as a memory filesystem, makes a configurable list of directories in <filename>/var</filename> with the <citerefentry><refentrytitle>mkdir</refentrytitle><manvolnum>1</manvolnum></citerefentry> command, and changes modes on some of those directories. In the execution of <filename>/etc/rc.d/var</filename>, one other <filename>rc.conf</filename> variable comes into play – <literal>varsize</literal>. A <filename>/var</filename> partition is created by <filename>/etc/rc.d/var</filename> based on the value of this variable in <filename>rc.conf</filename>:
varsize=8192
Remember that this value is in sectors by default.
The fact that <filename>/var</filename> is a read-write filesystem is an important distinction, as the <filename>/</filename> partition (and any other partitions you may have on your flash media) should be mounted read-only. Remember that in <xref linkend="intro"/> we detailed the limitations of flash memory - specifically the limited write capability. The importance of not mounting filesystems on flash media read-write, and the importance of not using a swap file, cannot be overstated. A swap file on a busy system can burn through a piece of flash media in less than one year. Heavy logging or temporary file creation and destruction can do the same. Therefore, in addition to removing the <literal>swap</literal> entry from your <filename>/etc/fstab</filename>, you should also change the Options field for each filesystem to <literal>ro</literal> as follows:
# Device Mountpoint FStype Options Dump Pass#
/dev/ad0s1a / ufs ro 1 1
A few applications in the average system will immediately begin to fail as a result of this change. For instance, cron will not run properly as a result of missing cron tabs in the <filename>/var</filename> created by <filename>/etc/rc.d/var</filename>, and syslog and dhcp will encounter problems as well as a result of the read-only filesystem and missing items in the <filename>/var</filename> that <filename>/etc/rc.d/var</filename> has created. These are only temporary problems though, and are addressed, along with solutions to the execution of other common software packages in <xref linkend="strategies"/>.
An important thing to remember is that a filesystem that was mounted read-only with <filename>/etc/fstab</filename> can be made read-write at any time by issuing the command:
<prompt>#</prompt> <userinput>/sbin/mount -uw <replaceable>partition</replaceable></userinput>
and can be toggled back to read-only with the command:
<prompt>#</prompt> <userinput>/sbin/mount -ur <replaceable>partition</replaceable></userinput>
Building a File System from Scratch
Since ATA compatible compact-flash cards are seen by FreeBSD as normal IDE hard drives, you could theoretically install FreeBSD from the network using the kern and mfsroot floppies or from a CD.

Loading…

No matching activity found.

Browse all component changes

Source information

Source string comment
(itstool) path: sect1/para
Flags
read-only
Source string location
article.translate.xml:191
String age
a year ago
Source string age
a year ago
Translation file
articles/solid-state.pot, string 24