I need to enable a swap file on my embedded linux product. The problem is that the file is located on an SD card.

At the moment I'm using 15MB swap and about 120MB RAM because of temporary increases in memory usage. I know (good) SD cards have a wear-leveling mechanism implemented to spread all writes evenly over different blocks. Only 0.2GB of the 4GB card is being used so plenty of free space.

Is it possible to predict (not exactly offourse) the failure date of the SD card? 1 year, 5 years, 10 years, ...? I was thinking about checking how many data gets written in a specific timeframe and checking this with datasheet specs or something like that.

Any ideas how to proceed?

Edit: I see here that a 2GB can have 10TB of data written before failure, so extrapolated gives me 20TB for a 4GB version.

  • Out of curiosity, what card are you using? Feb 1, 2016 at 9:53
  • @perhapsmaybeharry: SanDisk 4GB class 4 uSD
    – Dimi
    Feb 1, 2016 at 10:15
  • uSD? Do you mean microSD? Feb 1, 2016 at 10:21
  • @perhapsmaybeharry: yes, microSD
    – Dimi
    Feb 1, 2016 at 10:22
  • it might be better to use zram instead of swap. It'll be faster and you won't have to worry about the flash lifespan
    – phuclv
    Jul 21, 2018 at 11:57

1 Answer 1


People underestimate the lifetime of modern flash as most (decent) flash cards will take hundreds of terabytes of data and still work. As indicated here on Ask Different (though not quite exactly your problem), it's going to be some time before you should start worrying about your SD card's lifespan.

To quote an example, my SanDisk 32GB Extreme lasted for about five or six years with daily read-writes totalling to about 300GB/day. If you go through the math that's 547.5TB before it finally conked out earlier this month.

I understand that the file being written/read to it is a swap file which means constant changes, but that shouldn't worry you too much (people with more experience in this field, please correct me if I'm wrong).

If you're curious, do measure how much data goes in and out of your card per day on average. In most cases the average SD card can take up to or even more than 500TB. You can then use these values to roughly get an idea of the estimated time before your SD card conks out.

  • Any ideas how to measure written swap data? Of can you recommend a program that I can cross-compile?
    – Dimi
    Feb 1, 2016 at 10:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.