LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   df vs du discrepancy (https://www.linuxquestions.org/questions/linux-hardware-18/df-vs-du-discrepancy-902476/)

DebianUser 09-11-2011 04:25 PM

df vs du discrepancy
 
I have a usbflash drive and via df it was showing size 3.8G with 258M free. I deleted the only couple of files on it and it then shows 268M free even though it was empty. It's formatted to FAT32 so I formatted it in my windows pc and put it back in the linux box and this time it showed correctly of

/dev/sdc1 3.8G 4.0K 3.8G 1% /mnt/usbflash

what has happened here? as I think it's done the same for my usb hard disk

df shows

/dev/sdd1 466G 466G 0 100% /mnt/usbdisk

but du shows

415G used

I believe du is what's actually physically in use on the disk but df accounts for other allocated stuff waiting to go on it is this right.

I did

lsof | grep deleted
mysqld 2157 mysql 4u REG 9,0 0 94076933 /tmp/ibODLTNW (deleted)
mysqld 2157 mysql 5u REG 9,0 0 94076934 /tmp/ibzVf00G (deleted)
mysqld 2157 mysql 6u REG 9,0 0 94076935 /tmp/ibfy36dr (deleted)
mysqld 2157 mysql 7u REG 9,0 0 94076936 /tmp/ibZufItb (deleted)
mysqld 2157 mysql 11u REG 9,0 0 94076937 /tmp/ib3VuYdW (deleted)

if this means anything?

I'm running Debian 2.6.26-2-686

T3RM1NVT0R 09-11-2011 04:57 PM

Quote:

Originally Posted by DebianUser (Post 4469138)
I have a usbflash drive and via df it was showing size 3.8G with 258M free. I deleted the only couple of files on it and it then shows 268M free even though it was empty. It's formatted to FAT32 so I formatted it in my windows pc and put it back in the linux box and this time it showed correctly of

/dev/sdc1 3.8G 4.0K 3.8G 1% /mnt/usbflash

what has happened here? as I think it's done the same for my usb hard disk

For this part what I can think is your usbflash drive is not mounted with sync mode on. What I mean to say is when you deleted the files the changes were not written to it. If you would have tried umounting and then remounting I am quite sure you would have got the correct disk space usage.



Quote:


df shows

/dev/sdd1 466G 466G 0 100% /mnt/usbdisk

but du shows

415G used

I believe du is what's actually physically in use on the disk but df accounts for other allocated stuff waiting to go on it is this right.

I did

lsof | grep deleted
mysqld 2157 mysql 4u REG 9,0 0 94076933 /tmp/ibODLTNW (deleted)
mysqld 2157 mysql 5u REG 9,0 0 94076934 /tmp/ibzVf00G (deleted)
mysqld 2157 mysql 6u REG 9,0 0 94076935 /tmp/ibfy36dr (deleted)
mysqld 2157 mysql 7u REG 9,0 0 94076936 /tmp/ibZufItb (deleted)
mysqld 2157 mysql 11u REG 9,0 0 94076937 /tmp/ib3VuYdW (deleted)

if this means anything?

I'm running Debian 2.6.26-2-686
For this part I need to understand what exactly you are trying to put forward. Are you trying to say that du and df values differ and du shows the current statistics and df shows old stats when drive mounted in async mode?

Please explain.

DebianUser 09-12-2011 04:14 AM

I tried remounting the usbflash drive before I formatted it and it still showed the incorrect sizes.

Yes the fact that the sizes from df and du differ and how to rectify it. How do I mount in async mode?

T3RM1NVT0R 09-12-2011 04:36 PM

@ Reply
 
Alright. I have tested it myself and I found the same discrepancy. I tested on my SLES system and Ubuntu system with the same results that is there was a difference between the output of df and du.

And yes df output is greater than du output. After a bit of digging I found: http://www.cyberciti.biz/tips/freebs...nt-output.html

The above link explains the concept of open file descriptor which is the reason behind mis-match.

When you mount a flash drive if I am not wrong it always mount in async mode.

I hope this helps.


All times are GMT -5. The time now is 06:42 PM.