GNU bug report logs - #25602
[parted] Problem with msdos mbr creation

Previous Next

Package: parted;

Reported by: Lukasz Majewski <lukma <at> denx.de>

Date: Wed, 1 Feb 2017 16:43:02 UTC

Severity: normal

To reply to this bug, email your comments to 25602 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-parted <at> gnu.org:
bug#25602; Package parted. (Wed, 01 Feb 2017 16:43:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Lukasz Majewski <lukma <at> denx.de>:
New bug report received and forwarded. Copy sent to bug-parted <at> gnu.org. (Wed, 01 Feb 2017 16:43:03 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Lukasz Majewski <lukma <at> denx.de>
To: bug-parted <at> gnu.org
Subject: [parted] Problem with msdos mbr creation
Date: Wed, 1 Feb 2017 11:28:03 +0100
Dear All,

My parted version is 3.2. OS: Linux GNU Debian 8.6

For one of my embedded systems (arm based one) I do use parted to create
bootable SD card.

parted -s $DRIVE mklabel msdos

First, I do clean up the first 1MiB of SD card:

dd if=/dev/zero of=$DRIVE bs=1024 count=1024

The problem is that parted is generating following code from the very
beginning of the MBR:

00000000  FA B8 00 10  8E D0 BC 00   B0 B8 00 00  8E D8 8E C0
00000010  FB BE 00 7C  BF 00 06 B9   00 02 F3 A4  EA 21 06 00
00000020  00 BE BE 07  38 04 75 0B   83 C6 10 81  FE FE 07 75
00000030  F3 EB 16 B4  02 B0 01 BB   00 7C B2 80  8A 74 01 8B


What is the purpose of this code? Why is has been put there?

Such data in this place fools the ROM bootloader and hangs the board.

Also, fdisk (from util-linux 2.25.2) when is creating "dos" partition
table is not writing such data.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd <at> denx.de




Information forwarded to bug-parted <at> gnu.org:
bug#25602; Package parted. (Wed, 01 Feb 2017 23:35:01 GMT) Full text and rfc822 format available.

Message #8 received at 25602 <at> debbugs.gnu.org (full text, mbox):

From: "Brian C. Lane" <bcl <at> redhat.com>
To: Lukasz Majewski <lukma <at> denx.de>
Cc: 25602 <at> debbugs.gnu.org
Subject: Re: bug#25602: [parted] Problem with msdos mbr creation
Date: Wed, 1 Feb 2017 15:33:52 -0800
On Wed, Feb 01, 2017 at 11:28:03AM +0100, Lukasz Majewski wrote:
> Dear All,
> 
> My parted version is 3.2. OS: Linux GNU Debian 8.6
> 
> For one of my embedded systems (arm based one) I do use parted to create
> bootable SD card.
> 
> parted -s $DRIVE mklabel msdos
> 
> First, I do clean up the first 1MiB of SD card:
> 
> dd if=/dev/zero of=$DRIVE bs=1024 count=1024
> 
> The problem is that parted is generating following code from the very
> beginning of the MBR:
> 
> 00000000  FA B8 00 10  8E D0 BC 00   B0 B8 00 00  8E D8 8E C0
> 00000010  FB BE 00 7C  BF 00 06 B9   00 02 F3 A4  EA 21 06 00
> 00000020  00 BE BE 07  38 04 75 0B   83 C6 10 81  FE FE 07 75
> 00000030  F3 EB 16 B4  02 B0 01 BB   00 7C B2 80  8A 74 01 8B
> 
> 
> What is the purpose of this code? Why is has been put there?
> 
> Such data in this place fools the ROM bootloader and hangs the board.
> 
> Also, fdisk (from util-linux 2.25.2) when is creating "dos" partition
> table is not writing such data.

That's the MBR boot code normally used to boot a BIOS system. If it
causes problems on a non-x86 system you should zero it out (or write the
system bootloader after partitioning).

-- 
Brian C. Lane (PST8PDT)




Information forwarded to bug-parted <at> gnu.org:
bug#25602; Package parted. (Thu, 02 Feb 2017 16:35:02 GMT) Full text and rfc822 format available.

Message #11 received at 25602 <at> debbugs.gnu.org (full text, mbox):

From: Lukasz Majewski <lukma <at> denx.de>
To: "Brian C. Lane" <bcl <at> redhat.com>
Cc: 25602 <at> debbugs.gnu.org
Subject: Re: bug#25602: [parted] Problem with msdos mbr creation
Date: Thu, 2 Feb 2017 10:05:35 +0100
Hi Brian,

> On Wed, Feb 01, 2017 at 11:28:03AM +0100, Lukasz Majewski wrote:
> > Dear All,
> > 
> > My parted version is 3.2. OS: Linux GNU Debian 8.6
> > 
> > For one of my embedded systems (arm based one) I do use parted to
> > create bootable SD card.
> > 
> > parted -s $DRIVE mklabel msdos
> > 
> > First, I do clean up the first 1MiB of SD card:
> > 
> > dd if=/dev/zero of=$DRIVE bs=1024 count=1024
> > 
> > The problem is that parted is generating following code from the
> > very beginning of the MBR:
> > 
> > 00000000  FA B8 00 10  8E D0 BC 00   B0 B8 00 00  8E D8 8E C0
> > 00000010  FB BE 00 7C  BF 00 06 B9   00 02 F3 A4  EA 21 06 00
> > 00000020  00 BE BE 07  38 04 75 0B   83 C6 10 81  FE FE 07 75
> > 00000030  F3 EB 16 B4  02 B0 01 BB   00 7C B2 80  8A 74 01 8B
> > 
> > 
> > What is the purpose of this code? Why is has been put there?
> > 
> > Such data in this place fools the ROM bootloader and hangs the
> > board.
> > 
> > Also, fdisk (from util-linux 2.25.2) when is creating "dos"
> > partition table is not writing such data.
> 
> That's the MBR boot code normally used to boot a BIOS system. 

Hmm.... Nice to know :-)

