I accidentally deleted a partition and given partitioning essentially is just how the space is divided, thought it wouldn't be too hard to repair the mistake. I was wrong. Why does deleting a partition make the data in accessible? When I try to access the disk, now it says it needs to be formatted before it can be accessed. This confuses me as the format was not changed.
12 Answers
Why does deleting a partition cause data to be lost?
It doesn't.
I mean, well, sometimes it doesn't.
Sometimes it does.
It depends on what software you use.
In theory, there is no good reason why deleting a partition needs to result in losing the data. After all, a partition, is basically just a set of numbers, located in a specific spot (called the "partition table"), which specify the boundaries of the partition. In theory, changing those numbers to zeroes wouldn't cause a change in the other sectors that are inside the boundaries of the partition. So, in theory, your filesystem volume should remain in tact (unaltered).
However, there's a notable exception to that theory.
For whatever reason, (at least some versions of) MS-DOS FORMAT.COM expected that the first sector of the new filesystem volume contains bits cleared to zero (before FORMAT runs). Clearing those bits to zero would be a sensible task for FORMAT.COM to do, but instead, FORMAT.COM just expects that this task gets done.
In order to accommodate this weird expectation, MS-DOS FDISK.EXE (the partitioning software) would erase the first sector.
The most sensible tool would be FORMAT. Linux man pages @ die.net: fdisk states, “we consider this a bug in DOS FORMAT and DOS FDISK.” However, since both of those pieces of software came with the same operating system, this arrangement tended to work out just fine. People wouldn't be aware of this situation if they were simply following the instructions in MS-DOS's manual.
Despite however improper this arrangement might seem, some other operating systems would typically support doing the same thing, in order to be rather compatible with MS-DOS. This is because MS-DOS was popular (prior to Windows 95 and subsequent versions of Microsoft Windows), so other operating systems sought compatibility with MS-DOS.
Make no mistake: You can use some software (e.g., OpenBSD's fdisk) to "erase" a partition (which, at least for MBR-based partitions, is defined as setting the partition Type Identifier to zero) and not lose any data within the partition. If you recorded the settings (boundaries, type identifier), you can re-write those values, and all the data in the partition remains in tact.
So, whether the data at the start of the partition gets mutilated, or not, depends on what software you use. (Or, possibly for some software, what settings/options you choose.)
1By deleting the partition you are removing the marker information that tells operating systems where the partition is on the disk and how much of the disk it takes up.
Without that information the operating system has no idea where to start looking for valid filesystem data. Part of the partitioning and formatting of the disk will set up the headers telling the operating system where all the filesystem metadata is so that it can be read.
If you delete and recreate the partition it will not have set up the filesystem specific data in the partition header. It needs to be formatted before the disk can be used.
I have heard that in the event that you delete a partition then TestDisk can be used to recover it, but if you recreated the partition manually then you probably overwrote the data it would have tried to recover.