sobota, 20 lutego 2016

Linux - 0 bytes available but many gigs free

Today I woke up and found out that one of my servers stopped responding.
After attaching LCD and a reboot I was welcomed by a message stating that one of drives has bad sectors and needs to be replaced.

I decided to copy all the data from that drive to another witch had more than enough free space.
After a few hours of copying the precess stopped with a message stating that 0 bytes on target drive are available.

Quick check using df showed that there are 137GB free but 0 is available.
The drive is a 3TB WD Red with one 3TB ext4 partition.

After some digging I found out that this is normal on Linux.
When you create a partition, Linux reserves 5% of it's capacity for root user. It is intended to store logs and settings so that system has space to write even if users use all storage.
The thing is that it is not needed on all disks - if drive is used only to store let's say CCTV recordings you want all storage available. It is needed mainly on partition containing /var folder.

How to fix it? - use tune2fs

The command is as follows (need to run it as root/use sudo, replace XX with the number of your partition):

tune2fs -m 0 /dev/sdXX

on Ubuntu use

sudo tune2fs -m 0 /dev/sdXX


I hope this will save you some time.

Brak komentarzy:

Prześlij komentarz