parted destroy mbr with boot loader if you just add partition on gpt

Bug #351414 reported by Oleksij Rempel
2
Affects Status Importance Assigned to Milestone
parted (Ubuntu)
Fix Released
High
Unassigned

Bug Description

There is no problem to install ubuntu together which mac on the same disk labeled with gpt. The problem come if you wont to add some partition after install, so parted will just reset mbr even there is nothing to change. It schould only write new gpt table, not mbr.

You can reproduce it on virtual system with ubuntu only:
1. kvm-img create -f raw test.raw 10G
2. parted test.raw ( mklabel gpt, mkpart 0 5GB ... and leave some place for testing)
3. kvm test.raw -m 1G -boot d -cdrom jaunty-alternate.iso (install with manual partitioning and use partitions you made before )
4. boot it ( it's working )
5. parted test.raw ( mkpart 5GB 6GB ... just add some new partition )
6. boot it ( not working )

workaround is to reinstall grub just after parted.
-------------------------------------------------------
lsb_release -rd
Description: Ubuntu jaunty (development branch)
Release: 9.04

apt-cache policy parted
parted:
  Installiert: 1.8.8.git.2008.03.24-11.1ubuntu6
  Kandidat: 1.8.8.git.2008.03.24-11.1ubuntu6
  Versions-Tabelle:
 *** 1.8.8.git.2008.03.24-11.1ubuntu6 0
        500 http://de.archive.ubuntu.com jaunty/main Packages
        100 /var/lib/dpkg/status

Related branches

Revision history for this message
Oleksij Rempel (olerem) wrote :
Download full text (4.3 KiB)

Here is first sector before parted:

0000000: eb48 9000 0000 0000 0000 0000 0000 0000 .H..............
0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000030: 0000 0000 0000 0000 0000 0000 0000 0302 ................
0000040: ff00 0080 241c 0000 0008 fa90 90f6 c280 ....$...........
0000050: 7502 b280 ea59 7c00 0031 c08e d88e d0bc u....Y|..1......
0000060: 0020 fba0 407c 3cff 7402 88c2 52be 7f7d . ..@|<.t...R..}
0000070: e834 01f6 c280 7454 b441 bbaa 55cd 135a .4....tT.A..U..Z
0000080: 5272 4981 fb55 aa75 43a0 417c 84c0 7505 RrI..U.uC.A|..u.
0000090: 83e1 0174 3766 8b4c 10be 057c c644 ff01 ...t7f.L...|.D..
00000a0: 668b 1e44 7cc7 0410 00c7 4402 0100 6689 f..D|.....D...f.
00000b0: 5c08 c744 0600 7066 31c0 8944 0466 8944 \..D..pf1..D.f.D
00000c0: 0cb4 42cd 1372 05bb 0070 eb7d b408 cd13 ..B..r...p.}....
00000d0: 730a f6c2 800f 84ea 00e9 8d00 be05 7cc6 s.............|.
00000e0: 44ff 0066 31c0 88f0 4066 8944 0431 d288 D..f1...@f.D.1..
00000f0: cac1 e202 88e8 88f4 4089 4408 31c0 88d0 ........@.D.1...
0000100: c0e8 0266 8904 66a1 447c 6631 d266 f734 ...f..f.D|f1.f.4
0000110: 8854 0a66 31d2 66f7 7404 8854 0b89 440c .T.f1.f.t..T..D.
0000120: 3b44 087d 3c8a 540d c0e2 068a 4c0a fec1 ;D.}<.T.....L...
0000130: 08d1 8a6c 0c5a 8a74 0bbb 0070 8ec3 31db ...l.Z.t...p..1.
0000140: b801 02cd 1372 2a8c c38e 0648 7c60 1eb9 .....r*....H|`..
0000150: 0001 8edb 31f6 31ff fcf3 a51f 61ff 2642 ....1.1.....a.&B
0000160: 7cbe 857d e840 00eb 0ebe 8a7d e838 00eb |..}.@.....}.8..
0000170: 06be 947d e830 00be 997d e82a 00eb fe47 ...}.0...}.*...G
0000180: 5255 4220 0047 656f 6d00 4861 7264 2044 RUB .Geom.Hard D
0000190: 6973 6b00 5265 6164 0020 4572 726f 7200 isk.Read. Error.
00001a0: bb01 00b4 0ecd 10ac 3c00 75f4 c300 0000 ........<.u.....
00001b0: 0000 0000 0000 0000 0000 0000 0000 8000 ................
00001c0: 0100 eefe ffff 0100 0000 ffff 3f01 0000 ............?...
00001d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001e0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00001f0: 0000 0000 0000 0000 0000 0000 0000 55aa ..............U.

and after parted just added new partition:
0000000: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000010: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000020: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000030: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000040: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000050: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000060: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000070: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000080: 0000 0000 0000 0000 0000 0000 0000 0000 ................
0000090: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000a0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000b0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000c0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000d0: 0000 0000 0000 0000 0000 0000 0000 0000 ................
00000e0: 0000 0000 0000 0000 0000 00...

Read more...

Revision history for this message
Oleksij Rempel (olerem) wrote :

as you can see. mbr partition table is the same .. (partition tipe "ee" for gpt) but boot code was removed. This should happen only if change label, like from msdos to gpt but not if there is gpt and i just add new partition.

Revision history for this message
Oleksij Rempel (olerem) wrote :

This patch should fix it.

Revision history for this message
Colin Watson (cjwatson) wrote :

This patch looks wrong - it will cause the MBR partition table to drift out of sync with GPT. Instead, I think _write_pmbr should be changed to preserve the first 446 bytes of the MBR.

Changed in parted (Ubuntu):
importance: Undecided → High
status: New → Triaged
Revision history for this message
Colin Watson (cjwatson) wrote :

This was fixed upstream, and as such will be fixed in Lucid:

commit 14a1589194dc0adcebb6cca2ab2c2a87e1d26b38
Author: Joel Granados Moreno <email address hidden>
Date: Wed Jun 3 20:36:55 2009 +0200

    gpt: preserve first 446 bytes of the PMBR (protective MBR)

    * libparted/label/gpt.c (_write_pmbr): Make sure we read and preserve
    the first 446 bytes of the device when we are creating the PMBR.

Revision history for this message
Launchpad Janitor (janitor) wrote :

This bug was fixed in the package parted - 1.8.8.git.2009.07.19-5ubuntu1

---------------
parted (1.8.8.git.2009.07.19-5ubuntu1) lucid; urgency=low

  * Resynchronise with Debian. Remaining changes:
    - gptsync.dpatch: On Intel Mac systems, write a synced MBR rather than a
      protective MBR.
    - Add -fno-stack-protector on sparc.
    - sparc-new-label.dpatch: Fix sparc disk label generation. This is
      required for LDOM and parallel installations with Solaris 10.
    - loop-partitions.dpatch: Loop devices can only have one partition, so
      don't generate device names such as "/dev/loop0p1".
    - When building with gcc-4.3, add -Wno-array-bounds to CFLAGS.
    - Cell partition tables are misdetected as pc98, so disable pc98 support
      on powerpc.
    - disable_o_direct.dpatch: Replace the use of O_DIRECT with calls to
      fsync() at appropriate times.
    - unpartitioned-disks.dpatch (update): Just return immediately from
      ped_disk_commit if running on an unpartitioned disk, to avoid failures
      in case we end up in _kernel_reread_part_table.
    - udevadm-settle.dpatch: Run 'udevadm settle' either side of rereading
      the partition table, to avoid a variety of races.
    - dmraid.dpatch: Restored. Ensures that device-mapper devices for dmraid
      arrays do not have extra nodes created needlessly, as well as making
      sure that partition nodes for dmraid devices are not probed.
  * Upstream fixed destruction of first 446 bytes of protective MBR on GPT
    write (LP: #351414).

parted (1.8.8.git.2009.07.19-5) unstable; urgency=low

  * Update building system with automake 1.11

parted (1.8.8.git.2009.07.19-4) unstable; urgency=low

  [ Otavio Salvador ]
  * Fix FTBFS in s390 due a missing prototype in dasd label.

  [ Aurelien Jarno ]
  * Add FreeBSD architecture support files
  * Regenerate configure and Makefile.in

parted (1.8.8.git.2009.07.19-3) unstable; urgency=low

  [ Otavio Salvador ]
  * control.in: use debug for libparted-dbg.

  [ Colin Watson ]
  * control.in: Move libparted@LIBPKGVER@-i18n to section localization.

  [ Luca Favatella ]
  * control.in: Remove libdevmapper-dev as build-dependency on GNU/kFreeBSD.
  * debian/rules: Enable device-mapper only on Linux.

  [ Otavio Salvador ]
  * Do not dynamicaly update soname.

parted (1.8.8.git.2009.07.19-2) unstable; urgency=low

  * unblacklist-md.dpatch: Revert commit
    f94e08bdb4ba0fa1b9fd35509e04c2d9ee84ff80, which broke RAID configuration
    in d-i and isn't necessary given our unpartitioned-disks patch.
  * Add myself to Uploaders, at Otavio's suggestion.

parted (1.8.8.git.2009.07.19-1) unstable; urgency=low

  * New upstream snapshot.

  [ Max Vozeler ]
  * Restore dependency on the patch-stamp target. (closes: #534248)

  [ Otavio Salvador ]
  * Drop baseline-symbols patch.
  * Update symbols - no soname bump required.

parted (1.8.8.git.2009.06.03-2) unstable; urgency=low

  * libparted: move LinuxSpecific stuff to a private linux.h header
 -- Colin Watson <email address hidden> Mon, 09 Nov 2009 21:40:36 +0000

Changed in parted (Ubuntu):
status: Triaged → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.