Moxa UC-8410A-LX [81/86] Setting the sd card to read only mode

Moxa UC-8410A-LX [81/86] Setting the sd card to read only mode
UC-8410A Series Linux Software Extending the Lifetime of the SD Card
B-3
Tweaking GNU/Linux to Write to RAM Instead of the SD card
The “tmpfs” function is a useful GNU/Linux function that can be used to write to RAM as if it were an ordinary
file system, and is fast, efficient, and easy to use.
tmpfs can write to RAM instead of the local disk (in this case, the SD card). All you need to do is add an entry
to the /etc/fstab file (to mount the folder you wish to have written to RAM) and reboot (so that each mount is
cleanly mounted before services start writing files).
The kernel will do the rest for you by managing the writes to the RAM on this virtual file system. In addition, the
kernel will only use the amount of RAM required for writing files, and not the entire size of the mount. If, for
example, we add the following line to the /etc/fstab file, the kernel will mount /var/log to RAM.
tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0
However, it will not use any RAM until the files are written to /var/log. When files are written to /var/log, the
kernel will only save them to RAM. When files are removed from /var/log, the RAM used to store the files will
be freed up.
This means it only uses the RAM it needs to store the files, making the process very efficient.
You can also specify the total size to allocate for each mount in /etc/fstab. In the above example, we set
“size=100m” so that /var/log can use up to 100 MB of space and no more. This prevents the file system from
using up all of the RAM, which can cause the system to slow down or even crash. By running the
mount
command, we can see in the example above that /var/log is mounted as a tmpfs volume to RAM, 100 MB in
size.
Filesystem Size Used Avail Use% Mounted on
tmpfs 100M 596K 100M 1% /var/log
GNU/Linux uses a variety of locations to make frequent writes. The following list of entries can be used as a
starting point for most distributions.
tmpfs /tmp tmpfs defaults,noatime,nosuid,size=100m 0 0
tmpfs /var/tmp tmpfs defaults,noatime,nosuid,size=30m 0 0
tmpfs /var/log tmpfs defaults,noatime,nosuid,mode=0755,size=100m 0 0
tmpfs /var/run tmpfs defaults,noatime,nosuid,mode=0755,size=2m 0 0
tmpfs /var/spool/mqueue tmpfs defaults,noatime,nosuid,mode=0700,gid=12,size=30m 0 0
Use “size=” parameter to avoid using up huge amounts of RAM in case something tries to save a huge amount
of data. The “noatime” and “nosuid” parameters are also recommended for security and performance, and
“mode=” together with “gid=” match the permissions and group of the original file system to what was
originally located on the SD card.
“tmpfs” can also handle permissions. As usual, entries in /etc/fstab mount over the top of what is on the SD
card, as standard Unix/Linux types do. So if for some reason the mounts fail, writes will still work to the SD
card.
One additional point to keep in mind is that anything mounted with tmpfs will be lost on a reboot. So, logs in
/var/log in the example above will be wiped out if the computer is shut down or rebooted. For this reason, do
not use tmpfs to save any files that need to be preserved during reboots.
Setting the SD Card to Read-only Mode
Setting the SD card to read-only mode essentially makes GNU/Linux run in read-only mode, similar to how it
works when booting from a live CD. This way, you can avoid writing to the SD card, which in theory will extend
its life. However, there are some drawbacks to this strategy.
NOTE
Click the following link for more information on minicom:
http://www.gnu.org/software/coreutils/manual/html_node/dd
-invocation.html

Содержание

Скачать