gpart bootcode Operation not permitted

Artem Kuchin artem at artem.ru
Mon Apr 6 11:56:20 UTC 2020


03.04.2020 22:44, Miroslav Lachman пишет:
> Artem Kuchin wrote on 2020/04/03 21:23:
>> 03.04.2020 17:42, Miroslav Lachman пишет:
>>>
>>> I think you can use "gmirror stop" on boot partition, then "gmirror 
>>> clear" and then update both individual boot partitions by gpart.
>>>
>>>
>>
>> I am afraid to do it. Gmirror stops mirroring, okay. What what 
>> gmirror clear does? What metadata is cleared and what it is used for?
>>
>> How to restart mirroring after that and how to make sure that mirror 
>> is 100% complete?
>>
>> Is it possible to exclude only boot partition from mirroring?
>
> Of course that's what I am suggesting - just split up mirroring of 
> boot partition and keep mirroring on swap and root!
>
> Gmirror clear deletes the very last sector on the given partition 
> where metadata of gmirror are stored. It does not touch the data on 
> the partitions. You don't need to worry.
>
> You have 3 mirrors. They are visible in /dev/mirror or by command 
> "gmirror status":
> boot
> swap
> root
>
> As the "man gmirror" shows:
>      gmirror stop [-fv] name ...
>
> You can run: gmirror stop -v boot
>
> It stops only the "boot" mirror. swap and root are still mirrored.
>
> Then you can clear metadata on each provider:
>
> gmirror clear ada0p1
> gmirror clear ada1p1
>
> Or you can use "gmirror destroy -v boot" istead of 3 command above. It 
> should stop the "boot" mirror and then clear metadata on both providers.
>
> The you will have / your system will use 2 independent boot 
> partitions: ada0p1 and ada1p1.
> The machine should be able to boot from any of those 2 disks because 
> each of them has valid boot partitions / boot code.
>
> Gpart bootcode should work for them on each system upgrade.
>
> gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
> gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1
>
> Kind regards
> Miroslav Lachman

Hmm. tried what you wrote but it went a little different, failed to 
clear  and needed to use destroy anyway


# gmirror stop -v boot
Done.

# gmirror status
        Name    Status  Components
mirror/swap  COMPLETE  ada0p2 (ACTIVE)
                        ada1p2 (ACTIVE)
mirror/root  COMPLETE  ada0p3 (ACTIVE)
                        ada1p3 (ACTIVE)
mirror/boot  COMPLETE  gpt/boot1 (ACTIVE)
                        gpt/boot0 (ACTIVE)

# gmirror clear ada0p1
Can't clear metadata on ada0p1: Operation not permitted.
gmirror: Not fully done.

# gmirror clear ada1p1
Can't clear metadata on ada1p1: Operation not permitted.
gmirror: Not fully done.

# gmirror destroy -v boot
Done.

# gmirror status
        Name    Status  Components
mirror/swap  COMPLETE  ada0p2 (ACTIVE)
                        ada1p2 (ACTIVE)
mirror/root  COMPLETE  ada0p3 (ACTIVE)
                        ada1p3 (ACTIVE)


# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada0
partcode written to ada0p1
bootcode written to ada0

# gpart bootcode -b /boot/pmbr -p /boot/gptboot -i 1 ada1
partcode written to ada1p1
bootcode written to ada1

Now it can boot from any disk. Thank you.


Artem





More information about the freebsd-fs mailing list