From owner-freebsd-hackers@FreeBSD.ORG Sat Sep 15 00:29:23 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 9F28E106566C for ; Sat, 15 Sep 2012 00:29:23 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-oa0-f54.google.com (mail-oa0-f54.google.com [209.85.219.54]) by mx1.freebsd.org (Postfix) with ESMTP id 5E0668FC08 for ; Sat, 15 Sep 2012 00:29:23 +0000 (UTC) Received: by oagm1 with SMTP id m1so4167268oag.13 for ; Fri, 14 Sep 2012 17:29:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=VjmATMD+Kc1xNXft45UlQALCMEJtLRvY8P5f78D/iG0=; b=JouSuLyigeXZlY0lumOgzLnxJXkC5sd87FIYhGoCekldsmrjOaLpoNwDKfameN60t0 XCnFvABYk6Dcgr4mcsv5Mum9RX8E4KqxvZPxbcRMvXto81az3chGJIkIyDixZFRjyEM+ y2UoIlCH4+BM0UCb1dp+RxgDqCWDZWUgEX+gomfokqOZxbaOiIXOAj7X8ZlC0wdu1tGd rXb8z/idXm6MUfVcUJ6eyLySQq0cPNTJeGC52AocZB5uEAv4SAWZFzknYH/c4KPJBmIa 9z5reTsUnQkQndsmy5zJUBFA3BQCOLHt8UtMR+UajFT8jAjCTDFcIG2jlV0+nVwnm2Sh 6Qvw== MIME-Version: 1.0 Received: by 10.60.29.164 with SMTP id l4mr6193477oeh.4.1347668962512; Fri, 14 Sep 2012 17:29:22 -0700 (PDT) Received: by 10.76.142.201 with HTTP; Fri, 14 Sep 2012 17:29:22 -0700 (PDT) In-Reply-To: <5053C9A1.3030605@rawbw.com> References: <5053C9A1.3030605@rawbw.com> Date: Fri, 14 Sep 2012 17:29:22 -0700 Message-ID: From: Garrett Cooper To: Yuri Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-hackers@freebsd.org Subject: Re: 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:29:23 -0000 On Fri, Sep 14, 2012 at 5:19 PM, 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. 1. What version of FreeBSD? 2. What do you have set for kern.geom.debug_flags? 3. Is /dev/ad4 (or any partitions / slices under it) currently in use? Thanks! -Garrett