Solved Partition types

I have a device where gpart () shows a partition as ms-basic-data but file()-s identifies it as ext4.

This has probably occurred because a partition was created originally as ms-basic-data but eventually formatted as ext4

Is there some way to ensure that gpart reports the type correctly?
 
Is there some way to ensure that gpart reports the type correctly?
The type is correct. But the type of the partition doesn't depend on the actual filesystem the partition was formatted with. You can create any type of partition and format it with some other filesystem. There's nothing stopping you from doing this.
 
Is there any way I can change what type gpart shows?

I guess gpart modify might do the trick...

I'm hoping I don't break anything if I try but get things wrong.
 
Is there any way I can change what type gpart shows?
Partitions are defined by their GUID, each partition type has a specific GUID, gpart(8) just shows which GUID was used. So you would need to change the actual GUID on disk.

I'm hoping I don't break anything if I try but get things wrong.
Make an image of the disk and backup the partition table. Mess around with the image so you don't damage the original, see how far that gets you.
 
Is there any way I can change what type gpart shows?

I guess gpart modify might do the trick...

Can you say why this matters to you?

I'm hoping I don't break anything if I try but get things wrong.

What would you wish gpart to report? Is it really ext4? Does it mount as such?

You may recall the same issue with gpart reporting 'ntfs' for type 7 (in scheme MBR, not GPT), when type 7 can be IFS, HPFS, NTFS or ExFAT.

As noted above, partition type here is not necessarily related to which filesystem it becomes formatted (or reformated) as, or contains.
 
Can you say why this matters to you?

I have a lot of partitions on some disks and knowing how to mount them simplifies things for me.

Anyway I just found that

gpart modify -i 1 -t linux-data da0

made gpart consistent with file, so I'm happy with that, though I'd like to know where 'partition type' data is stored.
 
Use labels ( gpart modify -l my-linux-root, for example) to really mark your partitions with what they're used for. Depending on type GUID is going to be rather vague and confusing real fast.

As a bonus, these labels will show up in /dev/gpt/ on FreeBSD, and /dev/disk/by-partlabel/ on Linux.
 
Back
Top