/tmp, /var/log, /var/tmp as /dev/md - why?

Warner Losh imp at bsdimp.com
Wed Jul 2 14:49:04 UTC 2014


On Jul 1, 2014, at 8:20 PM, John-Mark Gurney <jmg at funkthat.com> wrote:

> Anton Shterenlikht wrote this message on Tue, Jul 01, 2014 at 11:46 +0100:
>>> From r.c.ladan at gmail.com Tue Jul  1 11:37:35 2014
>>> 
>>> 2014-07-01 11:25 GMT+02:00 Anton Shterenlikht <mexas at bris.ac.uk>:
>>> 
>>>> Why is it a good idea to mount /tmp and some var dirs on memory disks:
>>>> 
>>>> root at raspberry-pi:/usr/ports # df -m
>>>> Filesystem     1M-blocks Used Avail Capacity  Mounted on
>>>> /dev/mmcsd0s2a     14694  777 12742     6%    /
>>>> devfs                  0    0     0   100%    /dev
>>>> /dev/mmcsd0s1         16    3    13    20%    /boot/msdos
>>>> /dev/md0              28    4    22    16%    /tmp
>>>> /dev/md1              14    0    12     0%    /var/log
>>>> /dev/md2               4    0     4     0%    /var/tmp
>>>> root at raspberry-pi:/usr/ports #
>>>> 
>>>> Is this about speed or power, or maybe space?
>>>> 
>>>> Mostly write tear because you're using an SD card, and it improves speed
>>> too.
>> 
>> "write tear"?
>> Is this a joke, or some technical term?
>> I cannot find what it means.
> 
> it is a technical term, though I'd be surprised if any SD card had
> an issue w/ that anymore…

SD cards are made from NAND flash. NAND flash is different than a hard disk in that it has only a limited number of times you can write to a given spot before it becomes unusable (well, hard drives have this too, but the numbers are huge (1e20 or something like that if memory serves). This number can be as low as a few hundred for the really low-end cheap crap parts, but typically is a few thousand. The reason for this is because you have to erase each NAND page before you can program it, and each time you erase it you expose the cell to a huge negative potential voltage. This leads to trapping of electrons, as well as some minor physical damage, usually along tiny flaws in the manufacturing process. The net effect is that the dynamic range of the cell is reduced, which leads to errors which eventually get bad enough that the pages become useless. Since there’s actual physical damage to each program/erase cycle, it is referred to as “wear and tear.” You’ll see references to “wear leveling” which attempts to wear out each block at about the same rate.


> write tear is where when writing data, only part of the data gets
> written and then you loose power...  This is mostly an issue on flash
> where you have to erase the data beforey ou can program it...  Most
> flash now have a layer of indirection so that they copy/write the
> data to a new flash block, and then point the block there before
> erasing the old data... (kinda like a log FS)…

Yes, nearly all block devices based on flash have some kind of log-based system under the covers. It is a shame they don’t expose the log directly, since a number of interesting optimizations could be made in host software that are not possible going through the translation layer a log-bsed system imposes on the card. But we get what we get...

Warner
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 842 bytes
Desc: Message signed with OpenPGP using GPGMail
URL: <http://lists.freebsd.org/pipermail/freebsd-arm/attachments/20140702/bb7cb4c1/attachment.sig>


More information about the freebsd-arm mailing list