Friday, October 27, 2017

partitioning - How to get rid of a zero-size invisible partition left after deleting Windows boot partition



Computers sold with pre-installed Windows 7 have a small "System Reserved" boot partition at the beginning of the disk which is not really necessary as Windows can boot alone or alongside Ubuntu without this. So I've decided to remove it from a couple of machines which went OK (except the extra effort of moving/resizing partitions to the left and sometimes having to repair Windows boot manager).



In one of the machines, however, I was surprised to see that the new partition numbers start from 2 in GParted. And the output of fdisk -l is like this:



   Device Boot      Start         End      Blocks   Id  System

/dev/sdb2 * 2048 52426751 26212352 7 HPFS/NTFS/exFAT
/dev/sdb3 52426752 942684159 445128704 7 HPFS/NTFS/exFAT
/dev/sdb4 942684160 976773119 17044480 12 Compaq diagnostics


It took me some time to discover that the reason for this was the fact that somehow a zero-size invisible partition was left after I deleted that partition as seen in the output of sfdisk -l below:



   Device Boot Start     End   #cyls    #blocks   Id  System
/dev/sdb1 0 - 0 0 0 Empty
/dev/sdb2 * 0+ 3263- 3264- 26212352 7 HPFS/NTFS/exFAT

/dev/sdb3 3263+ 58679- 55416- 445128704 7 HPFS/NTFS/exFAT
/dev/sdb4 58679+ 60801- 2122- 17044480 12 Compaq diagnostics


Apart from the unseemly partition numbering, I'm curious to know how I can ged rid of this weird partition?



You can't, because it's not there. On an MBR disk, there are always precisely four primary partition entries, but some of them can be unused. The sfdisk -l command you used lists all of these entries, even if they're unused. In other words, sfdisk -l is showing a "ghost" entry -- the data structures are present, but they don't define a partition. You could shift the numbers so that you've got partitions 1-3 rather than 2-4, but then using sfdisk -l would show a similar "ghost" partition #4. This is not an error, a bug, or a problem; it's just the way the MBR data structures are defined.



I mentioned you can shift the partition numbers. AFAIK, this is awkward to do with fdisk, sfdisk, or parted, and you also risk rendering Windows unbootable if you try, since Windows can be fussy about its partitions. Thus, I don't recommend you try; just live with the fact that your partitions begin with #2. If, however, this bugs you enough to risk an unbootable Windows installation, you could try my FixParts program. It includes an s option that sorts the partitions; that should shift their numbers down by 1. If you try this and Windows doesn't boot, though, I can't help you, since I'm not a Windows expert.


No comments:

Post a Comment

11.10 - Can't boot from USB after installing Ubuntu

I bought a Samsung series 5 notebook and a very strange thing happened: I installed Ubuntu 11.10 from a usb pen drive but when I restarted (...