def start(self): """ Do things. """ used = [] # Bind-mount /dev, /sys and /proc (if no_virtual_partitions is not True): if not self.settings["skip"]: for point in ("/dev","/sys","/proc"): fullpath = os.path.join(self.main_settings["target"],os.path.basename(point)) if lib.is_mounted(fullpath): lib.umount(path=fullpath) # We can go? lib.mount_partition(path=point, opts="bind", target=fullpath, check=False) used.append(fullpath) # Store used self.settings["used"] = used
def freespace(self, partition): """ Calculates freespace on partition. """ # Rapid-mount mounted = lib.mount_partition(path=partition) info = os.statvfs(mounted) free = info.f_frsize * info.f_bavail # Umount lib.umount(path=mounted) return free
def configure(self): """ Configures the previously formatted persistent filesystem. """ path = self.main_settings["target"] + self.settings["path"] # os.path.join doesn't work if second argument begins with / image = os.path.join(path, "persistence-%s" % (self.settings["suffix"])) # Mount mpoint = lib.mount_partition(path=image, opts="loop") if self.settings["type"] in ("root", "home"): # Write with open(os.path.join(mpoint, "persistence.conf"), "w") as f: if self.settings["type"] == "root": # root persistence f.write("/ union\n") elif self.settings["type"] == "home": # home persistence f.write("/ bind\n") else: # We need to copy the path specified in type as the persistence.conf in the mountpoint shutil.copy2(self.settings["type"], os.path.join(mpoint, "persistence.conf")) # Umount! lib.umount(path=mpoint)
def start(self): """ Start override to unsquash. """ if "partdisks" in self.modules_settings: settings = self.modules_settings["partdisks"] else: settings = self.settings # Mount root partition. root = settings["root"] # Ensure that is unmounted if os.path.ismount(self.main_settings["target"]): # Target mounted. Unmount lib.umount(path=self.main_settings["target"]) if lib.is_mounted(root): # Partition mounted. Unmount lib.umount(path=root) # Then mount at TARGET lib.mount_partition(path=root, target=self.main_settings["target"]) used = [] # Mount every partition which has "useas" on it # Get changed. try: changed = self.modules_settings["partdisks"]["changed"] except: # Pass changed = {} mountpo = [] changeslist = {} # Regenerate changed to sort it sanely for key, value in changed.items(): if not "useas" in value["changes"]: # There isn't "useas" in changes; skipping this item continue mountpo.append(value["changes"]["useas"]) changeslist[value["changes"]["useas"]] = key mountpo.sort() for point in mountpo: # Get correct partition key = changeslist[point] # Get value value = changed[key] # Get useas useas = value["changes"]["useas"] if useas in ("/","swap"): # Root or swap, do not use it continue # Mount key to mountpoint if lib.is_mounted(key): # Umount lib.umount(path=key) if useas == "/boot/efi": # If this is going to be the /boot/efi partition # we should make sure that it's going to have the # proper partition type set to EFI System Partition lib.prepareforEFI(lib.return_partition(key)) # If we mount_on_install, simply set drop to False, as we should use it anyway if ("mount_on_install" in value["changes"] and value["changes"]["mount_on_install"]) or useas in ("/boot","/boot/efi"): # Create mountpoint mountpoint = self.main_settings["target"] + useas # useas begins with a /, so os.path.join doesn't work if not os.path.exists(mountpoint): os.makedirs(mountpoint) lib.mount_partition(path=key, target=mountpoint) # Partition will be used during unsquash, we should remember when linstaller will execute revert used.append(key) # Store used self.settings["used"] = used