Partitions overlapping linux
I have problem with my partitions which are overlapping each other (fdisk -l
)
/dev/sda1 * 2048 206847 204800 100M 7 HPFS/NTFS/exFAT
/dev/sda2 8155136 220203007 212047872 101,1G 83 Linux
/dev/sda3 220203008 639633407 419430400 200G 7 HPFS/NTFS/exFAT
/dev/sda4 208894 976768064 976559171 465,7G f extended W95 (LBA)
/dev/sda5 208896 8155135 7946240 3,8G 82 exchange partition
/dev/sda6 639645696 976768064 337122369 160,8G 7 HPFS/NTFS/exFAT
How can I repair that ? Is deleting all the hard drive could repair this ?
I agree with quixotic's comment:
If all these partitions work, and you never need to change these partitions, you should be fine.
This partition table is very unusual. It looks like mangled MBR-based partitioning scheme. I will help you understand what's going on.
To know the partitions a program (like fdisk
or gparted
) performs the following analysis:
-
Master Boot Record (MBR) at sector
0
is read. It contains four partition entries, they are given numbers1
,2
,3
,4
. Any entry that's not empty defines a partition with corresponding number (likesda1
for the 1st entry). Notice you can have any set of these entries non-empty, so it's possible to have e.g.sda2
andsda4
only.
These partitions shouldn't overlap. It's a good practice to have them in order (first table entry goes first on the disk and so on). There's no need to leave any "unused" sectors between these partitions nor at the end; still it's common to have few "unused" sectors between MBR and the first partition. By "unused" I mean "not belonging to any partition", still they can be used for something else – e.g. sectors between MBR and the first partition are commonly used to store a stage of bootloader (that's why your sda1
starts at 2048
, not at 1
).
In your case there are sda1
, sda2
, sda3
and sda4
defined in MBR. Their entries are not exactly in disk order but it really doesn't matter (still it may confuse users). What matters is: sda2
and sda3
are within sda4
, so formally the partitions do overlap. Programs like gparted
detect this and raise a warning. In a moment I will explain why it's not fatal in your particular case.
- At most one of these partitions can be an extended partition (others are called primary partitions). If there is one, then further analysis will be performed.
Your sda4
is an extended partition.
- An extended partition is not supposed to hold a filesystem. Instead, it may contain zero or more logical partitions. The very first sector of the extended partition is called extended boot record (EBR) and describes the first logical partition (if any). The number associated with this partition is always
5
and it must begin after its EBR. The first EBR may point to the second EBR which describes partition number6
(which must begin after its EBR); the second EBR may point to the third one and so on. Eventually some EBR doesn't point to the next and it means it describes the last partition. EBRs don't store their numbers, they are like links of a chain. For this reason logical partitions have consecutive numbers.
In your case the sector number 208894
contains EBR that describes sda5
. There is also another EBR, probably somewhere between 639633408
and 639645695
that describes sda6
. The only two logical partitions don't fill the whole sda4
, that's why gparted
tells you there is 300 GB of free space. If you examine the contents of sda4
only, you see free space. If you examine entries in MBR only, you see overlapping partitions. The trick is sda2
and sda3
fit into this allegedly free space – that's why the overlapping isn't fatal.
gparted
is not smart enough to spot this because your setup is so unusual, crazy I would say.
Another comment:
I don't know that
fdisk
or other tools won't imagine 300G of free space in the extended partition and let you create additional partitions there, which would overlap withsda(2,3)
.
I say It's highly possible they let you break things this way.
So what can you do? If it works, don't touch.
Well, one could deal with this mess and make the partition layout perfectly sane, but (e.g.):
- some partition numbers would change, I expect problems booting Windows (there is Windows, isn't there?);
-
primary
sda2
should be new logicalsda6
but there is no free sector between them for EBR.
With careful (and manual) partition table editing, partition moving/resizing, repairing the boot process etc. this can be done. Many things can go wrong though.
Can deleting all the hard drive repair this?
You mean: backup important files, delete all the partitions, create sane partitions and filesystems from scratch, install OSes, then copy the files back? Yes, it would repair this.