I am using my pi as a weather station, so there are frequent database updates, etc., and it has chewed up a few cheap 4gb cards. The system should run forever in a 4gb filesystem, but I have upgraded the SD card to a 32gb class 10 Samsung card. I am leery about expanding the filesystem beyond the 4gb as it will greatly increase the time to clone the card for backup. So my question is, if I leave it as a 4gb filesystem, will the wear leveling built into the card use the whole 32gb capacity of the card - will it level across the whole physical media even as the logical disk remains 4gb?
2 Answers
Yes, it will be leveled across the entire card.
Wear leveling obviously depends upon virtual addressing, and this is done by a microcontroller in the card. The operating system sees these addresses as real contiguous physical addresses that it can partition, but the card's MC has no concept of what the data it stores is for or how it is organized; it just runs the card, including the address mappings, and wear leveling juggles these around with use.
This means that it does not matter what size the partition you create is. There is no good reason to expand the filesystem for the purpose of "maximizing" wear leveling for a longer lifespan. If it is more useful for you to leave it small, then leave it small.
That depends on a lot of different factors. SD cards are not required to have wear leveling at all. Most name brand cards have wear leveling built in, but a lot of the cheaper knockoffs don't.
The OS has some control over how that's done, but not really in the way you're hoping for. If you don't expand the logical disk, the OS won't ever write outside of the area it's defined. That has to be left to the device's firmware for a variety of reasons.
I would recommend expanding the file system, since you don't really lose anything by doing so. The cloned image may take significantly more space on disk, but compressing it with 7z, or something similar will greatly reduce that effect.
Alternatively, you could backup using means other than a full system clone.