Skip to content

Commit

Permalink
Use partprobe to inform OS of changes
Browse files Browse the repository at this point in the history
  • Loading branch information
matbme committed Jan 2, 2024
1 parent 0c930db commit 16f6a5c
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion core/disk.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,15 @@ func (disk *Disk) Update() error {
return nil
}

// waitForNewPartition is called after creating a new partition in order to
// waitForNewPartition should be called after creating a new partition to
// inform the OS of changes to the partition table (using `partprobe`) and
// ensure the system is aware of it before proceeding.
func (disk *Disk) waitForNewPartition() error {
err := RunCommand(fmt.Sprintf("partprobe %s", disk.Path))
if err != nil {
return err
}

for {
output, err := OutputCommand(fmt.Sprintf("lsblk -nro NAME %s | wc -l", disk.Path))
if err != nil {
Expand Down

0 comments on commit 16f6a5c

Please sign in to comment.