LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 06-24-2009, 06:09 AM   #1
crs_zxf
Member
 
Registered: Oct 2008
Distribution: Arch Linux
Posts: 37

Rep: Reputation: 17
difference between "df" and "fdisk" ??


Hi, guys!

I wanna know why the number of 1K-blocks reported by "df" and "fdisk" are different.

For my /dev/sda7, "df" says that I have 419642824 1k-blocks, while "fdisk" says I have 426332938+ 1k-blocks (BTW, I also wonder what does the trailing '+' mean).

At first, I thought it's due to the different unit used by "df" and "fdisk", that is, to "df", 1K = 1024B, and to "fdisk", 1K = 1000B, but seems that this explanation didn't make sense, since 426332938/1.024 = 416340759.765625, which is smaller than 419642824.

So why? Any ideas? Thanks!
 
Old 06-24-2009, 06:17 AM   #2
pixellany
LQ Veteran
 
Registered: Nov 2005
Location: Annapolis, MD
Distribution: Mint
Posts: 17,809

Rep: Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743Reputation: 743
fdisk reports on the disks and partitions---regardless of whether a filelsystem is installed (or which one).

df reports on the filesystem. I imagine the difference could be simmply associated with fielsystem overhead...
 
Old 06-24-2009, 06:26 AM   #3
Curingaa
LQ Newbie
 
Registered: Jun 2009
Location: Goiânia, Brazil
Distribution: Slackware
Posts: 6

Rep: Reputation: 0
Also good to see man pages (man df; man fdisk), or also df --help and fdisk --help....
 
Old 06-24-2009, 06:31 AM   #4
i92guboj
Gentoo support team
 
Registered: May 2008
Location: Lucena, Córdoba (Spain)
Distribution: Gentoo
Posts: 4,083

Rep: Reputation: 405Reputation: 405Reputation: 405Reputation: 405Reputation: 405
Quote:
Originally Posted by crs_zxf View Post
Hi, guys!

I wanna know why the number of 1K-blocks reported by "df" and "fdisk" are different.
I guess (but not sure) that being df fs-aware, the difference strives in the fact that a fs can report less total space for many reasons, for example, space reserved for root or fs overhead as someone stated above. But, as said, not sure.


Quote:
(BTW, I also wonder what does the trailing '+' mean).
This one I can explain, fdisk counts blocks of 1024 bytes, but hardware understands sectors of 512 bytes, the + means that the volume has an odd number of sectors, hence, it has one sector at the end which doesn't form a complete block, hence, you have 426332938 blocks of 1024 bytes + one sector of 512 bytes.
 
Old 06-24-2009, 08:56 AM   #5
crs_zxf
Member
 
Registered: Oct 2008
Distribution: Arch Linux
Posts: 37

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by i92guboj View Post
I guess (but not sure) that being df fs-aware, the difference strives in the fact that a fs can report less total space for many reasons, for example, space reserved for root or fs overhead as someone stated above. But, as said, not sure.
yeah, fs does reserve some space (normally 5% for linux) for special purposes, but the reserved space isn't reflected in the difference between "df" and "fdisk" output, it's reflected in the "df" output, in which
Code:
"Used" + "Available" < "1K-blocks"
and the difference between the two sides of the previous formula is the amount of space reserved by the filesystem.
 
Old 06-24-2009, 09:08 AM   #6
dfezz1
LQ Newbie
 
Registered: Mar 2008
Posts: 11

Rep: Reputation: 0
Hi

What is the actual size of the HDD? 400G or 406G ?
It has to be the filesystem verses raw blocks that is the difference. This is the only reason for the differnce in reporting.

Is this causing an issue or are you just curious? We try to fix problems here, although in doing so we do teach others and pass on aquired knowledge, but that isn't the focus.
 
Old 06-24-2009, 09:25 AM   #7
crs_zxf
Member
 
