LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware
User Name
Password
Linux - Hardware This forum is for Hardware issues.
Having trouble installing a piece of hardware? Want to know if that peripheral is compatible with Linux?

Notices


Reply
  Search this Thread
Old 09-11-2011, 04:25 PM   #1
DebianUser
Member
 
Registered: Apr 2010
Posts: 88

Rep: Reputation: 15
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
 
Old 09-11-2011, 04:57 PM   #2
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
Quote:
Originally Posted by DebianUser View Post
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.
 
Old 09-12-2011, 04:14 AM   #3
DebianUser
Member
 
Registered: Apr 2010
Posts: 88

Original Poster
Rep: Reputation: 15
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?
 
Old 09-12-2011, 04:36 PM   #4
T3RM1NVT0R
Senior Member
 
Registered: Dec 2010
Location: Internet
Distribution: Linux Mint, SLES, CentOS, Red Hat
Posts: 2,385

Rep: Reputation: 477Reputation: 477Reputation: 477Reputation: 477Reputation: 477
@ 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.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Discrepancy df/du aztrix SUSE / openSUSE 5 01-12-2010 04:52 PM
Login Password Discrepancy sjreilly Linux - Security 0 07-27-2009 12:02 PM
x.org 6.9 discrepancy? bobbens Linux - Software 6 01-12-2006 06:17 AM
A/V speed discrepancy in mPlayer coldwater Linux - Software 2 11-12-2005 08:47 PM
Server uptime discrepancy peppiv Linux - Software 2 05-17-2004 11:41 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Hardware

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

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration