def get_boot_device(): """ Guess the /boot device based on the last mountpoint Returns None if it cannot find it. """ for device_path in get_devices(): last_mountpoint = tune2fs.get_last_mountpoint(device_path) if last_mountpoint == "/boot": return device_path return None
def get_valid_devices(): """Get valid devices to be encrypted or decrypted""" boot_device = get_boot_device() device_paths = [] for device_path in get_devices(): disktype = get_info(device_path)["TYPE"] fstype = get_info(device_path)["FSTYPE"] last_mountpoint = tune2fs.get_last_mountpoint(device_path) if disktype not in VALID_DISK_TYPES: continue if fstype not in VALID_FSTYPES: continue if boot_device and boot_device == device_path: continue device_paths.append(device_path) return device_paths
if len(sys.argv) == 1: devices = get_devices(by="UUID") for d in devices: print d print "=" * 40 valid_devices = get_valid_devices() pp.pprint(valid_devices) else: device_path = sys.argv[1] data = get_info(device_path) print len(data) pp.pprint(data) print " SIZE : %s" % get_size(device_path) print " FREE SIZE: %s" % get_free_size(device_path) print " FREE SIZE: %s" % get_free_size(device_path) print " UUID : %s" % get_uuid(device_path) print " UUID : %s" % get_info(device_path)["UUID"] format = "%-30s %-10s %-10s %-10s" for device_path in get_valid_devices(): disktype = get_info(device_path)["TYPE"] fstype = get_info(device_path)["FSTYPE"] last_mountpoint = tune2fs.get_last_mountpoint(device_path) print format % (device_path, disktype, fstype, last_mountpoint) print "IS THIS PREBOOT?", is_preboot()