Accidentally removed "type" flag on partition in gparted

I accidentally removed the “type” flag on a partition while using gparted and the partition is no longer visible to gparted or to dolphin file manager. The data and the partition is still there and I can manually mount it, but it shows up as empty space otherwise. While I am not that worried about it as I can manually mount it, I am hoping to upgrade to the newest openSUSE soon and so it would be nice if partition editors could see the partition so it doesn’t get written over. I don’t know much about managing disk flags through the command line, so any help is appreciated. I am using openSUSE 12.1 if it makes a difference.

Please show an fdisk -l of the disk.

This is the disk in question:

Disk /dev/sda: 750.2 GB, 750156374016 bytes
255 heads, 63 sectors/track, 91201 cylinders, total 1465149168 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x000a509f

Device Boot Start End Blocks Id System
/dev/sda1 4096 409604095 204800000 83 Linux
/dev/sda2 409604096 819204095 204800000 0 Empty

As you see the type of sda2 is set to 0 (it is not a flag and it is not removed, it is an 8 bit field).

You did not tell what the type was before you set it to 0, but when the partition contains a Linux file system (like ext4), then it should be 83 like on sda1.

I guess that you can set it to same way you set it to 0 by using gparted and I do not quite understand why you did not do that. I never used gparted, thus I can only tell you how to do this using fdisk. To become root and start fdisk:

su -c 'fdisk /dev/sda2'

fdisk is interactive. You can see what single letter commands exist with the command


but in this case we need the command


you are now asked for the partition number


and then for the type:


then check if it is correct now:


when OK write the changed partition table to the disk:



BTW, next time when you post here copied/pasted computer text like you did above with the fdisk -l listing do so between CODE tags, else it is badly readable. You get the CODE tags by clicking the # button in the toolbar ofthe post editor.

Sorry it took so long to get back to you on this. The reason that I didn’t fix it in gparted was because the partition was not detected in gparted, it only showed sda1 and the rest of the disk was free unpartitioned space. In any case what you said worked like a charm (though I had to put /dev/sda and not /dev/sda2). While I knew that the type number I needed was 83, I had no idea fdisk was interactive and I wasn’t able to find anything that described what you said to do when I searched before posting. Thanks a lot.

Documentation for fdisk? Start with

man fdisk

as always when looking for Unix/Linux documentation.