Date: Sat, 15 Sep 2012 15:22:50 +0200 From: "Julian H. Stacey" <jhs@berklix.com> To: Garrett Cooper <yanegomi@gmail.com> Cc: Yuri <yuri@rawbw.com>, freebsd-hackers@freebsd.org Subject: Re: Why fdisk can't open root disk with MBR for writing? Message-ID: <201209151322.q8FDMobF058992@fire.js.berklix.net> In-Reply-To: Your message "Fri, 14 Sep 2012 17:29:22 PDT." <CAGH67wS0-kFoP=Ae_2-HGNKV2HsdabCo1w9T-VWQ5fQipj1T9w@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
Hi Yuri & hackers, Garrett Cooper wrote: > On Fri, Sep 14, 2012 at 5:19 PM, Yuri <yuri@rawbw.com> 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 I have been applying this diff to my man fdisk: http://berklix.com/~jhs/src/bsd/fixes/FreeBSD/src/gen/sbin/fdisk/ *** 8.0-RELEASE/src/sbin/fdisk/fdisk.8 Sat Mar 14 22:32:16 2009 --- new-generic/src/sbin/fdisk/fdisk.8 Sat Mar 14 22:35:10 2009 *************** *** 462,464 **** --- 462,468 ---- The .Xr bsdlabel 8 command must be used for this. + .Pp + When running multi user, you cannot write unless you first run this: + .br + sysctl kern.geom.debugflags=16 I never submitted it as a send-pr, anyone think I should submit it to help save people ? Cheers, Julian -- Julian Stacey, BSD Unix Linux C Sys Eng Consultant, Munich http://berklix.com Reply below not above, like a play script. Indent old text with "> ". Send plain text. Not: HTML, multipart/alternative, base64, quoted-printable.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201209151322.q8FDMobF058992>