Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
Discover what filesystem(s) are on a disk/partition?
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo
View previous topic :: View next topic  
Author Message
humbletech99
Veteran
Veteran


Joined: 26 May 2005
Posts: 1229
Location: London

PostPosted: Sat Feb 02, 2008 5:55 pm    Post subject: Discover what filesystem(s) are on a disk/partition? Reply with quote

Is there any really good linux program to definitively tell you what filesystem(s) are on a disk/partitions?

When you do mount /dev/sda1, for example, the mount program detects the filesystem type and then mounts the partition as that filesystem so you can use it. I am looking for a program to just run the check of what filesystem it is without mounting the filesystem. I suspect that "mount" does this detection by looking for signatures in the first by bytes of the partition in order to identify it, so there should be some other program that can do this too, right?

EDIT: as I was typing this, I realized that fdisk and parted must be able to do this and they seem to, although I haven't tried them on any random disks yet. If anyone knows of any other good programs for file system detection, could you pls post them here?
_________________
The Human Equation:

value(geeks) > value(mundanes)
Back to top
View user's profile Send private message
frostschutz
Advocate
Advocate


Joined: 22 Feb 2005
Posts: 2977
Location: Germany

PostPosted: Sat Feb 02, 2008 6:26 pm    Post subject: Reply with quote

file

# file -s /dev/hda1
/dev/hda1: x86 boot sector, Microsoft Windows XP Bootloader NTLDR

# file -s /dev/sda2
/dev/sda2: Linux rev 1.0 ext3 filesystem data (needs journal recovery) (large files)

# file -s /dev/mapper/vg-ccache
/dev/mapper/vg-ccache: ReiserFS V3.6 block size 4096 (mounted or unclean) num blocks 1048576 r5 hash


EDIT:
fdisk doesn't care about file systems, it just shows partition types which has nothing to do with actual data on that partition.
no idea how parted does things.
Back to top
View user's profile Send private message
humbletech99
Veteran
Veteran


Joined: 26 May 2005
Posts: 1229
Location: London

PostPosted: Sat Feb 02, 2008 7:13 pm    Post subject: Reply with quote

ah, I didn't realize that file could actually work on partitions as well but this makes sense for unix philosophy of abstracting everything as files...

That's what I thought about fdisk in fact, that it looks at partition type rather than reading the actual filesystem itself, there is no guarantee that they are the same thing...

thanks
_________________
The Human Equation:

value(geeks) > value(mundanes)
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Sat Feb 02, 2008 7:14 pm    Post subject: Reply with quote

parted /dev/sda print:
Model: ATA MAXTOR STM325082 (scsi)
Disk /dev/sda: 250GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number  Start   End     Size    Type     File system  Flags
 1      32.3kB  132MB   132MB   primary  ext3         boot
 2      132MB   905MB   773MB   primary  linux-swap
 3      905MB   8916MB  8011MB  primary  ext3
 4      8916MB  250GB   241GB   primary               lvm

Parted is indeed able to detect filesystems on partitions.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
humbletech99
Veteran
Veteran


Joined: 26 May 2005
Posts: 1229
Location: London

PostPosted: Sat Feb 02, 2008 7:20 pm    Post subject: Reply with quote

question is, does it just look at partition types and print that, or does it actually read the filesystem to determine it's structure?
_________________
The Human Equation:

value(geeks) > value(mundanes)
Back to top
View user's profile Send private message
VinzC
Watchman
Watchman


Joined: 17 Apr 2004
Posts: 5098
Location: Dark side of the mood

PostPosted: Sat Feb 02, 2008 10:05 pm    Post subject: Reply with quote

humbletech99 wrote:
question is, does it just look at partition types and print that, or does it actually read the filesystem to determine it's structure?

Don't know really. It reports what's on my filesystems without lying and nothing else matters to me in fact ;-) .

EDIT: you could just have a look at the source code to be sure otherwise.
_________________
Gentoo addict: tomorrow I quit, I promise!... Just one more emerge...
1739!
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Other Things Gentoo All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum