Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
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.


  Search this Thread
Old 02-06-2005, 12:10 AM   #1
Registered: Feb 2003
Distribution: Suse 8.1
Posts: 102

Rep: Reputation: 15
Filesystem Magic numbers? where are they defined?

Hello -

Is there a way to read the magic number for a filesystem on a partition, and then compare that to a database/list of magic numbers?

I'm particularily interested in partitions that may be mislabeled (thus fooling fdisk) and also in determing whether fdisk's "Linux" output is ext2, ext3, reiser, etc.....

Any ideas?

Thanks in advnace!

Old 02-06-2005, 02:22 AM   #2
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
cfdisk will let you set the "type" of partition. This sounds like what you're looking for. It will also give you a list of varying file systems to go with the selection.
Old 02-06-2005, 06:37 AM   #3
LQ Guru
Registered: Jan 2002
Posts: 6,042

Rep: Reputation: Disabled
Most Linux filesystems like ext2, ext3, ReiserFS, JFS, XFS, use type 83, so you can not tell. The only way to know what filesystem is what is learning each filesystem and write a program. Typing mount -t auto should automatically detect the filesystem. No, cfdisk will not detect the filesystem because it is a front end to fdisk.
Old 02-07-2005, 12:42 AM   #4
Registered: Jun 2004
Location: Northern CA
Distribution: Debian
Posts: 835

Rep: Reputation: 49
<little additional looking arround>

First, yeah I know that cfdisk is a frontend to fdisk. It does deal with partition type numbers and it does tell you what values are appropriate for particular file systems.

Yes, I understand that the number is not stored in the file system, and can be wrong. I haven't seen problems with this in linux, and have only once had a problem with this in windows.

A simpler way to determine a filesystem type is using the "guessfstype" command. Letting mount guess and then checking with "cat /proc/mounts" will also give it to you (as Electro eluded to).

To the best of my knowledge, the partition type number is completely separate from what is actually in the partition. I guess it's supposed to be a way to label what filesystem is supposed to be there, but it doesn't mean that the number is accurate.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
No mountpoints defined after magic partition... jiapei100 Linux - General 1 06-30-2005 07:17 AM
DISCUSSION: Virtual Filesystem: Building a Linux Filesystem from an Ordinary File mchirico LinuxAnswers Discussion 0 10-28-2004 11:35 PM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 10:18 AM
magic numbers problem muneebs123 Programming 2 09-05-2003 02:33 PM
magic numbers muneebs123 Mandriva 1 09-04-2003 07:31 PM > Forums > Linux Forums > Linux - General

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

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