Write Counter

Using applications, configuring, problems
Post Reply
Message
Author
User avatar
borgbucolic
Posts: 16
Joined: Sat 20 Aug 2011, 19:56
Location: Washington State, USA

Write Counter

#1 Post by borgbucolic »

Hello,
I am using Puppy 5.2.8 on a USB stick. I have the stick set up so that there is a Linux swap partition on it as well. I've been using for a year, so far it works fine. At the price of 4 gig sticks (this one I got free), I'm not too concerned about the write-life of SSDs. I do regular backups.

I am curious. Is there a way to set up a "write counter" that will increment each time there is a write to the USB?

It would be nice if I could get data writes and swap writes counted seperately. :)

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#2 Post by amigo »

While theoretically possible, that would take a bit of well-written code to make it happen. You'd have to have an LD_PRELOADable library which would trap all write glibc operations, figure out if the write was going to a flash device and then increment the counter.

The best alternative is to not use any space on the device as swap at all. If the device is fairly new, you're gonna have a hard time hitting the write-limits. It will also help to use the mount options 'noatime' and 'nodiratime' in your fstab.

User avatar
borgbucolic
Posts: 16
Joined: Sat 20 Aug 2011, 19:56
Location: Washington State, USA

#3 Post by borgbucolic »

amigo wrote:While theoretically possible, that would take a bit of well-written code to make it happen. You'd have to have an LD_PRELOADable library which would trap all write glibc operations, figure out if the write was going to a flash device and then increment the counter.
I was thinking that. I'm not sure I want to invest the time and effort into it. I was hoping there was a simpler solution I was not aware of.
amigo wrote:The best alternative is to not use any space on the device as swap at all. If the device is fairly new, you're gonna have a hard time hitting the write-limits. It will also help to use the mount options 'noatime' and 'nodiratime' in your fstab.
That is just the point. The computers I use it on have plenty of memory, I seldom have "out of memory" problems. I suspect the swap is hardly used. At the same time, I don't care if I eventually trash the drive, they are cheap (if not free). I've had to rethink how I install and configure a distribution on a stick. The original thinking behind USB stick installations are based on SSD limitations and costs that are not the same anymore.

amigo
Posts: 2629
Joined: Mon 02 Apr 2007, 06:52

#4 Post by amigo »

Most modern systems will *hardly* ever use swap under normal conditions. Still it is not a good idea to run with no swap at all, because occassionaly the kernel will, for some reason, want to write out a page or two to swap. The solution is to use a swap file which is in RAM or under a tmpfs mount, so that nothing really gets written to any disk. It sounds funny, but works.

Post Reply