I accidentally deleted the partition table of 2 drives in my 4 drive RAID6 by reversing the order of sudo sgdisk -R=/dev/sdb /dev/sdz

parted /dev/sdb print currently reports:

Model: ATA ST2000DM008-2FR1 (scsi)
Disk /dev/sdd: 2000GB
Sector size (logical/physical): 512B/4096B
Partition Table: gpt
Disk Flags: 

Number  Start   End     Size    File system  Name        Flags

lsblk still reports:

sdb                               8:16   0   1.8T  0 disk  
└─sdb1                            8:17   0   1.8T  0 

Question: Do I need to replace the partition table? What happens if I don't? If I do, what would be the best way to recover that? I do have the following bit of information from parted that I captured before stupidly deleting it

 1      1049kB  2000GB  2000GB               Linux RAID  raid

Just recreate the partition table exactly as it was before deleting (you can check it by using another disk as example).

lsblk continue showing the partition because the disk was in use (by the raid array) and the kernel did not upgrade its view of the undelying partition. You should be safe until a reboot or a partprobe command updates the kernel view of the partition table.

As a very important note, this can be the right time to check you backup and, if something is missing, to copy your data out the array before mangling again with the partition table.

  • Did the backup without a hitch. I restored the partition on the two drives using testdisk, though I haven't tried to reboot or partprobe yet. dumpe2fs reports a bad superblock on the partition. – soundsofpolaris Apr 28 at 18:17
  • @soundsofpolaris dumpe2fs should be run against the md raid array, not on the partition under it. I suggest to try to reboot now that you have up-to-date backups. – shodanshok Apr 28 at 19:01
  • Thank you! Because of your comments, I didn't panic and reboot. I was able to get a fullback and even sync a new drive. On reboot, turns out partitions recovered from testdisk were off, but I was able to spin up an old drive and copy the partition table (correctly this time!) – soundsofpolaris Apr 30 at 18:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.