def check_alongside_disk_layout(): """ Alongside can only work if user has followed the recommended BIOS-Based Disk-Partition Configurations shown in http://technet.microsoft.com/en-us/library/dd744364(v=ws.10).aspx """ # TODO: Add more scenarios where alongside could work partitions = misc.get_partitions() # logging.debug(partitions) extended = False for partition in partitions: if misc.is_partition_extended(partition): extended = True if extended: return False # We just seek for sda partitions partitions_sda = [] for partition in partitions: if "sda" in partition: partitions_sda.append(partition) # There's no extended partition, so all partitions must be primary if len(partitions_sda) < 4: return True return False
def get_type(part): """ Get filesystem type using blkid """ ret = '' if part and not misc.is_partition_extended(part): cmd = ['blkid', '-o', 'value', '-s', 'TYPE', part] ret = call(cmd) return ret
def get_type(part): """ Get filesystem type using blkid """ ret = '' if part and not misc.is_partition_extended(part): try: cmd = ['blkid', '-o', 'value', '-s', 'TYPE', part] ret = subprocess.check_output(cmd).decode().strip() except subprocess.CalledProcessError as err: logging.warning("Error running %s: %s", err.cmd, err.output) return ret
def get_info(part): """ Get partition info using blkid """ ret = '' partdic = {} # Do not try to get extended partition info if part and not misc.is_partition_extended(part): # -c /dev/null means no cache cmd = ['blkid', '-c', '/dev/null', part] call(cmd) for info in ret.split(): if '=' in info: info = info.split('=') partdic[info[0]] = info[1].strip('"') return partdic
def get_info(part): """ Get partition info using blkid """ ret = '' partdic = {} # Do not try to get extended partition info if part and not misc.is_partition_extended(part): # -c /dev/null means no cache cmd = ['blkid', '-c', '/dev/null', part] call(cmd) try: ret = subprocess.check_output(cmd).decode().strip() except subprocess.CalledProcessError as err: logging.warning("Error running %s: %s", err.cmd, err.output) for info in ret.split(): if '=' in info: info = info.split('=') partdic[info[0]] = info[1].strip('"') return partdic