LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
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 02-05-2005, 11:10 PM   #1
NiallC
Member
 
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!

NIall.
 
Old 02-06-2005, 01:22 AM   #2
gd2shoe
Member
 
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, 05:37 AM   #3
Electro
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-06-2005, 11:42 PM   #4
gd2shoe
Member
 
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.
 
  


Reply


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 06:17 AM
DISCUSSION: Virtual Filesystem: Building a Linux Filesystem from an Ordinary File mchirico LinuxAnswers Discussion 0 10-28-2004 10:35 PM
Adding numbers, break on non-numbers... Cruger Programming 1 03-22-2004 09:18 AM
magic numbers problem muneebs123 Programming 2 09-05-2003 01:33 PM
magic numbers muneebs123 Mandriva 1 09-04-2003 06:31 PM


All times are GMT -5. The time now is 12:36 AM.

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration