Skip to content

Commit

Permalink
Use partprobe to re-read partition table
Browse files Browse the repository at this point in the history
The `blkdev` command is fragile re-reading partition tables if a
partition is mounted. This change replaces it with the `partprobe`
command.

Closes-Bug: https://bugs.launchpad.net/cloud-init/+bug/1920939
Signed-off-by: Nicolas Bock <nicolas.bock@canonical.com>
  • Loading branch information
nicolasbock committed Mar 26, 2021
1 parent bad84ad commit 38f116f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions cloudinit/config/cc_disk_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
LSBLK_CMD = subp.which("lsblk")
BLKID_CMD = subp.which("blkid")
BLKDEV_CMD = subp.which("blockdev")
PARTPROBE_CMD = subp.which("partprobe")
WIPEFS_CMD = subp.which("wipefs")

LANG_C_ENV = {'LANG': 'C'}
Expand Down Expand Up @@ -688,10 +689,10 @@ def read_parttbl(device):
Use partprobe instead of 'udevadm'. Partprobe is the only
reliable way to probe the partition table.
"""
blkdev_cmd = [BLKDEV_CMD, '--rereadpt', device]
partprobe_cmd = [PARTPROBE_CMD, device]
util.udevadm_settle()
try:
subp.subp(blkdev_cmd)
subp.subp(partprobe_cmd)
except Exception as e:
util.logexc(LOG, "Failed reading the partition table %s" % e)

Expand Down
1 change: 1 addition & 0 deletions tools/.github-cla-signers
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ manuelisimo
marlluslustosa
matthewruffell
mitechie
nicolasbock
nishigori
olivierlemasle
omBratteng
Expand Down

0 comments on commit 38f116f

Please sign in to comment.