Solved Restore slices destroyed by "fdisk -I"

I know that there are many similar posts around here, but I wasn't able to find anyone else with exactly the same problem.

On this HD
Code:
ada1: 476940MB (976773168 512 byte sectors)
I had slices and partitions like this:
Code:
ada1s1
ada1s2
  ada1s2a
  ada1s2d
  ada1s2e
  ada1s2f
I accidentally destroyed slices information with fdisk -I ada1.

I have backup of fdisk info before this accident:
Code:
Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 126, size 79691661 (38911 Meg), flag 0
        beg: cyl 0/ head 2/ sector 1;
        end: cyl 1023/ head 255/ sector 63
The data for partition 2 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 79691850, size 897081255 (438027 Meg), flag 80 (active)
        beg: cyl 1023/ head 255/ sector 63;
        end: cyl 1023/ head 255/ sector 63
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
Is it possible to restore slices info using this data?

AFAIU, that should get back ada1s1 and ada1s2. Then I can run sysutils/scan_ffs on ada1s2 and restore bsdlabel info, and access my data again.
 
It's very counter-intuitive but create "new" partitions/slices with the exact same start and end. Creating/removing partitions (or slices) doesn't actually remove any data. So if you recreate the partitions using the exact same information your data should magically reappear.
 
I entered the old data by hand ( fdisk -i) and now I have:
Code:
******* Working on device /dev/ada1 *******
parameters extracted from in-core disklabel are:
cylinders=969021 heads=16 sectors/track=63 (1008 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=969021 heads=16 sectors/track=63 (1008 blks/cyl)

Media sector size is 512
Warning: BIOS sector numbering starts with sector 1
Information from DOS bootblock is:
The data for partition 1 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 126, size 79691661 (38911 Meg), flag 0
    beg: cyl 0/ head 2/ sector 1;
    end: cyl 1023/ head 255/ sector 63
The data for partition 2 is:
sysid 165 (0xa5),(FreeBSD/NetBSD/386BSD)
    start 79691850, size 897081255 (438027 Meg), flag 80 (active)
    beg: cyl 1023/ head 255/ sector 63;
    end: cyl 1023/ head 255/ sector 63
The data for partition 3 is:
<UNUSED>
The data for partition 4 is:
<UNUSED>
which is exactly what I had before the accident.

However, no /dev/ada1s1 and /dev/ada1s2 appeared. What is wrong?
 
You may need to tell the system to reread the partition tables; true > /dev/ada1
 
You may need to tell the system to reread the partition tables; true > /dev/ada1
I tried; nothing changed. Just /dev/ada1. On contrary, fdisk /dev/ada1 still shows two slices with the same parameters as before the accident. But I can't access them.
 
Update: I had to
Code:
dd if=/dev/zero of=/dev/ada1 bs=512 count=2
and repeat manual entering the old fdisk data. After that my ada1s2 bsdlabels magically reappeared, as SirDice predicted. Thanks, Sir!
 
Back
Top