LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   difference between partition type and file system (https://www.linuxquestions.org/questions/linux-software-2/difference-between-partition-type-and-file-system-4175597151/)

chinmaya5 01-10-2017 07:42 AM

difference between partition type and file system
 
while working with my usb drive, i first used fdisk and used "l" option to show the known partition type and opted ntfs volume set from the list. After being done with fdisk tool, i used mkfs to to create a new file system. i am now confused between the partition type that i created so that the usb drive can be used in windows 8 os and choose vfat as file system. so please clarify between partition type and file system....

pan64 01-10-2017 08:07 AM

I do not really understand your question, but probably: partition type is stored within the partition table, and may be modified without altering the filesystem used on the given partition (even, you may not need valid filesystem). And also you can create filesystem on any partition. Probably mkfs/formatting will set partition type too, but I'm not really sure about that, just I guess.

michaelk 01-10-2017 08:14 AM

In addition, the partition type is a label that is used by Windows to identify the type of filesystem. I have not tested this in Windows lately to see if this is still true.

linux does not care and as a frame of reference all regular linux filesystems use type 83. Formatting via linux does not change the partition type.

rknichols 01-10-2017 10:22 AM

Yes, Windows does care about partition types. That's why it is straightforward to hide a Windows partition for the case when you have more than one Windows installation on a disk.

Linux mostly doesn't care. For legacy MBR partitioning, there are about a dozen types that can contain subpartitions (the three "extended" partition types being the most familiar), and the kernel does treat those specially. There is also the (deprecated) "Linux RAID autodetect" type (0xfd). Other than those, the partition type does not matter to Linux. Linux looks for the various magic numbers (as with the "file" command) in the data to determine what a partition contains.

jefro 01-10-2017 05:18 PM

Depending on version of fdisk both of these may show up at ntfs volume.
So we'd need to know if you selected one of these of 7


86 FAT16 volume set

Legacy Fault Tolerant FAT16 volume. Windows NT 4.0 or earlier will add 0x80 to the partition type for partitions that are part of a Fault Tolerant set (mirrored or in a RAID-5 volume). Thus, one gets types 86, 87, 8b, 8c. See also Windows NT Boot Process and Hard Disk Constraints.

87 NTFS volume set

Legacy Fault Tolerant NTFS volume. HPFS Fault-Tolerant mirrored partition.


https://www.win.tue.nl/~aeb/partitio...n_types-1.html

https://unix.stackexchange.com/quest...ion-on-dev-sdx

chinmaya5 01-16-2017 11:46 AM

im still confused. the question that i want to ask is "what is the difference between partition type and file system?"

michaelk 01-16-2017 12:03 PM

They are completely different. The partition type is a byte of data in the partition table that is supposed to identify the filesystem for that partition. The filesystem is how data is data is stored and retrieved on storage medium. As stated above linux does not use the partition type to determine the filesystem so it really does not mater unless you are dual booting.

As an example the partition type for any linux regular linux filesystem is 83h. By any regular linux filesystem we mean ext2, ext3, ext4, xfs, reiserfs, btrfs, jfs and so on.

https://en.wikipedia.org/wiki/Partition_type

rknichols 01-16-2017 12:58 PM

Question: What is the difference between the label on a file cabinet drawer and the content of that drawer?
Answer: While there is probably some correlation, there is no necessarily relationship, and the drawer labeled "O - Z" might actually contain someone's lunchbox and no file folders at all.

To Linux, the partition type is just "the label on the drawer." It's going to open the drawers and look to determine the contents.

sundialsvcs 01-16-2017 01:49 PM

Here we go . . .

At a predictable place on the disk, there is a "disk label" of sorts, which contains (among other things) a "partition table." This table allows you to carve out four (or more) fixed regions of space on the drive.

Part of each partition-record is a partition type code, which simply clues the operating system as to what sort of data it should expect to find there ... and whether it should instead ignore that area completely. ("If you don't know what it is, don't mess with it!")

For example: a partition coded as "Linux swap" would not be expected to contain "a file system" at all. It would be expected to contain the on-disk data structure used by the Linux virtual memory manager. Likewise, the Linux virtual memory manager would consider only partitions that had been tagged with this particular partition-type code ... lest it somehow mis-identify :eek: its content and thereby "royally(!) screw things up."

If the partition table cues Linux that such-and-such area on the disk "should contain a file system," Linux will now look for it ... beginning with another "label record" which it expects to find at a particular place and to contain recognizable content. Specifically, Linux will attempt to identify (and load) an appropriate file-system driver (which may be a resident part of the kernel, or a loadable module), expecting it then to know how to handle the content of the partition.

The kernel mechanisms that are responsible for making this identification are called "coldplug" and "hotplug." The latter is responsible for removable devices.

By mutual agreement, the designers of all operating systems cooperate on these standards so that they can create software that works properly among various OSes, without stomping on each others' toes.

rknichols 01-16-2017 02:38 PM

Quote:

Originally Posted by sundialsvcs (Post 5655829)
For example: a partition coded as "Linux swap" would not be expected to contain "a file system" at all. It would be expected to contain the on-disk data structure used by the Linux virtual memory manager. Likewise, the Linux virtual memory manager would consider only partitions that had been tagged with this particular partition-type code ... lest it somehow mis-identify :eek: its content and thereby "royally(!) screw things up."

If the partition table cues Linux that such-and-such area on the disk "should contain a file system," Linux will now look for it ... beginning with another "label record" which it expects to find at a particular place and to contain recognizable content. Specifically, Linux will attempt to identify (and load) an appropriate file-system driver (which may be a resident part of the kernel, or a loadable module), expecting it then to know how to handle the content of the partition.

Sorry, but no. Only the partition types that can contain subpartitions (e.g., the "Extended" types) have any special treatment at all. Other than that, you can use any type for anything. You can run mkswap on a 0x83 ("Linux") partition and use it for swap. Likewise, you can run mkfs.ext4 on a 0x82 ("Linux swap") partition and use it for a filesystem. The virtual memory manager will try to use any partition you specify in a swapon command (or, with "swapon -a", have identified as "swap" in /etc/fstab). It of course will fail if the actual content of that partition does not begin with the swap header placed there by the mkswap command. The partition type does not matter.

I actually had a system that was running for years with swap on a type 0x83 partition, until one day I noticed and changed the type to 0x82 just to avoid confusing me. The Linux kernel and OS were not upset by that at all.

sundialsvcs 01-16-2017 03:20 PM

Pardon me ... I fear that I took the "'extended partition' exception" for granted in my previous comment.

Yes, the original set of partition-type codes was fixed. ("Think: MS-DOS on an 8086.") The "Extended" type-code was the original (and necessary) escape valve.

And, I will most-graciously grant your most-kindly correction "that the present-day logic no longer considers the 'partition-type' code."

(I confess that I am not surprised, although I have not myself lately studied the source-code. Thank you.)

Jjanel 01-17-2017 01:06 AM

@OP: Hi! Great to see you studying 'concepts'! (WikiPedia is great for concepts)
Tip: put 'wiki' in front of <concept> web-search, like: (DuckDuckGo/Google/etc)
Quote:

wiki file system
p.s. @Mod: maybe move to NewbieForum[?]... @LQgurus: ? ;)