> If it
> causes problems on a non-x86 system you should zero it out

The problem is that we are using it with TI's SDK script to create
bootable SD card.

In this script we clean (write 0x00) the MBR before we run parted -s
msdos.

The problem is that parted itself (and silently) puts the code there
and hence the embedded system thinks that there is a valid bootloader
code and happily hangs.

Is there any option to parted to avoid adding this code (and behave
like fdisk)?

> (or write
> the system bootloader after partitioning).
> 

The only fix I do see is to manually write 0x00 to the beginning of the
MBR created by parted.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd <at> denx.de




Information forwarded to bug-parted <at> gnu.org:
bug#25602; Package parted. (Thu, 02 Feb 2017 16:52:02 GMT) Full text and rfc822 format available.

Message #14 received at 25602 <at> debbugs.gnu.org (full text, mbox):

From: "Brian C. Lane" <bcl <at> redhat.com>
To: Lukasz Majewski <lukma <at> denx.de>
Cc: 25602 <at> debbugs.gnu.org
Subject: Re: bug#25602: [parted] Problem with msdos mbr creation
Date: Thu, 2 Feb 2017 08:50:54 -0800
On Thu, Feb 02, 2017 at 10:05:35AM +0100, Lukasz Majewski wrote:
> Hi Brian,
> 
> > On Wed, Feb 01, 2017 at 11:28:03AM +0100, Lukasz Majewski wrote:
> > > Dear All,
> > If it
> > causes problems on a non-x86 system you should zero it out
> 
> The problem is that we are using it with TI's SDK script to create
> bootable SD card.
> 
> In this script we clean (write 0x00) the MBR before we run parted -s
> msdos.
> 
> The problem is that parted itself (and silently) puts the code there
> and hence the embedded system thinks that there is a valid bootloader
> code and happily hangs.
> 
> Is there any option to parted to avoid adding this code (and behave
> like fdisk)?

No, the only time it won't write it is if there is something already
there (eg. not 0x00). So if you could get the SDK to write it's
bootloader first, then partition it, parted will leave it untouched.

-- 
Brian C. Lane (PST8PDT)




Information forwarded to bug-parted <at> gnu.org:
bug#25602; Package parted. (Thu, 02 Feb 2017 20:24:01 GMT) Full text and rfc822 format available.

Message #17 received at 25602 <at> debbugs.gnu.org (full text, mbox):

From: Lukasz Majewski <lukma <at> denx.de>
To: "Brian C. Lane" <bcl <at> redhat.com>
Cc: 25602 <at> debbugs.gnu.org
Subject: Re: bug#25602: [parted] Problem with msdos mbr creation
Date: Thu, 2 Feb 2017 21:23:03 +0100
On Thu, 2 Feb 2017 08:50:54 -0800
"Brian C. Lane" <bcl <at> redhat.com> wrote:

