Quantcast
Channel: User Kamil Maciorowski - Super User
Viewing all articles
Browse latest Browse all 645

Answer by Kamil Maciorowski for If I deleted a partition, will that delete the data on this partition?

$
0
0

If I deleted a partition, will that delete the data on this partition?

Strictly: no. Deleting a partition means removing the relevant entry from the partition table. This does nothing to data inside the partition*. If you re-create the entry in the partition table then you will revert the deletion. In fact a standard way to expand a partition+filesystem to the right may involve deleting the partition. See this question and my answer there.

After just deleting a partition, the data is still there. After re-creating just the partition the data is still there. Note that some partitioning tools may detect the header of the old filesystem and ask if you want to destroy it. They assume that maybe you are going to create a new filesystem and thus they offer you an option to make the partition appear "clean" (because in general some tools that create filesystems may refuse to work if the partition appears to contain a filesystem already). If you re-create the partition without choosing this option then the data will be still there.

But if a new filesystem gets created, it shall not and will not use the old data; it will gradually overwrite it with its own data. It's a job of the new filesystem to always return its own data. One of the reasons to have a filesystem as an abstraction layer is you (and your programs) don't have to worry which parts of the partition get overwritten or what happens to old data. The filesystem is obliged to reliably give you data you have stored in it, not some random nor stale data. So in normal operation there is no risk that some old files appear or something gets corrupted because of the fact the old filesystem used to be there.

It may be possible to recover some old files. Recovery programs bypass the filesystem layer in order to do so. There may also be a way (depending on the type of the new filesystem) to allocate blocks to a regular file without zeroing them, this would make some old data appear inside the file. This can be useful while testing, debugging or manually repairing the (new) filesystem. It's not something any OS (including your newly reinstalled Ubuntu) does by itself.

The fact the old filesystem was there will not corrupt anything.


* In Windows it's common to create a partition and its filesystem in one step, this makes many users think that "partition" and "filesystem" are synonyms (while they are certainly not). I can imagine this philosophy can be extended to deleting partitions, so there may exist overzealous tools that wipe the beginning of the partition when removing the entry from the partition table. Their "delete partition" action should be named "delete partition and cripple filesystem". The actual act of deleting a partition does nothing to the data inside the partition. If a tool commanded to just delete a partition does anything to the data, it's being overzealous.


Viewing all articles
Browse latest Browse all 645

Trending Articles