LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.

Notices


Reply
  Search this Thread
Old 09-01-2007, 08:00 AM   #1
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 999

Rep: Reputation: 142Reputation: 142
How to detect/read the block size of my partitions?


Ciao!
I have an innocent question: how can I know/doublecheck which block size I used to format my partitions?
This because I just copied my root filesystem from a jfs to a brand new reiserFS partition, and on the jfs it occupies 54GB, while on reiserFS it uses only 52. I would therefore like to check the block size of both filesystems in order to know, if it is the same, if this result is because of the features that ReiserFS uses with very small files (Gentoo package manager has thousands of such small files).
Thanks!
 
Old 09-01-2007, 07:10 PM   #2
osor
HCL Maintainer
 
Registered: Jan 2006
Distribution: (H)LFS, Gentoo
Posts: 2,450

Rep: Reputation: 78
I think some versions of dumpfs or equivalent will emit this information, though the utility is filesystem-specific (e.g., for ext2, you could use “dumpe2fs -h /path/to/block/device”). I don’t think there is any standard utility that does this for any filesystem, although I’m not sure why not. For example, you could do this (which is portable across all POSIX systems):
Code:
#include <stdio.h>
#include <stdlib.h>
#include <sys/statvfs.h>

int main(int argc, char *argv[])
{
	struct statvfs buf;
	if(statvfs(argv[1], &buf))
		exit(EXIT_FAILURE);

	printf("File system block size: %lu\n", buf.f_bsize);
	printf("Fundamental file system block size: %lu\n", buf.f_frsize);

	exit(EXIT_SUCCESS);
}
Compile the program with “make blocks” (assuming you call it “blocks.c”). Then just run the program as “./blocks /path/to/mountpoint” (notice that the path is not to the block device, but to the mountpoint — e.g., instead of “/dev/sda1” use “/usr”).
 
Old 09-03-2007, 12:12 PM   #3
Pearlseattle
Member
 
Registered: Aug 2007
Location: Zurich, Switzerland
Distribution: Gentoo
Posts: 999

Original Poster
Rep: Reputation: 142Reputation: 142
Hey, fantastic! Thank you very much!!!!!
 
  


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 On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Raid disk problem : Attempt to read block from filesystem resulted in short read ElmPie Linux - General 5 08-26-2008 05:21 AM
Block size of partition salmanucit Red Hat 4 04-10-2007 05:17 AM
Find Block size? cnm Linux - Newbie 4 11-15-2006 10:53 AM
block size ust Linux - Software 1 11-24-2005 11:45 PM
Why Linux returns the device size for 1 block more when it could be read?? fa3a Programming 1 01-29-2004 06:23 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

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