LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (http://www.linuxquestions.org/questions/linux-software-2/)
-   -   df -h returns wrong values (http://www.linuxquestions.org/questions/linux-software-2/df-h-returns-wrong-values-792652/)

Hmail 03-02-2010 10:34 AM

df -h returns wrong values
 
Hi guys,

I'm having a kind of weird issue, and it's not a big problem, but it's kind of annoying. If I run df -h on my server, I get the following values:
Code:

henk@tiffany:~$ df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root            9.5G  4.9G  4.2G  55% /
/dev/sda1            917G  898G    0 100% /media/disk1
/dev/sdb1            917G  723G  148G  84% /media/disk2
tmpfs                122M    0  122M  0% /dev/shm
/dev/hda1            7.9G  6.5G  1.4G  83% /media/windows

As you can see, except from tmpfs and /dev/hda1, the other filesystems have a wrong size. I'm not very good in calculations, 917 minus 898 isn't 0. I tried to run some fsck scans on those partitions, but that doesn't solve anything. I can still write to /dev/sda1, but if I want to copy files through samba to this disk, it refuses it, because the disk is full. I would love to have these 19 Gigabyte available, and I'm also wondering why this is.
As for the filesystem types, /dev/sda1 and /dev/sdb1 are ext3 and /dev/root is ext4.

Can anyone explain me why this is, and, if possible, how I can solve this?

MensaWater 03-02-2010 11:11 AM

It has to do with reserved blocks. There is a certain amount reserved so that root and system processes can continue to write to a disk but it will be seen as "full" by non-root processes.

From the mkfs.ext3 man page:

Quote:

-m reserved-blocks-percentage
Specify the percentage of the filesystem blocks reserved for the super-user. This avoids fragmentation, and allows root-owned daemons, such as syslogd(8), to continue to function correctly after non-privileged processes are prevented from writing to the filesystem. The default percentage is 5%.
You're using 97% so presumably the writing you've been doing outside of Samba is as root.

tredegar 03-02-2010 01:14 PM

.. and the amount of disk space that is reserved for the root user can be altered with tune2fs

See man tune2fs

If you are referring to an external "media" disk, you can probably set the reserved blocks to zero, but never, ever do this for your root filesystem, or one day you may be unable to login, even as root, to fix the mess.

[ You could recover from the above by using a live CD though, but these did not exist when the ext2 / ext3 filesystems were first engineered, but do you want to run the risk of trashing your system because root has run out of filespace? ].

Hmail 03-02-2010 02:53 PM

Great, thanks for the explanation! I'm going to take a look at tune2fs :)
I'll let the /dev/root partition stay as it is, but these /media partitions (which are seperate hard drives) don't need reserved space to log in on those. I assume it's still possible to mount a full disk, or am I wrong?

edit: For future reference:
tune2fs -r 0 /dev/sda1
tune2fs -r 0 /dev/sdb1

and:
Code:

root@tiffany:~# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/root            9.5G  4.9G  4.2G  55% /
tmpfs                122M    0  122M  0% /dev/shm
/dev/hda1            7.9G  6.5G  1.4G  83% /media/windows
/dev/sdb1            917G  723G  195G  79% /media/disk2
/dev/sda1            917G  899G  19G  98% /media/disk1

Thanks a lot!

tredegar 03-02-2010 03:13 PM

Quote:

I assume it's still possible to mount a full disk, or am I wrong?
This is linux. So you are in control. You can mount whatever you like, wherever you like, as you choose.

Some choices might be inadvisable though. For example, running tune2fs not to allow root to have some reserved disk space on your root partition might be a mistake you will regret bitterly in the future. So don't do that, is my advice.

But for your "media" disks, it'll be fine. If you run out of space on one of them, you'll be fine, because although you cannot save that big file, your system will still boot, and you can clean up, delete unnecessary stuff to free up space and fix it.

Best to read up on this so you fully understand what you are doing, and why.

Linux puts you in control, so you had better know why you are changing the defaults (which are generally safe) and the repercussions of making any changes.

Then you'll be both happy and safe.

Hmail 03-02-2010 04:05 PM

Okay, cool, thanks a lot, I just asked it for verification. I know it's Linux, I pretty much know my way around it, but because I'm in control, I can still mess up. A lot ;) That's why I wanted to be sure.

I left the /dev/root as it was, because of these warnings. However, I'm almost sure that, sooner or later, I'll mess up big time. I might know what I'm doing, but I still want things to be done quickly instead of safe. Luckily it's my own server, and I would be the only one who will cry my eyes out. But unfortunately, that's just the best way to learn it. For now, I've avoided that. Thanks a lot for the warnings!

tredegar 03-02-2010 04:36 PM

Quote:

I pretty much know my way around it, but because I'm in control, I can still mess up. A lot.
So that's why you take full backups, of course.
Quote:

I might know what I'm doing, but I still want things to be done quickly instead of safe.
"Quick" or "safe" ? Well, "You makes your choice and takes your pick". You can have one, or the other, but not necessarily both.


All times are GMT -5. The time now is 06:36 AM.