From owner-freebsd-hackers@FreeBSD.ORG Sat Sep 15 00:19:46 2012 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 7DB53106564A for ; Sat, 15 Sep 2012 00:19:46 +0000 (UTC) (envelope-from yuri@rawbw.com) Received: from shell0.rawbw.com (shell0.rawbw.com [198.144.192.45]) by mx1.freebsd.org (Postfix) with ESMTP id 692448FC1F for ; Sat, 15 Sep 2012 00:19:46 +0000 (UTC) Received: from eagle.yuri.org (stunnel@localhost [127.0.0.1]) (authenticated bits=0) by shell0.rawbw.com (8.14.4/8.14.4) with ESMTP id q8F0JjpV057293 for ; Fri, 14 Sep 2012 17:19:45 -0700 (PDT) (envelope-from yuri@rawbw.com) Message-ID: <5053C9A1.3030605@rawbw.com> Date: Fri, 14 Sep 2012 17:19:45 -0700 From: Yuri User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:15.0) Gecko/20120912 Thunderbird/15.0.1 MIME-Version: 1.0 To: freebsd-hackers@FreeBSD.org Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Cc: Subject: Why fdisk can't open root disk with MBR for writing? X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Sep 2012 00:19:46 -0000 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. Yuri