Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 18 Mar 2009 09:23:01 -0700
From:      Marcel Moolenaar <xcllnt@mac.com>
To:        Andriy Gapon <avg@FreeBSD.org>
Cc:        freebsd-geom@freebsd.org
Subject:   Re: gpart bootcode and /boot/boot
Message-ID:  <0B27FB91-9F2B-4F96-B4A0-330CAD725AF1@mac.com>
In-Reply-To: <49C11880.8000506@freebsd.org>
References:  <4978C24D.9040706@icyb.net.ua> <49A6C33E.70402@freebsd.org> <EE8C5392-A907-4C75-BEB4-125C30AA6D41@mac.com> <49C11880.8000506@freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

On Mar 18, 2009, at 8:51 AM, Andriy Gapon wrote:

> on 26/02/2009 18:54 Marcel Moolenaar said the following:
>>
>> On Feb 26, 2009, at 8:28 AM, Andriy Gapon wrote:
>>
>>> on 22/01/2009 21:00 Andriy Gapon said the following:
>>>> Sorry for being lazy - what is "gpart bootcode" equivalent of  
>>>> bsdlabel
>>>> -B [-b boot] ?
>>>>
>>>
>>> Marcel, guys, I am still curious.
>>>
>>> disklabel -B refuses do to anything because of what it thinks is
>>> incorrect
>>> partition info.
>>>
>>> And the following command gets "Operation not permitted" when it  
>>> opens
>>> ad6s1 for
>>> writing:
>>> gpart bootcode -p /boot/boot -i 1 ad6
>>
>> Don't you mean "gpart bootcode -b /boot/boot ad6s1"
>>
>> If you say "-i 1 ad6", then what you want is bootcode
>> in a partition that is controlled by the scheme on ad6
>> (the scheme on ad6 is the MBR). You can't do that,
>> because that partition is sub-partitioned by the BSD
>> scheme.
>>
>> Since you want bootcode in the BSD scheme, you need
>> to add bootcode to ad6s1.
>
>
> Thank you very much for the explanation!
>
>>>
>>> This is amd64, stable/7, gpart-only kernel (gpart_mbr, gpart_bsd).
>>
>> Bootcode for the BSD scheme is not present in 7-STABLE yet.
>> I just recently added that to -CURRENT (I must have missed
>> it) and I need to get around MFCing it. Feel free to do the
>> MFC for me. The code has been in -CURRENT long enough to do
>> a MFC.
>
> Thank you for the offer and sorry that I haven't used the opportunity.
> And thank you for the MFC - I am using the code in stable/7 and  
> successfully
> updated boot2 blocks via the command you suggested.
> Just for the record - I did it to use jhb's fix for real<->protected  
> switch in
> boot code.
>
> BTW, is there a way to read/backup bootcode (for BSD scheme)?

There's no gpart function for it yet, but you can use dd
as a work-around. Unfortunately, that means you need to
know how much to read:
	MBR:	1 sector (512B) starting at 0
	BSD:	16 sectors (8KB) starting at 0

These raw dumps can be restored using gpart:
	gpart bootcode -b $mbr.dd ad6
	gpart bootcode -b $bsd.dd ad6s1

No, it will not destroy any partitioning data :-)

-- 
Marcel Moolenaar
xcllnt@mac.com






Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?0B27FB91-9F2B-4F96-B4A0-330CAD725AF1>