def auto_fstab(self): all_lines = [] all_lines.append("# /etc/fstab: static file system information.") all_lines.append("#") all_lines.append("# Use 'blkid' to print the universally unique identifier for a") all_lines.append("# device; this may be used with UUID= as a more robust way to name devices") all_lines.append("# that works even if disks are added and removed. See fstab(5).") all_lines.append("#") all_lines.append("# <file system> <mount point> <type> <options> <dump> <pass>") all_lines.append("#") root_ssd = 0 for path in self.mount_devices: opts = 'defaults' chk = '0' parti = self.mount_devices[path] info = fs.get_info(parti) uuid = info['UUID'] if parti in self.fs_devices: myfmt = self.fs_devices[parti] else: # It hasn't any filesystem defined (maybe swap?) # TODO: don't skip it and mount it as it should be if it is a swap partition continue if path == '/': chk = '1' opts = "rw,relatime,data=ordered" else: full_path = os.path.join(self.dest_dir, path) subprocess.check_call(["mkdir", "-p", full_path]) if self.ssd != None: for i in self.ssd: if i in self.mount_devices[path] and self.ssd[i]: opts = 'defaults,noatime,nodiratime' # As of linux kernel version 3.7, the following # filesystems support TRIM: ext4, btrfs, JFS, and XFS. # If using a TRIM supported SSD, discard is a valid mount option for swap if myfmt == 'ext4' or myfmt == 'btrfs' or myfmt == 'jfs' or myfmt == 'xfs' or myfmt == 'swap': opts += ',discard' if path == '/': root_ssd = 1 all_lines.append("UUID=%s %s %s %s 0 %s" % (uuid, path, myfmt, opts, chk)) if root_ssd: all_lines.append("tmpfs /tmp tmpfs defaults,noatime,mode=1777 0 0") full_text = '\n'.join(all_lines) with open('/install/etc/fstab','w') as f: f.write(full_text)
def fill_partition_list(self): # create tree store 'partition_list_store' for our model if self.partition_list_store != None: self.partition_list_store.clear() # Treeview columns: # disc path or partition path or "free space", # fs_type # label # part_name # formatable_active # formatable_visible # size # used # partition_path # flags self.partition_list_store = Gtk.TreeStore(str, str, str, str, bool, bool, str, str, str, str, int) if self.disks == None: # just call get_devices once self.disks = pm.get_devices() for disk_path in sorted(self.disks): disk = self.disks[disk_path] if disk is None: # maybe disk without a partition table? print(disk_path) row = [disk_path, "", "", "", False, False, "", "", "", "", 0] self.partition_list_store.append(None, row) else: dev = disk.device size_txt = self.get_size(dev.length, dev.sectorSize) row = [dev.path, "", "", "", False, False, size_txt, "", "", "", 0] disk_parent = self.partition_list_store.append(None, row) parent = disk_parent # create list of partitions for this device (/dev/sda for example) partitions = pm.get_partitions(disk) partition_list = pm.order_partitions(partitions) for partition_path in partition_list: p = partitions[partition_path] size_txt = self.get_size(p.geometry.length, dev.sectorSize) label = "" if p.type == pm.PARTITION_EXTENDED: path = p.path mount_point = "" fs_type = _("extended") formatable = False used = "" flags = pm.get_flags(p) # aas# cannot get label from staged partition try: info = fs.get_info(partition_path) except: info = [] if "LABEL" in info: label = info["LABEL"] elif p.type == pm.PARTITION_PRIMARY or p.type == pm.PARTITION_LOGICAL: path = p.path # aas# fix crash if no fs on partition if p.fileSystem: fs_type = p.fileSystem.type else: fs_type = "none" formatable = True used = str(pm.get_used_space(p)) flags = pm.get_flags(p) if pm.check_mounted(p): if "swap" in fs_type: mount_point = "(swap)" else: mount_point = self.get_mount_point(p.path) else: mount_point = "" # aas# we cannot get label of staged partition try: info = fs.get_info(partition_path) except: info = [] if "LABEL" in info: label = info["LABEL"] elif p.type == pm.PARTITION_FREESPACE: path = _("free space") mount_point = "" fs_type = _("not used") formatable = True used = "" flags = "" row = [ path, fs_type, mount_point, label, False, formatable, size_txt, used, partition_path, "", p.type, ] tree_iter = self.partition_list_store.append(parent, row) if p.type == pm.PARTITION_EXTENDED: parent = tree_iter elif p.type == pm.PARTITION_PRIMARY: parent = disk_parent # assign our new model to our treeview self.partition_list.set_model(self.partition_list_store) self.partition_list.expand_all()