hazel 01-17-2017 01:31 AM

Well, you learn something every day! I had always been under the impression that partition type and filesystem have to agree or there will be trouble somewhere.

rknichols 01-17-2017 08:41 AM

Quote:

Originally Posted by hazel (Post 5656036)
Well, you learn something every day! I had always been under the impression that partition type and filesystem have to agree or there will be trouble somewhere.

You just need to be careful with Windows filesystems and partition types. If you put a Linux filesystem on one of the partition types that Windows recognizes (e.g., 7 "HPFS/NTFS", or 0x0c "W95 FAT32 LBA"), Windows is going to suggest that it needs to be formatted. If you put an NTFS or FAT filesystem on a partition type that Windows does not recognize, Windows won't see it.

sundialsvcs 01-17-2017 09:25 AM

There are, of course, many very-good reasons why the partition-type code should indicate the actual content and purpose of the partition, especially when multiple operating systems may be involved, e.g. "dual booting."

If someone goes to diagnose a disk problem, the first thing they're going to look at is the partition table, and the contents of that table should be descriptive and appropriate. If you "get cute" and stick a file system on what's labeled to be a swap partition, a technician might see that it "isn't a valid swap partition" and run mkswap on it ... :eek: ... because you led him to anticipate that this is what the partition really contains! In fact, it's what you said it contains!


All times are GMT -5. The time now is 07:04 PM.