[parted-devel] [PATCH 0/2] Stop replacing boot code in MBR when updating msdos table

Mike Fleetwood mike.fleetwood at googlemail.com
Fri Oct 24 14:00:21 BST 2025


On Thu, 23 Oct 2025 at 00:45, Brian C. Lane <bcl at redhat.com> wrote:
>
> On Wed, Oct 22, 2025 at 09:43:36PM +0100, Mike Fleetwood wrote:
> > Hi,
> >
> > A user requested that GParted not replace MBR boot code when updating
> > the msdos partition table.  Since neither fdisk nor libparted GPT code
> > overwrite boot code when they update the MBR then libparted msdos code
> > shouldn't either.  Writing boot code is the responsibility of boot
> > loader installation, not a partitioning tool.
>
> In theory I'm fine with this, and I agree that the bootloader should
> handle this. Are we sure that nothing depends on this being written? And
> that when a proper bootloader is run it overwrites it without checking
> to see that it is used?
>
> This will only effect new disks, so I'm not too worried about data loss
> from the change.

I don't see how any reasonable setup can depend on the old behaviour of
libparted added boot code, if the area in the MBR was zero, to
successfully boot.  Every distribution installer I've used has a step at
the end to install the boot loader.  If the user chooses not to install
a boot loader, if that is even an option, then it's up to them to setup
the boot loader themselves.

I don't see how any boot loader installation can fail to install boot
code into the MBR if it's zero and have succeeded if it contained
libparted previous boot code.

I've successfully re-installed GRUB2 boot loader (grub-install /dev/sda)
and rebooted, both over zeroed and libparted boot code in the MBR.  The
SYSLINUX's documented method of installing MBR boot code is
(dd conv=notrunc bs=440 count=1 if=mbr.bin of=/dev/sdX) which is always
going to overwrite boot code in the MBR.

Following is patchset v2 which updates the one line summary for patch 1
and the NEWS entry to be clearer about exactly what has changed.

Thanks,
Mike



More information about the parted-devel mailing list