Getting useful diagnostics from geom(8) and friends

Garrett Cooper yanefbsd at gmail.com
Thu May 27 22:57:33 UTC 2010


On Thu, May 27, 2010 at 3:46 PM, Rick C. Petty
<rick-freebsd2009 at kiwi-computer.com> wrote:
> On Thu, May 27, 2010 at 03:27:59PM -0700, Garrett Cooper wrote:
>> On Thu, May 27, 2010 at 3:08 PM, Rick C. Petty
>> <rick-freebsd2009 at kiwi-computer.com> wrote:
>> > On Thu, May 27, 2010 at 05:02:41PM -0500, Rick C. Petty wrote:
>> >
>> > In any case, show us the output of "gpart show /dev/ad4" if there are
>> > any problems.
>>
>>     Here's the entire operation; I realize there's a rounding error in
>> the size calculation with capacity...
>> Thanks,
>> -Garrett
>>
>> ./clear_and_rewrite_partitions ad4
>> + atacontrol cap ad4
>> + awk /^lba supported/ { print $3 }
>> + capacity=268435455
>> + dd if=/dev/zero of=/dev/ad4 bs=20m count=1
>> 1+0 records in
>> 1+0 records out
>> 20971520 bytes transferred in 0.610148 secs (34371204 bytes/sec)
>> + expr 0 + 268435455 / 1024 - 1
>> + dd if=/dev/zero of=/dev/ad4 bs=1m oseek=262142
>> dd: /dev/ad4: Input/output error
>> 1+0 records in
>> 0+0 records out
>> 0 bytes transferred in 0.021521 secs (0 bytes/sec)
>
> This last step is unnecessary, and there's something wrong with your math.
> 268435455 sectors is ~128 GiB, since each sector is 512 bytes.  So seeking
> to 256 GiB won't work.  Also you probably want lba48 not lba, or you'll
> always be limited to 268435455 which is rarely (never?) the actual disk
> size.

Quote:

# GPT optionally caches a protective MBR at the end; trash it.
dd if=/dev/zero of=/dev/$1 bs=1m oseek=`expr 0 + $capacity / 1024 - 1`

Yes, it's required for some cases because of the way that some systems
setup with gpt partitioning; PCBSD for instance does install a PMBR
that confuses the hell out of sysinstall where geom keeps on restoring
the old disk layout when it tastes the provider.

The capacity drive is 250GB, and I intentionally want to blow away the
last couple of sectors:

%atacontrol cap ad4

Protocol              Serial ATA II
device model          WDC WD2502ABYS-18B7A0
serial number         WD-WCAT1F033778
firmware revision     02.03B04
cylinders             16383
heads                 16
sectors/track         63
lba supported         268435455 sectors
lba48 supported       488281250 sectors
dma supported
overlap not supported

Feature                      Support  Enable    Value           Vendor
write cache                    yes	yes
read ahead                     yes	yes
Native Command Queuing (NCQ)   yes	 -	31/0x1F
Tagged Command Queuing (TCQ)   no	no	31/0x1F
SMART                          yes	yes
microcode download             yes	yes
security                       yes	no
power management               yes	yes
advanced power management      no	no	0/0x00
automatic acoustic management  yes	no	254/0xFE	128/0x80

I don't doubt that my math is wrong though... I'll use lba48 instead.

>> + ls /dev/ad4s*
>> ls: /dev/ad4s*: No such file or directory
>> + gpart create -s MBR ad4
>> gpart: 22 scheme 'MBR'
>> + gpart bootcode -b /boot/mbr -p /boot/boot0 -i 5 ad4
>> gpart: No such geom: ad4.
>
> I'm not sure you want to use both -b and -p options at the same time..
> does that even work?

No idea. At this point I've just started throwing random stuff at geom
trying to figure out why things aren't working because trying the same
thing over and over expecting a different results is a sign of
insanity :D.

> Regardless, try my aforementioned suggestion of specifying the complete
> device path when running "gpart bootcode".

Did that and the basename for the provider (ad4 in this case). Neither
worked :(.

> Also, what is partition #5 here?

>From boot0cfg(8):

     -s slice
             Set the default boot selection to slice.  Values between 1 and 4
             refer to slices; a value of 5 refers to the option of booting
             from a second disk.

Probably user error, but it was worth trying I guess..

>> + gpart add -b 34 -s 128 -t freebsd ad4
>> gpart: 22 geom 'ad4'
>> + gpart show ad4
>> gpart: No such geom: ad4.
>> + ls /dev/ad4s*
>> ls: /dev/ad4s*: No such file or directory
>
> Are you sure geom_part_mbr and geom_part_bsd are kldload'd?

It's 7.1, so the names are different...

%kldstat -v | grep g_
		58 g_md
		133 g_bsd
		134 g_dev
		135 g_disk
		136 g_mbrext
		137 g_mbr
		138 g_vfs
		139 g_part
		206 g_class

geom is hardwired into the kernel.

Thanks!
-Garrett


More information about the freebsd-geom mailing list