Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Sep 2012 20:23:51 -0600 (MDT)
From:      Warren Block <wblock@wonkity.com>
To:        Yuri <yuri@rawbw.com>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: Why fdisk can't open root disk with MBR for writing?
Message-ID:  <alpine.BSF.2.00.1209142016200.36584@wonkity.com>
In-Reply-To: <5053C9A1.3030605@rawbw.com>
References:  <5053C9A1.3030605@rawbw.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, 14 Sep 2012, Yuri wrote:

> I am trying to change the active partition in MBR.
> This should be a matter of changing only two bits (clearing one in one byte 
> and setting another one in another byte).
>
> However, fdisk complains:
> fdisk: Failed to write MBR. Try to use gpart(8).
>
> truss reveals that fdisk failed to open the root disk for writing:
> open("/dev/ad4",O_RDWR,00)                       ERR#1 'Operation not 
> permitted'
> open("/dev/ad4",O_RDONLY,00)                     = 3 (0x3)
> ...
> ...
> pwrite(0x3,0x34048200,0x200,0x0,0x0,0x0)         ERR#9 'Bad file descriptor'
> Failed to write MBR. Try to use gpart(8)
>
> The question is: why the disk can't be open RW under root?
> The secondary issue is the bug in fdisk: once -a option is supplied and it 
> can't open it RW it should just say so, and not suggest using gpart because 
> gpart will probably have the same issue.

Did you actually try gpart?  GEOM prevents writes to providers that are 
in use, but gpart should handle it correctly if the problem is just that 
fdisk doesn't understand GEOM.

# gpart set -a active -i 1 ada0

If that fails, the provider is in use, usually mounted.  The safety can 
be disabled, but it's better to figure out what has it in use.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?alpine.BSF.2.00.1209142016200.36584>