blockdev Linux command could show sector and size information for deleted partitions, which are still in use (i.e. mounted).
Deleting partitions in use their characters’ devices under /dev are preserved till the partitions are released from use and the kernel reloads the new partition table.
So before rebooting or releasing the deleted partitions blockdev may be used to report useful information for future recovery:
Delete the partitions with parted by just overwriting the partition table with empty one, for example:
[root@srv ~]# parted /dev/sda GNU Parted 3.1 Using /dev/sda Welcome to GNU Parted! Type 'help' to view a list of commands. (parted) p Model: ATA Crucial_CT500MX2 (scsi) Disk /dev/sda: 500GB Sector size (logical/physical): 512B/4096B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags 1 1049kB 34.3GB 34.3GB primary boot, raid 2 34.4GB 34.9GB 537MB primary raid 3 34.9GB 67.1GB 32.2GB primary raid 4 67.1GB 500GB 433GB extended lba 5 67.1GB 500GB 433GB logical raid (parted) mklabel msdos Warning: The existing disk label on /dev/sda will be destroyed and all data on this disk will be lost. Do you want to continue? Yes/No? Yes Error: Partition(s) 1, 2, 3, 4, 5 on /dev/sda have been written, but we have been unable to inform the kernel of the change, probably because it/they are in use. As a result, the old partition(s) will remain in use. You should reboot now before making further changes. Ignore/Cancel? Cancel (parted) p Model: ATA Crucial_CT500MX2 (scsi) Disk /dev/sda: 500GB Sector size (logical/physical): 512B/4096B Partition Table: msdos Disk Flags: Number Start End Size Type File system Flags (parted) q
First, print the partition table, then delete all partitions by setting an empty new partition table!
Use blockdev to show the deleted partitions information.
[root@srv ~]# blockdev --report /dev/sda1 /dev/sda2 /dev/sda3 /dev/sda4 /dev/sdb5 RO RA SSZ BSZ StartSec Size Device rw 512 512 4096 2048 34359738368 /dev/sda1 rw 512 512 4096 67110912 536870912 /dev/sda2 rw 512 512 4096 68159488 32212254720 /dev/sda3 blockdev: cannot open /dev/sda4: No such file or directory. rw 256 512 4096 131076096 432862658560 /dev/sdb5
The partitions, which are not in use, are removed from the kernel structures, so no information is available with blockdev. Their characters’ devices under /dev/ are removed, too.
The information such as the size of the partitions and the start sectors may be used to recover the partitions manually with fdisk, sfdisk, sgdisk or parted or even testdisk – testdisk official site. In fact, testdisk is the recommended way.