Something Messed Up with my Slice & Partition Tables!

Hi,

so I screwed something up with my slice and partition tables and now I have a hard time fixing it. Fdisk, sysinstall/Fdisk and GParted and the device nodes give me different output regarding my partitions and I am not sure how to fix it. Could someone help me please?

Here are some details about what my machine tells me:

1 Sysinstall tells me that there is no slice defined on my disk
2 The existing nodes for my hard drive are ad0 and ad0a only
3 fdisk tells me that slice 3 is defined
4 GParted gives me the same info as fdisk

The ouput from fdisk and GParted is right, but the one from sysinstall and the device nodes is screwed up. I tried modifying the slices with fdisk and then to set it back to what it should be, but it does not fix the problem, even after a reboot. I screwed things up when I ran the command

bsdlabel -w ad0

instead of

bsdlabel -w ad0s1

I have found how to recover the partitions using scan_ffs, but I really need to fix the slice table first. What should I do exactly? I am just using MBR + UFS on a FreeBSD 8.2 i386 machine.

Thanks a lot!
 
wblock@ said:
Was it one big slice for the whole drive?

sysnistall tells me that there is only a single slice for the whole drive. However only the third slice was defined before I screwed things up. Fdisk and GParted still give me the right slice information.

Thanks!
 
Don't use sysinstall. It may be showing a proposed layout.

Please show the actual output of fdisk, and describe what is right and what is wrong about it.
 
wblock@ said:
Don't use sysinstall. It may be showing a proposed layout.

Please show the actual output of fdisk, and describe what is right and what is wrong about it.

There is nothing wrong with fdisk's output. Sysinstall's output is wrong, but I don't care too much about it. The problem though is that device nodes seem to match sysinstall's output rather than fdisk's output. I don't see ad0s3 in /dev. Only ad0 and ad0a exist. And rebooting does not change anything.

Thanks!
 
So I just tried reinitializing the first sector of the drive using

dd if=/dev/zero of=/dev/ad0 bs=512 count=1

then I recreated the slice using fdisk andreinstalled the boot loader using

boot0config -B ad0

When I try rebooting the machine, FreeBSD starts booting and it fails when it tries mounting the file system. I still says that only ad0 and ad0a exist and that ad0s3 (and ad0s3a) do not exist. So where is that info written, if not in the first sector of the drive? Whatever I do does not seem to affect the device nodes that are created when I either try to boot FreeBSD from the hard drive, or when I try booting it from a live FreeBSD CD.

Thanks
 
How can I delete a bsdlabel record?

Hi,

Could someone tell me how I can destroy a bsdlabel record? I thought it was located in the first sector of the device node used to create it, but it does not seem to be the case for some reason. I had created partitions using

bsdlabel -B /dev/ad0

and using the command

dd if=/dev/zero of=/dev/ad0 bs=512 count=1

does not allow to destroy the record.

Thanks!
 
If the disk has important data, use dd(1) to make a full copy to a file or another drive for experimenting.

The MBR is first on the disk, containing the partition (slice) information and the bootcode.
The FreeBSD partition information, or "label", is at the start of each slice.

If you can recreate the partition table so it's exactly like it was, the old bsdlabel will be found in the right spot and work.
 
wblock@ said:
If the disk has important data, use dd(1) to make a full copy to a file or another drive for experimenting.

The MBR is first on the disk, containing the partition (slice) information and the bootcode.
The FreeBSD partition information, or "label", is at the start of each slice.

If you can recreate the partition table so it's exactly like it was, the old bsdlabel will be found in the right spot and work.

Yes I know that the MBR is in the first sector, but the problem is that I did

bsdlabel -B /dev/ad0

instead of

bsdlabel -B /dev/ad0s1

so the bsdlabel has not been written to the first sector of a slice and it is now interfering with the MBR. Overwriting the first sector of the drive destroys the MBR but does not affect the bsdlabel record. Because of this bsdlabel record that has been created at the drive level rather than at the slice level, FreeBSD ignores slice information when creating the device nodes so ad0a gets created instead of ad0s3 . So I need to know where the bsdlabel record got written so I can destroy it and prevent it from causing this interference. I started a new thread to ask about this specifically...

Thanks!
 
So I have fixed my problem. I discovered that when a bsdlabel record is created at the drive level rather than at the slice level, it gets written to the second sector instead of the first sector. So erasing that second sector destroyed the record. Otherwise such a bsdlabel record prevents FreeBSD from generating device nodes for the different slices. It only creates labels at the drive level and ignores anything in the MBR...
 
wblock@ said:
Why?

The bsdlabel(8) page clears the first 32 blocks with dd(1) in an example:
% man bsdlabel | less -p wipe

Try that on a copy of the disk first.

Yep I discovered that bsdlabels at the drive level get created in the second sector. Somehow there must be a condition in the FreeBSD boot loader to ignore the MBR records when such a bsdlabel record exists...
 
Back
Top