Loading ...
Sorry, an error occurred while loading the content.

980Avoiding writes to USB flash disk

Expand Messages
  • mrthreeplates
    Aug 31, 2004
    • 0 Attachment
      Hi,

      For those of you using the NSLU2 with only a flash
      disk, you may be interested in this. I've been
      looking into minimizing writes to prolong the life
      of the flash disk. This is probably not a big deal,
      but why burn out something sooner than necessary?

      I discovered that simply accessing a file (reading) can
      cause the OS to update that file's access time. This
      causes a write to the filesystem even though you didn't
      intend it. You could mount the filesystem read-only,
      but that becomes inconvienent.

      There are a couple of ways you can prevent this, one
      is on a per-file basis and the other is filesystem wide.

      To turn off the updating of the access times, mount
      the filesystem with "noatime". I just tested this
      with a vfat filesystem and it seemed to work.

      If you already have your vfat filesystem mounted (e.g.
      with a single usb flash drive like me), you can type this
      (as root):

      Note: (first check the output of the mount or df commands to
      make sure your devices are the same).

      # mount -t vfat -o remount,noatime /dev/sdb1 /share/flash/data

      If you want to verify that this is working (to
      check i/o stats), type the following command:

      # cat /proc/stat

      ...
      disk_io: (8,1):(953,949,52698,4,4)
      ...

      This means there were 953 total I/Os to my device
      (I assume 8,1 means /dev/sdb1). There were 949 reads
      and 4 writes.

      If you run the cat command in a loop in one window and do activity
      in another, you can play around and get feedback on what you
      are doing and how it affects the filesystem.

      Regards,

      George