Pain when using MBR after GPT was on HDD

Did anyone try this? I've had a major pain, after I realized that FreeBSD places labels that are not being overwritten by fdisk.

The story...

I've had a system running. The hardware was failing and I wanted to copy the whole disk contents to a second PC (same architecture). Usually it's a matter of fdisk, dump and restore. Then some fstab and rc.conf (NIC) corrections.

This was very naive, because soon I noticed that the root partition could not be found. I've typed "?" to find drives that are accessible as possible root file systems. I've found some old partitions that I thought were overwritten ("ad0p1" etc and lots of old ufsid labels; "ad0s1a" was not usable!).

Quickly I realized, I have to overwrite the space from block 1 to 62 with zeroes (space between MBR (0) and first label (63)). At this moment I've already thought that the situation is very annoying, but it was not the end!

I've restarted FreeBSD and then... I got a warning message similar to this "GPT label is damaged! Luckily I've found a copy of it somewhere else!". Again... old partitions, old ufsids as above. Now I've got really mad, because I wasn't sure if I ever get this to work. I've remembered that someone has told me that GEOM stores meta-data at the end(!) of the partition, drive, slice or whatever container you assign it. I've also noticed that there have been some 1000 of blocks after the slice specified in the MBR. I've used my best maths efforts to carefully figure out the offsets and then zeroed them out.

The zombie partitions went away and the reboot what successful this time. But it was unnecessarily painful, don't you think? Isn't there a way to make this better?
 
This would work (gpart destroy), when gpart would not crash on a livefs CD. I've tried to use gpart for installation from the live CD, but it only crashed that's why I've used MBR. It worked, but you see what I got.

Why doesn't fdisk prepare the hard drive accordingly, when I am using it?
 
Back
Top