> On Thu, Feb 02, 2017 at 10:05:35AM +0100, Lukasz Majewski wrote:
> > Hi Brian,
> > 
> > > On Wed, Feb 01, 2017 at 11:28:03AM +0100, Lukasz Majewski wrote:
> > > > Dear All,
> > > If it
> > > causes problems on a non-x86 system you should zero it out
> > 
> > The problem is that we are using it with TI's SDK script to create
> > bootable SD card.
> > 
> > In this script we clean (write 0x00) the MBR before we run parted -s
> > msdos.
> > 
> > The problem is that parted itself (and silently) puts the code there
> > and hence the embedded system thinks that there is a valid
> > bootloader code and happily hangs.
> > 
> > Is there any option to parted to avoid adding this code (and behave
> > like fdisk)?
> 
> No, the only time it won't write it is if there is something already
> there (eg. not 0x00). So if you could get the SDK to write it's
> bootloader first, then partition it, parted will leave it untouched.

For my SoC the 0x00 address is one of potential places where bootloader
binary is placed. The SoC considers this code valid if it finds data
different than 0x00 or 0xFF.
We normally store bootloader on FAT partition, not at fixed address in
the SDcard. When it is not found on FAT partition, then LBA 0x0 is
considered as next candidate. If we do have data different than
0x00000000 or 0xFFFFFFFF, then we will hang, not going to other boot
options.


Best regards,

Lukasz Majewski

--

DENX Software Engineering GmbH,      Managing Director: Wolfgang Denk
HRB 165235 Munich, Office: Kirchenstr.5, D-82194 Groebenzell, Germany
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd <at> denx.de




Information forwarded to bug-parted <at> gnu.org:
bug#25602; Package parted. (Tue, 18 Apr 2017 15:49:02 GMT) Full text and rfc822 format available.

Message #20 received at 25602 <at> debbugs.gnu.org (full text, mbox):

From: Phil Susi <psusi <at> ubuntu.com>
To: "Brian C. Lane" <bcl <at> redhat.com>, Lukasz Majewski <lukma <at> denx.de>
Cc: 25602 <at> debbugs.gnu.org
Subject: Re: bug#25602: [parted] Problem with msdos mbr creation
Date: Tue, 18 Apr 2017 11:50:27 -0400
On 2/1/2017 6:33 PM, Brian C. Lane wrote:
> That's the MBR boot code normally used to boot a BIOS system. If it
> causes problems on a non-x86 system you should zero it out (or write the
> system bootloader after partitioning).

Brian, do you know why parted adds the boot code but fdisk does not?
Maybe we should consider removing it?  It's only use is to chain load
the "active partition" boot loader.  I can only think of three times
this is going to be used:

1) Booting DOS/Windows: they have commands to add the boot code after
the fact, and normally they would partition the disk first.

2) Booting with LILO installed to a partition: LILO had a switch to
write the MBR boot code if you ever wanted to do this and anyone still
uses LILO.

3) Booting with GRUB installed to a partition: GRUB strongly recommends
installing to the MBR instead, and if you really must put it in a
partition, and don't already have MBR boot code, you can use LILO to add it.





Information forwarded to bug-parted <at> gnu.org:
bug#25602; Package parted. (Tue, 18 Apr 2017 17:55:02 GMT) Full text and rfc822 format available.

Message #23 received at 25602 <at> debbugs.gnu.org (full text, mbox):

From: "Brian C. Lane" <bcl <at> redhat.com>
To: Phil Susi <psusi <at> ubuntu.com>
Cc: 25602 <at> debbugs.gnu.org, Lukasz Majewski <lukma <at> denx.de>
Subject: Re: bug#25602: [parted] Problem with msdos mbr creation
Date: Tue, 18 Apr 2017 10:54:00 -0700
On Tue, Apr 18, 2017 at 11:50:27AM -0400, Phil Susi wrote:
> On 2/1/2017 6:33 PM, Brian C. Lane wrote:
> > That's the MBR boot code normally used to boot a BIOS system. If it
> > causes problems on a non-x86 system you should zero it out (or write the
> > system bootloader after partitioning).
> 
> Brian, do you know why parted adds the boot code but fdisk does not?
> Maybe we should consider removing it?  It's only use is to chain load
> the "active partition" boot loader.  I can only think of three times
> this is going to be used:
> 
> 1) Booting DOS/Windows: they have commands to add the boot code after
> the fact, and normally they would partition the disk first.
> 
> 2) Booting with LILO installed to a partition: LILO had a switch to
> write the MBR boot code if you ever wanted to do this and anyone still
> uses LILO.
> 
> 3) Booting with GRUB installed to a partition: GRUB strongly recommends
> installing to the MBR instead, and if you really must put it in a
> partition, and don't already have MBR boot code, you can use LILO to add it.
> 

Yeah, I can't think of any good reason to keep it. We should probably
just zero it out to prevent old code from causing problems.

-- 
Brian C. Lane (PST8PDT)




This bug report was last modified 8 years and 61 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.