diff options
author | Ćukasz 'sil2100' Zemczak <lukasz.zemczak@ubuntu.com> | 2017-04-18 12:27:57 +0200 |
---|---|---|
committer | usd-importer <ubuntu-server@lists.ubuntu.com> | 2017-04-24 08:23:24 +0000 |
commit | 512b1e00ab9b75e46cc76af40c72cf239fa100e5 (patch) | |
tree | 533eeec1377dd0502725e57bad3225d2e82fd812 /azurelinuxagent/daemon/resourcedisk/default.py | |
parent | c6339c307f36f77a4198d6faf1275acdf371200b (diff) | |
parent | 0f537ddd741bfb333dbc01b994013a2b4e75d26f (diff) | |
download | vyos-walinuxagent-512b1e00ab9b75e46cc76af40c72cf239fa100e5.tar.gz vyos-walinuxagent-512b1e00ab9b75e46cc76af40c72cf239fa100e5.zip |
Import patches-applied version 2.2.9-0ubuntu1 to applied/ubuntu/zesty-proposed
Imported using git-ubuntu import.
Changelog parent: c6339c307f36f77a4198d6faf1275acdf371200b
Unapplied parent: 0f537ddd741bfb333dbc01b994013a2b4e75d26f
New changelog entries:
* New upstream release (LP: #1683521).
Diffstat (limited to 'azurelinuxagent/daemon/resourcedisk/default.py')
-rw-r--r-- | azurelinuxagent/daemon/resourcedisk/default.py | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/azurelinuxagent/daemon/resourcedisk/default.py b/azurelinuxagent/daemon/resourcedisk/default.py index 21de38f..2b116fb 100644 --- a/azurelinuxagent/daemon/resourcedisk/default.py +++ b/azurelinuxagent/daemon/resourcedisk/default.py @@ -85,6 +85,11 @@ class ResourceDiskHandler(object): except ResourceDiskError as e: logger.error("Failed to enable swap {0}", e) + def reread_partition_table(self, device): + if shellutil.run("sfdisk -R {0}".format(device), chk_err=False): + shellutil.run("blockdev --rereadpt {0}".format(device), + chk_err=False) + def mount_resource_disk(self, mount_point): device = self.osutil.device_for_ide_port(1) if device is None: @@ -138,12 +143,13 @@ class ResourceDiskHandler(object): shellutil.run(mkfs_string) else: logger.info("GPT not detected, determining filesystem") - ret = self.change_partition_type(suppress_message=True, option_str="{0} 1".format(device)) + ret = self.change_partition_type(suppress_message=True, option_str="{0} 1 -n".format(device)) ptype = ret[1].strip() if ptype == "7" and self.fs != "ntfs": logger.info("The partition is formatted with ntfs, updating " "partition type to 83") self.change_partition_type(suppress_message=False, option_str="{0} 1 83".format(device)) + self.reread_partition_table(device) logger.info("Format partition [{0}]", mkfs_string) shellutil.run(mkfs_string) else: @@ -166,8 +172,8 @@ class ResourceDiskHandler(object): logger.info("Mount resource disk [{0}]", mount_string) ret, output = shellutil.run_get_output(mount_string, chk_err=False) - # if the exit code is 32, then the resource disk is already mounted - if ret == 32: + # if the exit code is 32, then the resource disk can be already mounted + if ret == 32 and output.find("is already mounted") != -1: logger.warn("Could not mount resource disk: {0}", output) elif ret != 0: # Some kernels seem to issue an async partition re-read after a @@ -178,9 +184,7 @@ class ResourceDiskHandler(object): logger.warn("Failed to mount resource disk. " "Retry mounting after re-reading partition info.") - if shellutil.run("sfdisk -R {0}".format(device), chk_err=False): - shellutil.run("blockdev --rereadpt {0}".format(device), - chk_err=False) + self.reread_partition_table(device) ret, output = shellutil.run_get_output(mount_string) if ret: |