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
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.
However, even a small installation of FreeBSD using normal installation procedures can produce a system in size of greater than 200 megabytes. Most people will be using smaller flash memory devices (128 megabytes is considered fairly large - 32 or even 16 megabytes is common), so an installation using normal mechanisms is not possible—there is simply not enough disk space for even the smallest of conventional installations.
The easiest way to overcome this space limitation is to install FreeBSD using conventional means to a normal hard disk. After the installation is complete, pare down the operating system to a size that will fit onto your flash media, then tar the entire filesystem. The following steps will guide you through the process of preparing a piece of flash memory for your tarred filesystem. Remember, because a normal installation is not being performed, operations such as partitioning, labeling, file-system creation, etc. need to be performed by hand. In addition to the kern and mfsroot floppy disks, you will also need to use the fixit floppy.
Partitioning Your Flash Media Device
After booting with the kern and mfsroot floppies, choose <literal>custom</literal> from the installation menu. In the custom installation menu, choose <literal>partition</literal>. In the partition menu, you should delete all existing partitions using <keycap>d</keycap>. After deleting all existing partitions, create a partition using <keycap>c</keycap> and accept the default value for the size of the partition. When asked for the type of the partition, make sure the value is set to <literal>165</literal>. Now write this partition table to the disk by pressing <keycap>w</keycap> (this is a hidden option on this screen). If you are using an ATA compatible compact flash card, you should choose the FreeBSD Boot Manager. Now press <keycap>q</keycap> to quit the partition menu. You will be shown the boot manager menu once more - repeat the choice you made earlier.
Creating Filesystems on Your Flash Memory Device
Exit the custom installation menu, and from the main installation menu choose the <literal>fixit</literal> option. After entering the fixit environment, enter the following command:
<prompt>#</prompt> <userinput>disklabel -e /dev/ad0c</userinput>
At this point you will have entered the vi editor under the auspices of the disklabel command. Next, you need to add an <literal>a:</literal> line at the end of the file. This <literal>a:</literal> line should look like:
a: <replaceable>123456</replaceable> 0 4.2BSD 0 0
Where <replaceable>123456</replaceable> is a number that is exactly the same as the number in the existing <literal>c:</literal> entry for size. Basically you are duplicating the existing <literal>c:</literal> line as an <literal>a:</literal> line, making sure that fstype is <literal>4.2BSD</literal>. Save the file and exit.

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:254
String age
a year ago
Source string age
a year ago
Translation file
articles/solid-state.pot, string 34