by

Minecraft server on a full disk

Recently, a Minecraft server I host used up all the disk space on its RAM drive, and consequently bad things resulted, but it further worsened by the fact that my friend kept the server running for eight hours more. The following is an explanation of what occurs when the Minecraft server keeps running but with no actual available disk space.

Running out of disk space

Does running out of disk space cause data loss? Not necessarily. Picture a chunk file as the example below, with three different chunks stored in different “slots.” The three squares represent disk space already “acquired” on the disk as one single .mca file, with the white areas representing acquired (from the PoV of a hard drive) but unused (from the PoV of Minecraft) space.

chunk

Sometimes a chunk needs to be enlarged, but only some activities do that. If you are placing down “simple” blocks like sandstone or cobble, you’re just changing a few bits of data in the chunk, so the chunk does not need to be resized. However, this is different when you add new entities (mobs, such as skeletons, or item drops, etc.) or new tile entities (more complex blocks, like chests, furnaces, etc.) because the existing space isn’t enough to store all the new data (think inventories!). Those changes require more disk space to store the chunk.

chunk1

But even then, even if the hard drive itself is out of space, sometimes it is OK. The middle chunk above still has “room” to expand. The white space available was already, as mentioned previously, acquired on the disk.

The problems appear when the slot that the chunk is already contained within becomes too small to fit the newest version of that chunk. What happens is that a new free area has to be found in the file that can fit the chunk, but if that cannot be found, the chunk is placed at the end of the file. Placing data at the end of the file means that the entire file itself has to be enlarged, therefore requiring more actual disk space usage. When the hard disk is out of space, the extra data has nowhere to go. Because the header of the .mca file indexes where a particular chunk is stored, the index for this chunk may now point to this section of the file that cannot actually be written, causing the chunk to simply “disappear” on next load.

chunk2

As seemingly irrelevant this information is to the world outside Minecraft, this also explains the same problem that your computer has when saving something to disk. When you save a file, it has the same, sometimes difficult, task: find a place to store the bits. If you’ve ever heard about “fragmentation,” that is when, rather than simply moving the entire file to another place, the file is split across across several areas. Of course, while Minecraft can put more data at the end of the file, your hard drive has a fixed amount of total space. The chunk format used by Minecraft does not do fragmentation.

  • elliot_z

    Good day,

    Thank you for the article.
    The server I run recently ran out of disk space over night as it was running a backup and it wasn’t configured properly to remove weeks old backups.

    I noticed it in the morning and tried to shut it down, to which I received a few server errors. I cleaned up the backup folder and started the server and received a few more error messages. Shutting down and starting again gave me a clean boot of the server. I am pretty sure the error messages were plugin that had corrupted configs. A few had reverted to default settings and I replaced those from older backups. No big deal there.

    My worry though is that the server now has some corrupted chunks. Do you know of a way to check for this? Or how likely this would happen? I could push the world back 24 hours, but it would kinda suck for a few folks.

    Any suggestions appreciated.

    Cheers.