--- pyanaconda/bootloader.py | 8 ++++---- pyanaconda/storage/devicetree.py | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 4 deletions(-) diff --git a/pyanaconda/bootloader.py b/pyanaconda/bootloader.py index c981acd..4ef8b32 100644 --- a/pyanaconda/bootloader.py +++ b/pyanaconda/bootloader.py @@ -564,10 +564,7 @@ class BootLoader(object): self.warnings = [] return valid - if os.path.exists("/dev/live") and \ - os.path.realpath("/dev/live") == device.path: - self.errors.append(_("%s cannot be on the live device.") - % description) + if device.protected: valid = False if not self._device_type_match(device, constraint["device_types"]): @@ -670,6 +667,9 @@ class BootLoader(object): if device is None: return False + if device.protected: + valid = False + if not self._device_type_match(device, self.stage2_device_types): self.errors.append(_("%s cannot be of type %s") % (self.stage2_description, device.type)) diff --git a/pyanaconda/storage/devicetree.py b/pyanaconda/storage/devicetree.py index b735ec2..c4f3981 100644 --- a/pyanaconda/storage/devicetree.py +++ b/pyanaconda/storage/devicetree.py @@ -1016,11 +1016,49 @@ class DeviceTree(object): log.error("Unknown block device type for: %s" % name) return + def get_live_backing_device_path(): + """ Return a path to the live block device or an empty string. + + The line we're looking for will be of the form + + root='block:/dev/disk/by-uuid/<UUID>' + + """ + root_info = "/run/initramfs/tmp/root.info" + dev_live = "/dev/live" + root_path = "" + if os.path.exists(dev_live): + root_path = os.readlink(dev_live) + elif os.path.exists(root_info): + for line in open(root_info): + if not line.startswith("root="): + continue + + value = line.split("=", 1)[1][1:-1] + if not value.startswith("block:"): + continue + + root_path = os.path.realpath(value.split(":", 1)[1])) + root_name = devicePathToName(root_path) + if root_name.startswith("dm-"): + root_name = dm.name_from_dm_node(root_name) + root_path = "/dev/mapper/%s" % root_name + + break + + return root_path + # If this device is protected, mark it as such now. Once the tree # has been populated, devices' protected attribute is how we will # identify protected devices. if device and device.name in self.protectedDevNames: device.protected = True + # if this is the live backing device we want to mark its parents + # as protected also + live_path = get_live_backing_device_path() + if live_path and device.path and live_path: + for parent in device.parents: + parent.protected = True # Don't try to do format handling on drives without media or # if we didn't end up with a device somehow. -- 1.7.6 _______________________________________________ Anaconda-devel-list mailing list Anaconda-devel-list@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/anaconda-devel-list