Bug 25889

Summary: FDISK lost a partition !
Product: Base System Reporter: Thao et Hubert Tournier <hubert.tournier>
Component: i386Assignee: freebsd-bugs (Nobody) <bugs>
Status: Closed FIXED    
Severity: Affects Only Me    
Priority: Normal    
Version: 4.2-RELEASE   
Hardware: Any   
OS: Any   

Description Thao et Hubert Tournier 2001-03-18 10:30:03 UTC
SUMMARY: I lost a partition beginning after the 8.4MB limit after an
ugrade from FreeBSD 4.0-RELEASE to 4.2-RELEASE made with a complete
reinstall of the operating system.

Here was my partition information BEFORE the problem :

MBR/PT track
100 MB DOS partition
4000 MB Win partition
3992 MB FreeBSD 4.0 partition
11476 MB Win data partition (extended I think).

When I first entered FDISK, here's what I saw (from memory) :

Disk Geometry 2495 cyls/255 heads/63 sectors = 40082175 sectors (19571
MB)
Offset		Size (ST)	End		Name	PType	Desc	Subtype	Flags
0		63		62		-	6	unused	0
63		208782		208844		ad0s1	2	fat	6
208845		8193150		8401994		ad0s2	2	fat	11
8401995		8177085		16579079	ad0s3	3	freebsd	165
16579080	23509080	40088159	-	6	unused	0

The last entry was incorrect : it should have been my 11 Go windows data
partition.

Although I was surprised, I thought the FDISK utility may have been
troubled with that partition starting after the 8.4 GB limit.

I decided to install anyway using the same parameters than the existing
FreeBSD 4.0-RELEASE partition.

The install went fine as usual, but both FreeBSD and Windows could not
see the windows data partition afterwards.

Using a disk editor, I saw that the fourth partition entry in the
partition table had been zeroed.

I think this is the only impact, but at this time, I haven't been able
to restore values enabling Windows or FreeBSD to see the lost partition.

Fix: 

PROPOSED MODIFICATION: In my opinion, the safest method would be to only
write back the modified partition entries in the table.

For my part, I used the FDISK utility to recreate something like that :

Disk Geometry 2495 cyls/255 heads/63 sectors = 40082175 sectors (19571
MB)
Offset		Size (ST)	End		Name	PType	Desc		Subtype	Flags
0		63		62		-	6	unused		0
63		208782		208844		ad0s1	2	fat		6
208845		8193150		8401994		ad0s2	2	fat		11
8401995		8177085		16579079	ad0s3	3	freebsd		165
16579080	23503095	40082174	ad0s4	1	extended DOS	5
40082175	5985		40088159	-	6	unused		0

But at this time, it doesn't solve my problem (the last partition is
still unrecognised).

I plan to fiddle with the partition type, then, in last recourse, to
write a specific recovery program under FreeBSD (I already did this for
an HPFS partition in the past).

Here is my partition information AT THIS TIME :

******* Working on device /dev/ad0 *******
parameters extracted from in-core disklabel are:
cylinders=2495 heads=255 sectors/track=63 (16065 blks/cyl)

Figures below won't work with BIOS for partitions not in cyl 1
parameters to be used for BIOS calculations are:
cylinders=2495 heads=255 sectors/track=63 (16065 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 6,(Primary 'big' DOS (> 32MB))
    start 63, size 208782 (101 Meg), flag 0
	beg: cyl 0/ sector 1/ head 1;
	end: cyl 12/ sector 63/ head 254
The data for partition 2 is:
sysid 11,(DOS or Windows 95 with 32 bit FAT)
    start 208845, size 8193150 (4000 Meg), flag 0
	beg: cyl 13/ sector 1/ head 0;
	end: cyl 522/ sector 63/ head 254
The data for partition 3 is:
sysid 165,(FreeBSD/NetBSD/386BSD)
    start 8401995, size 8177085 (3992 Meg), flag 80 (active)
	beg: cyl 523/ sector 1/ head 0;
	end: cyl 1023/ sector 63/ head 254
The data for partition 4 is:
sysid 5,(Extended DOS)
    start 16579080, size 23503095 (11476 Meg), flag 0
	beg: cyl 1023/ sector 63/ head 255;
	end: cyl 1023/ sector 63/ head 254
How-To-Repeat: 
It's not possible for me to repeat the problem at this time, because I
want to try different things in order to recover the partition data.

Perhaps, on another machine, someone could try the following procedure :
- Use a disk larger than 8.4 GB,
- Create a partition layout similar to the one I was using,
- Create an extended partition beginning after the 8.4 GB limit,
- Overwrite an existing FreeBSD installation using the FreeBSD
4.2-RELEASE installer,
- See if the extended partition is still there.
Comment 1 Sheldon Hearn freebsd_committer freebsd_triage 2002-01-30 13:57:41 UTC
State Changed
From-To: open->feedback

Anyone able to reproduce this on recent FreeBSD installations?
Comment 2 Thao et Hubert Tournier 2002-01-31 23:29:04 UTC
Hello,

sheldonh@FreeBSD.org wrote:
> 
> Synopsis: FDISK lost a partition !
> 
> State-Changed-From-To: open->feedback
> State-Changed-By: sheldonh
> State-Changed-When: Wed Jan 30 05:57:41 PST 2002
> State-Changed-Why:
> Anyone able to reproduce this on recent FreeBSD installations?
> 
> http://www.FreeBSD.org/cgi/query-pr.cgi?pr=25889

It's nice to hear from you.

I never encountered this problem again (I will have a new chance this
week-end during a 4.4R to 4.5R upgrade. This time I will make a backup
before :-)).

Anyway, I recovered nearly all of my data on the lost partition,
although something else had been screwed (maybe in the partition boot
sector) apart from the partition entry.

I still think that having Fdisk modify only partition entries which have
changed would be the way to go.

Just my 2c.

Have a nice day !

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message
Comment 3 Jens Schweikhardt freebsd_committer freebsd_triage 2002-08-10 15:49:11 UTC
State Changed
From-To: feedback->closed

Originator says he never encountered this problem again.