sfdisk: allow disabling boot flag on MBR partition table

Bug #1752876 reported by Andrius Štikonas
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
util-linux (Ubuntu)
Fix Committed
Medium
Unassigned

Bug Description

I would like to propose the following patch for Ubuntu 18.04 LTS

https://github.com/karelzak/util-linux/commit/8175ed3d74adacc895657ded7546cb3c5deeabad

[Impact]

 * This patch allows to use sfdisk to remove boot flag from all MBR partitions.
At the moment you can only "move" boot flag to other partitions.

 * Derivatives of Ubuntu that use Calamares might be impacted by this. At the moment
KDE Partition Manager and KPMcore (which is used by Calamares installer) are working on migrating to Polkit, so that they won't need to run GUI as root. One of the steps was moving from libparted backend to sfdisk backend for partitioning operations, so kpmcore will require 2.32 or 2.31.1 with this patch to have full functionality.

[Test Case]

Assuming that your want to deactivate boot flag on /dev/sdb which has MBR partition table:

sudo sfdisk --activate /dev/sdb -

Without this patch you should see an error message.

With the patch it will print:

The bootable flag on partition 1 is disabled now.

The partition table has been altered.
Calling ioctl() to re-read partition table.
Syncing disks.

[Regression Potential]
.
 * Should be extremely low. The change only adds a couple of lines in one file
which parses arguments of "sfdisk --activate". Nothing would change unless you
run sfdisk --activate

 * This patch does not change any libraries in util-linux, no need to worry about API/ABI stability.

 * GPT users are not affected at all.

[Other Info]
 * This patch is part of util-linux 2.32.

Simon Quigley (tsimonq2)
Changed in util-linux (Ubuntu):
assignee: nobody → Simon Quigley (tsimonq2)
importance: Undecided → Medium
status: New → Confirmed
Simon Quigley (tsimonq2)
Changed in util-linux (Ubuntu):
assignee: Simon Quigley (tsimonq2) → nobody
Revision history for this message
Phillip Susi (psusi) wrote :

Say, how does moving to sfdisk help? It still has to be run as root. You might consider using partman, which is the libparted wrapper program that allows debian-installer to make libparted calls from bash scripts. It takes commands and gives replies via a pair of named pipes.

Revision history for this message
Andrius Štikonas (stikonas) wrote :

sfdisk has to be run as root but it's fine because KPM KAuth helper can run commands as root. On the other hand, libparted was a library.

partman might have worked if somebody wrote a backend for it but sfdisk now has enough functionality anyway. Some things are hard to fix with libparted, e.g. libparted has no support for hybrid MBR. So we would just silently corrupt such setups with no way to fix it. We have more direct control over partition type with sfdisk, although, these partition flags don't matter that much anyway...

Revision history for this message
Andrius Štikonas (stikonas) wrote :

Anyway, we can probably close this bug. It's not too late for 18.04 and 18.10 has util-linux 2.32 anyway.

Also, we depend on util-linux for file system detection. So using sfdisk as opposed to partman saves us extra dependency (which is not well packaged by other distros).

Changed in util-linux (Ubuntu):
status: Confirmed → Fix Committed
Revision history for this message
Andrius Štikonas (stikonas) wrote :

s/It's not too late for/It's now too late for/

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.