5

Before the attempt to format a flash drive:

$ sudo fdisk -l
...
...
Disk /dev/sdc: 7.32 GiB, 7864320000 bytes, 15360000 sectors
Disk model: DataTraveler 3.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F89B0513-2DBE-8D40-BCDF-22BE8A5C5E45

Device     Start      End  Sectors  Size Type
/dev/sdc1   2048 15359966 15357919  7.3G Linux filesystem

During the attempt:

$ sudo mkfs.ntfs -I /dev/sdc1 
Cluster size has been automatically set to 4096 bytes.
Initializing device with zeroes: 100% - Done.
Creating NTFS volume structures.
mkntfs completed successfully. Have a nice day.

After the attempt:

$ sudo fdisk -l
...
...
Disk /dev/sdc: 7.32 GiB, 7864320000 bytes, 15360000 sectors
Disk model: DataTraveler 3.0
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: gpt
Disk identifier: F89B0513-2DBE-8D40-BCDF-22BE8A5C5E45

Device     Start      End  Sectors  Size Type
/dev/sdc1   2048 15359966 15357919  7.3G Linux filesystem

How is it possible? What am I doing wrong?

1
22

Here's what you're missing.

There's a partition table and there are file systems - they are related but different. You can perfectly have partitions type Linux filesystem (MBR notation Linux) formatted as NTFS and partitions type Microsoft basic data (MBR notation HPFS/NTFS/exFAT) formatted as e.g. ext4.

mkfs.* utilities simply format the storage, they never touch the partition table.

To change the partition type in the partition table you need to use any of these tools: fdisk, parted, sfdisk, gdisk, etc.

Linux GUI applications like GParted or KDE Partition Manager will set the correct partition type automatically when you create a new partition in the free space of your disk.

If you come from Windows then its partition tools do that automatically. Lastly Windows normally will refuse to mount a NTFS formatted partition when its type is not set to Microsoft basic data and if you have a partition type Microsoft basic data but it contains any other filesystem or its contains just binary zeros Windows will offer to format it.

2
  • 5
    NTFS is a filesystem, not a partitioning standard, and there is no practical difference between ‘Linux’ and ‘Windows’ partitions other than a few bytes in the partition table. It may also be worth noting that you can just use a flat disk without a partition table for a filesystem, Windows just does not like it (though most UNIX-like systems will have no issue with it at all). – Austin Hemmelgarn Jul 14 at 18:06
  • 1
    In Windows, it's called "super floppy", because floppies didn't use to have partition tables. It's been a long time since I worked with Windows, but AFAIR, it worked, you just couldn't create them using Windows builtin tools. The Windows format tool will always create a single partition covering the entire device for any device that is not a floppy. Not sure what the newer, more sophisticated GUI applications do. – Jörg W Mittag Jul 15 at 17:01
10

I assume you are confused by the Type Linux filesystem. The Type column in fdisk -l doesn't show what filesystem is on the device, it shows partition type -- on GPT this is a special GUID that helps systems recognize what is on the device, for Linux the default is Linux filesystem data and mkfs.ntfs doesn't change that. But it's not really a big problem, important is that the filesystem is NTFS (you can check with lsblk -f /dev/sdc1), the GUID is mostly ignored and having a "wrong" partition type shouldn't cause issues with your flash drive when using it on Windows. If you want to change it to something more appropriate for NTFS, you can use fdisk /dev/sdc to do that (t for partition type change and 11 (check list of partition types with L first it can be different with different versions of fdisk) for Microsoft basic data).

5
  • 2
    The number 11 is not set in stone. Actually it has changed and is likely to change again and can differ between versions etc. List; or test with 11 but be sure to read what it say ;) - If using script, simply use the hex-code/ID. As for Linux filesystem it all depends. Linux used same GUID as Microsoft basic data at first but this caused some issues. As for mkfs it is hard to say that it should change it. Just as one can format a Microsoft basic with anything one can also format a Linux fs with anything. It is a wider classification then filesystem. – ibuprofen Jul 14 at 6:27
  • Well ... that became a lengthy and messy comment, but hope it is readable c",) - Related: lists.gnu.org/archive/html/bug-parted/2011-06/msg00028.html – ibuprofen Jul 14 at 6:40
  • Thanks, I've updated the answer. I actually thought that some mkfs commands set the partition type, but a quick test with xfs, ext, vfat and pvcreate shows I was wrong. Some partitioning tools do that -- parted will set "correct" partition type when creating a filesystem with mkpart, but it makes sense for parted to do that, I shouldn't expect every mkfs tool to be able to change partition type. – Vojtech Trefny Jul 14 at 6:47
  • 1
    @VojtechTrefny: In general mkfs tools won't even be able to change the partition type, since they operate on the partition itself and may have no way of finding out where the partition table is stored. – psmears Jul 14 at 14:27
  • 6
    An mkfs program shouldn't mess with partition table entries, even if it did have access to the partition table. That's not its job. Its job is to create a file system on a block device or disk image file. Changing partition table entries is the job of partitioning tools like fdisk, gdisk, parted, etc. – cas Jul 14 at 16:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.