Skip to content

Commit

Permalink
sgdisk: Run partprobe after partition changes
Browse files Browse the repository at this point in the history
The sgdisk tool does not update the kernel partition table in contrast
to other similar tools. Often udev can detect the changes but not always
as experienced when adding a new partition on Flatcar's boot disk.
Instead of implicitly relying on some other component to re-read the
kernel partition table, trigger the re-read with partprobe.
  • Loading branch information
pothos committed Oct 2, 2023
1 parent de4da0e commit 78efdc2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 0 deletions.
2 changes: 2 additions & 0 deletions docs/release-notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@ nav_order: 9

### Changes

- The Dracut module now installs partprobe

### Bug fixes

- Prevent races with udev after disk editing
- A partition table re-read fixes corner cases where udev couldn't pick up changes


## Ignition 2.16.2 (2023-07-12)
Expand Down
1 change: 1 addition & 0 deletions dracut/30ignition/module-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ install() {
mkfs.xfs \
mkswap \
sgdisk \
partprobe \
useradd \
userdel \
usermod \
Expand Down
2 changes: 2 additions & 0 deletions internal/distro/distro.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ var (
mdadmCmd = "mdadm"
mountCmd = "mount"
sgdiskCmd = "sgdisk"
partprobeCmd = "partprobe"
modprobeCmd = "modprobe"
udevadmCmd = "udevadm"
usermodCmd = "usermod"
Expand Down Expand Up @@ -90,6 +91,7 @@ func GroupdelCmd() string { return groupdelCmd }
func MdadmCmd() string { return mdadmCmd }
func MountCmd() string { return mountCmd }
func SgdiskCmd() string { return sgdiskCmd }
func PartprobeCmd() string { return partprobeCmd }
func ModprobeCmd() string { return modprobeCmd }
func UdevadmCmd() string { return udevadmCmd }
func UsermodCmd() string { return usermodCmd }
Expand Down
5 changes: 5 additions & 0 deletions internal/sgdisk/sgdisk.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ func (op *Operation) Commit() error {
if _, err := op.logger.LogCmd(cmd, "deleting %d partitions and creating %d partitions on %q", len(op.deletions), len(op.parts), op.dev); err != nil {
return fmt.Errorf("create partitions failed: %v", err)
}
// In contrast to similar tools, sgdisk does not trigger the update of the kernel partition table
cmd = exec.Command(distro.PartprobeCmd(), op.dev)
if _, err := op.logger.LogCmd(cmd, "re-reading of %d deleted partitions and %d created partitions on %q", len(op.deletions), len(op.parts), op.dev); err != nil {
return fmt.Errorf("re-reading partitions failed: %v", err)
}

return nil
}
Expand Down

0 comments on commit 78efdc2

Please sign in to comment.