14

I have an external HDD which I formatted as NTFS partition in Windows. Now, I formatted this HDD in my linux system using the below command.

mkfs.ext3 /dev/sdb1

It was formatted successfully. However, when I run the fdisk -l command, it gives me the system as NTFS/HPFS.

   Device Boot      Start         End      Blocks   Id  System
   /dev/sdb1               1      121601   976760001   83  HPFS/NTFS

However, the command df -T /dev/sdb1 was still giving me the file system type as ext3.

Why is it not showing me the system as Linux when I run the fdisk -l command?

2 Answers 2

16

When setting up a disk or partition there are 2 aspects to doing this. The first is the act of laying down a partition table scheme on the disk using typically either MBR (Master Boot Record) or GPT (GUID Partitioning Table) formats. Both of these lay down a "structure" on the disk.

MBR

If you take a look at the structure of an MBR you'll notice that there is a section allotted for defining a partitions "type".

                          ss of layout

The valid partition types for MBR:

Command (m for help): l

 0  Empty           24  NEC DOS         81  Minix / old Lin bf  Solaris        
 1  FAT12           27  Hidden NTFS Win 82  Linux swap / So c1  DRDOS/sec (FAT-
 2  XENIX root      39  Plan 9          83  Linux           c4  DRDOS/sec (FAT-
 3  XENIX usr       3c  PartitionMagic  84  OS/2 hidden C:  c6  DRDOS/sec (FAT-
 4  FAT16 <32M      40  Venix 80286     85  Linux extended  c7  Syrinx         
 5  Extended        41  PPC PReP Boot   86  NTFS volume set da  Non-FS data    
 6  FAT16           42  SFS             87  NTFS volume set db  CP/M / CTOS / .
 7  HPFS/NTFS/exFAT 4d  QNX4.x          88  Linux plaintext de  Dell Utility   
 8  AIX             4e  QNX4.x 2nd part 8e  Linux LVM       df  BootIt         
 9  AIX bootable    4f  QNX4.x 3rd part 93  Amoeba          e1  DOS access     
 a  OS/2 Boot Manag 50  OnTrack DM      94  Amoeba BBT      e3  DOS R/O        
 b  W95 FAT32       51  OnTrack DM6 Aux 9f  BSD/OS          e4  SpeedStor      
 c  W95 FAT32 (LBA) 52  CP/M            a0  IBM Thinkpad hi eb  BeOS fs        
 e  W95 FAT16 (LBA) 53  OnTrack DM6 Aux a5  FreeBSD         ee  GPT            
 f  W95 Ext'd (LBA) 54  OnTrackDM6      a6  OpenBSD         ef  EFI (FAT-12/16/
10  OPUS            55  EZ-Drive        a7  NeXTSTEP        f0  Linux/PA-RISC b
11  Hidden FAT12    56  Golden Bow      a8  Darwin UFS      f1  SpeedStor      
12  Compaq diagnost 5c  Priam Edisk     a9  NetBSD          f4  SpeedStor      
14  Hidden FAT16 <3 61  SpeedStor       ab  Darwin boot     f2  DOS secondary  
16  Hidden FAT16    63  GNU HURD or Sys af  HFS / HFS+      fb  VMware VMFS    
17  Hidden HPFS/NTF 64  Novell Netware  b7  BSDI fs         fc  VMware VMKCORE 
18  AST SmartSleep  65  Novell Netware  b8  BSDI swap       fd  Linux raid auto
1b  Hidden W95 FAT3 70  DiskSecure Mult bb  Boot Wizard hid fe  LANstep        
1c  Hidden W95 FAT3 75  PC/IX           be  Solaris boot    ff  BBT            
1e  Hidden W95 FAT1 80  Old Minix      

So in your case the partition is identified as being of type 17.

Filesystem format

The second aspect to this is the formatting of the space within the partition itself (the filesystem). These are the filesystems that most are more familiar with when dealing with EXT3/4, etc.

So in your case you've mixed a partition type and a filesystem that generally don't go together. I should mention here that tools such as fdisk are "dumb" in the sense that they'll generally let you do whatever you want whether it makes sense to do so or not.

Changing the partition's type

So to resolve your issue you'll need to change the partition type to 83 if it's a bare partition being formatted as EXT4, or 8e if it's an LVM partition. The good news is you can use fdisk to change the partitions type through the t function:

   t   change a partition's system id

After successfully doing this your partitions should looks something like this:

   Device Boot      Start         End      Blocks   Id  System
/dev/sda1   *        2048     1026047      512000   83  Linux
/dev/sda2         1026048   976773119   487873536   8e  Linux LVM

What I would do!

However in your case since the partition type appears to be listed already as 83 and the partition is reported as being HPFS/NTFS, I think I'd be inclined to delete the partition(s) all together and start over with a clean slate.

3
  • 1
    Thanks a lot for the wonderful explanation. I have written 30 GB data to this HDD whose system is currently HPFS/NTFS. If I use fdisk -t command to change the partition type to Linux, does that mean it will delete the 30 GB data that is present inside the disk?
    – Ramesh
    Commented Feb 10, 2014 at 3:52
  • I've never tried to change a disks type when I've made a similar mistake as you have in the past. In general the partition table info is separate from your data so the data should be left alone intact. I think I would back it up first, then attempt to change it. Also if you're not mounting the partition in Windows you'd be OK to leave it as it is. Linux doesn't care about the type, only Windows will when/if it were to attempt to mount it.
    – slm
    Commented Feb 10, 2014 at 4:00
  • Anectdotal evidence: I had an ext4-formatted partition with a type id of 7 and correspondingly identified as HPFS/NTFS/exFAT. The t command with 83 re-labeled the disk as Linux, with no data loss :)
    – Johann
    Commented Jul 14, 2017 at 18:50
6

The id in the partition table doesn't have to have anything to do with what's actually in the partition. For example, there's no type for an XFS filesystem -- people just use "linux" (83). fdisk will say HPFS/NTFS until you change the partition type:

fdisk /dev/sdb
t 1
83
w

And then reboot, or reattach the drive. (make sure it's not mounted first)

1
  • I was wondering about this, too. Essentially, changing this number has no bearing on anything (as long as I don't change it to a Swap partition or something like that)?
    – palswim
    Commented May 20, 2014 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .