Subject: bug#25602: [parted] Problem with msdos mbr creation

From: Lukasz Majewski <[email-masked]>
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: [email-masked]