raspberry pi - Bootable SD card still has small memory, even after formating

07
2014-07
  • Inazuma

    I have an SD card which I used to run my RaspberryPi. I wanted to update the copy of raspbian on it, so I formated the card using the software from www.sdcard.com. I followed all the instructions correctly, however the size of my SD card didn't go back to it's default.

    It is a 4gb SD card, which after it's spell in the RaspberryPi had shrunken to 52mb, which I understand is normal. After formatting, the size rose to 3.69gb.

    This means that there is not enough space to install a new OS, so how can I make my SD card 4gb again?

    Any help would be much appreciated!

  • Answers
  • Jonathan Benn

    What formatting means: Think about the way a library is organized. If you just threw the books in randomly until the room was full then you would fit far more books, right? But you would never be able to find a particular book without searching through every single book one by one. Instead, libraries employ a sorting system (which takes up space!), and employ corridors and shelves (effectively empty space or space not used for books!) to make it possible to actually find a particular book in a timely manner.

    You need to understand that the same philosophy goes into formatting a computer disk. Usually, it means 2 things:

    1. Adding spaces between the areas in memory where data will be written
    2. Adding data (such as a File Allocation Table or similar) that tells the operating system where files are stored.

    What's in a GB?: Another factor at work is described in David Marshall's answer. Disk manufacturers tend to represent 1 GB as 1 billion bytes, when it is more typically represented as 2^30 bytes. Assuming this is the case for you, you really have 4e9 / 2^30 = 3.73 GB.

    Bad sectors: another thing that happens when you format a drive is that the operating system looks for and removes so-called bad sectors. These are areas of the disk that the OS can't read/write to. It marks these sectors as bad while formatting, so that they are effectively quarantined and don't cause your data to get corrupted. This system works well if the disk has suffered a small amount of damage and the source of the damage is not recurring. The downside is that the overall available disk space goes down since more disk space is no longer being used. This is a potential reason why your available space on the drive has gone down.

    Environmental factors: has anything else changed about the version of your operating system or the formatting tool itself? Any changes here could potentially cause the behaviour to change.

    Conclusion: Out of your original 3.73 GB of space, the remaining 3.73 - 3.69 = 0.04 GB was probably lost due to the organization system and/or bad sectors. Different formatting systems will use up more or less of the space on your disk. Bad sectors are, generally speaking, not recoverable. Potential solutions to the problem include:

    1. Buying a new, bigger drive (most likely to succeed!)
    2. Ensuring that you're using the same version of formatting utility or operating system as you previously used (if applicable)
    3. Trying a different formatting utility
    4. Applying a different file system type to the drive (if the formatting utility allows it)

    Good luck,

    --Jonathan

  • David Marshall

    On Windows 1GB = 1073741824

    To an SD card manufacturer 1GB = 1000000000

    3.69*1073741824 = 3962107330 approximately 4000000000 give that 3.69 is probably rounded down.


  • Related Question

    How to delete files from my indestructable memory card?
  • Matthew

    A week ago I started getting intermittent IO errors accessing the SD card on my rooted Evo 4g. I eventually plugged it into my windows machine and tried to format it. It appeared to work, but when I unmounted and remounted the card all the files came back. I tried formatting on my phone with the same result, and had a coworker try with the Mac diskutils suite. All the formats claimed to work, but the files came back when the card was remounted. Finally I ran dd if=/dev/zero of=/dev/block/mmcblk0; it completed, and the same thing happened again.

    But here is where it gets crazy. I put a new recovery file on the sd card -- and it added the file without any issue. But now it can't be deleted, just like everything else. So I can write to the SD card, but I can't delete anything.

    How can I fix this? Or if I can't, at least why is it happening?


  • Related Answers
  • Matthew

    Ultimately I replaced the card, and everything is now working. Multiple attempts to delete the files via different systems all failed. After more research it appears that some SD cards/flash memory are capable of changing a failed portion of the card to read-only, which allows the writable portion to still accept changes while not allowing any of the old items to be changed. Since the device was already full, it is pretty much useless as anything more than a permanent backup. Thanks for everyone's advice.

  • Broam

    I'll suggest you try a GNU/Linux box (a live CD should do) andshred all the files. Look for errors in kernel.log and dmesg when you do - if the device mounts read-only, the FS is corrupted, reparition it.