Linux - NewbieThis 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
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
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.
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.
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.
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.
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
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)
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.
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.
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".
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.