Registered: Oct 2008
Distribution: Arch Linux
Posts: 37

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by dfezz1 View Post
What is the actual size of the HDD? 400G or 406G ?
It has to be the filesystem verses raw blocks that is the difference. This is the only reason for the differnce in reporting.
The following is the entire output of "fdisk -l":
Code:
Disk /dev/sda: 500.1 GB, 500107862016 bytes
255 heads, 63 sectors/track, 60801 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Disk identifier: 0x624aa2e0

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *           1        6375    51207156    c  W95 FAT32 (LBA)
/dev/sda2            6376        6387       96390   83  Linux
/dev/sda3            6388       60801   437080455    5  Extended
/dev/sda5            6388        7603     9767488+  83  Linux
/dev/sda6            7604        7725      979933+  82  Linux swap / Solaris
/dev/sda7            7726       60801   426332938+  83  Linux
Quote:
Originally Posted by dfezz1 View Post
Is this causing an issue or are you just curious?
Both. Yesterday I just try to resize one of my partitions, but I'm a little bit confused about how to specify the size argument of "resize2fs" and the size argument passed to "n" command of "fdisk", resizing a partition normally involves using these 2 commands. (using "parted" is annoying, since you always need to deal with many filesystem features, like disabling some of them, which I'm not good at)

Last edited by crs_zxf; 06-24-2009 at 09:29 AM.
 
Old 06-24-2009, 10:24 AM   #8
PTrenholme
Senior Member
 
Registered: Dec 2004
Location: Olympia, WA, USA
Distribution: Fedora, (K)Ubuntu
Posts: 4,187

Rep: Reputation: 354Reputation: 354Reputation: 354Reputation: 354
There are several GUI partition editors that will hold your hand through resizing your partitions. So, if you're uncomfortable using the command line tools, try one of them.
 
Old 06-24-2009, 10:34 AM   #9
crs_zxf
Member
 
Registered: Oct 2008
Distribution: Arch Linux
Posts: 37

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by PTrenholme View Post
There are several GUI partition editors that will hold your hand through resizing your partitions. So, if you're uncomfortable using the command line tools, try one of them.
Thanks for your advice, but I think using command line tools can make me learn more, and better understand things.
 
Old 06-25-2009, 08:08 AM   #10
crs_zxf
Member
 
Registered: Oct 2008
Distribution: Arch Linux
Posts: 37

Original Poster
Rep: Reputation: 17
Quote:
Originally Posted by crs_zxf View Post
Both. Yesterday I just try to resize one of my partitions, but I'm a little bit confused about how to specify the size argument of "resize2fs" and the size argument passed to "n" command of "fdisk", resizing a partition normally involves using these 2 commands. (using "parted" is annoying, since you always need to deal with many filesystem features, like disabling some of them, which I'm not good at)
After doing some experiments, I think now I'm much more clear about the numbers that are reported or used by various tools.

To get a real 300G fs, you actually need to specify 304G as the argument of "resize2fs", here, by "real 300G", I mean the "size" reported by "df -h" is 300G. There's always an about 1.5% difference between the size reported by "df" and the argument you provide to "resize2fs" (of course, I don't know why, I only know the relationship between these two numbers).

Besides, the maximum amount of space that you can provide to "resize2fs" is the one reported by "fdisk -l".

Hope this info is helpful.

Last edited by crs_zxf; 06-25-2009 at 08:10 AM.
 
  


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
newbie question: whats the difference between "su root", "su" and "su -&quo mojarron Slackware 9 12-07-2009 04:08 PM
lilo says, "L 01 01 01" and fdisk says, "Unable to seek on /dev/hda1" clausawits Linux - General 3 12-31-2007 09:33 PM
fdisk reports odd "Start "and "End" sectors on single partition eponymous Linux - Software 3 10-01-2007 03:41 PM
Can you explain the difference between "Free Software (GNU)" and "Open Source"? vharishankar General 5 03-03-2005 09:40 AM
difference between "Web server local URL" and "IPv4 address"? kpachopoulos Linux - General 2 09-17-2004 01:30 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 05:16 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