Изменена установка на btrfs с сжатием

legacy27 3.6.9.7
parent fc2e151e92
commit e62d86880c

@ -987,23 +987,6 @@ class FormatBtrfs(FormatProcessGeneric):
def param(self):
return "-f", self.get_label(), self.dev
class FormatBtrfsCompressed(FormatBtrfs):
def postaction(self):
try:
if self.purpose != "boot" and self.compression:
Btrfs(self.dev).compression = self.compression
if self.purpose == "root":
# disable btrfs compression for /boot directory in root partition
# and usr/share/grub for unicode.pf2
for dn in ("boot", "usr/share/grub", "var/calculate/linux"):
Btrfs(self.dev).set_compression(dn, "")
if self.purpose == "calculate":
Btrfs(self.dev).set_compression("linux", "")
except BtrfsError as e:
raise DistributiveError(
_("Failed to set btrfs compression for {}").format(self.dev))
class PartitionDistributive(Distributive):
format_map = {
@ -1020,7 +1003,7 @@ class PartitionDistributive(Distributive):
'ntfs': FormatNtfs,
'uefi': FormatUefi,
'btrfs': FormatBtrfs,
'btrfs-compress': FormatBtrfsCompressed,
'btrfs-compress': FormatBtrfs,
'swap': FormatSwap
}
@ -1123,13 +1106,16 @@ class PartitionDistributive(Distributive):
def convertToDirectory(self):
"""Convert partition to directory by mounting"""
mapFS = {'btrfs-compress': 'btrfs'}
mapOpts = {'btrfs-compress': ' -o compress=%s' % self.compression}
mdirectory = self.mdirectory
for child in self.childs:
if isinstance(child, DirectoryDistributive) and \
mdirectory in child.directory:
return child
mdirectory = self._getMntDirectory(mdirectory)
self._mountPartition(self.partition, mdirectory)
self._mountPartition(self.partition, mdirectory,
mapOpts.get(self.fileSystem,""))
dirObj = DirectoryDistributive(mdirectory, parent=self)
if self.multipartition:
mulipartDataNotBind = filter(lambda x: x[2] != "bind",
@ -1139,10 +1125,10 @@ class PartitionDistributive(Distributive):
realMountPoint = None
if fileSystem != "swap":
realMountPoint = pathJoin(mdirectory, mountPoint)
mapFS = {'btrfs-compress': 'btrfs'}
self._mountPartition(
dev, realMountPoint,
"-t %s" % mapFS.get(fileSystem,fileSystem))
"-t %s" % mapFS.get(fileSystem,fileSystem) +
mapOpts.get(fileSystem,""))
partObj = PartitionDistributive(dev, flagRemoveDir=False,
fileSystem=fileSystem,
isFormat=isFormat,

@ -35,6 +35,7 @@ class FileSystemManager(object):
'label': '-L {labelname}',
'ssd': [],
'msdos': '83',
'compress': None,
'type': ['hdd', 'usb-hdd']},
'ext3': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.ext3',
@ -43,6 +44,7 @@ class FileSystemManager(object):
'label': '-L {labelname}',
'ssd': [],
'msdos': '83',
'compress': None,
'type': ['hdd', 'usb-hdd']},
'ext4': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.ext4',
@ -51,6 +53,7 @@ class FileSystemManager(object):
'label': '-L {labelname}',
'ssd': ['discard'],
'msdos': '83',
'compress': None,
'type': ['hdd', 'usb-hdd']},
'reiserfs': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.reiserfs',
@ -58,6 +61,7 @@ class FileSystemManager(object):
'gpt': '8300',
'label': '-l {labelname}',
'msdos': '83',
'compress': None,
'ssd': [],
'type': ['hdd', 'usb-hdd']},
'btrfs': {'defaultopt': defaultOpt,
@ -68,10 +72,12 @@ class FileSystemManager(object):
'msdos': '83',
'ssd': ['ssd', 'discard', 'space_cache'],
'type': ['hdd', 'usb-hdd'],
'compress': None,
'compatible': ['btrfs-compress']},
'btrfs-compress': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.btrfs',
'orig': 'btrfs',
'compress': "compress=%s",
'formatparam': '{labelparam} -f {device}',
'gpt': '8300',
'label': '-L {labelname}',
@ -86,6 +92,7 @@ class FileSystemManager(object):
'label': '-L {labelname}',
'msdos': '83',
'ssd': ['discard'],
'compress': None,
'type': ['hdd', 'usb-hdd']},
'xfs': {'defaultopt': defaultOpt,
'format': '/sbin/mkfs.xfs',
@ -95,6 +102,7 @@ class FileSystemManager(object):
'msdos': '83',
'boot': '-i sparce=0',
'ssd': ['discard'],
'compress': None,
'type': ['hdd', 'usb-hdd']},
# 'nilfs2': {'defaultopt': defaultOpt,
# 'format': '/sbin/mkfs.nilfs2',
@ -111,6 +119,7 @@ class FileSystemManager(object):
'label': '',
'ssd': [],
'auto': False,
'compress': None,
'msdos': '82'},
'uefi': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.vfat',
@ -120,6 +129,7 @@ class FileSystemManager(object):
'msdos': '0b',
'ssd': [],
'auto': False,
'compress': None,
'type': ['hdd']},
'vfat': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.vfat',
@ -129,6 +139,7 @@ class FileSystemManager(object):
'msdos': '0b',
'auto': False,
'ssd': ['discard'],
'compress': None,
'type': ['flash']},
'ntfs': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.ntfs',
@ -138,6 +149,7 @@ class FileSystemManager(object):
'msdos': '7',
'auto': False,
'ssd': [],
'compress': None,
'compatible': ['ntfs-3g']},
'ntfs-3g': {'defaultopt': defaultOpt,
'format': '/usr/sbin/mkfs.ntfs',
@ -147,11 +159,13 @@ class FileSystemManager(object):
'ssd': [],
'auto': False,
'msdos': '7',
'compress': None,
'compatible': ['ntfs']}}
default_param = {'defaultopt': defaultOpt,
'gpt': '8300',
'msdos': '83',
'compress': None,
'ssd': []}
@classmethod
@ -179,10 +193,12 @@ class FileSystemManager(object):
}
@classmethod
def getDefaultOpt(cls, fs, ssd=False):
return ",".join(cls.supportFS.get(fs, cls.default_param)['defaultopt'] +
(cls.supportFS.get(fs, cls.default_param)['ssd']
if ssd else []))
def getDefaultOpt(cls, fs, ssd=False, compress=None):
fsopts = cls.supportFS.get(fs, cls.default_param)
return ",".join(fsopts['defaultopt'] +
(fsopts['ssd'] if ssd else []) +
([fsopts['compress'] % compress]
if fsopts['compress'] and compress else []))
@classmethod
def checkFSForTypeMount(cls, fs, roottype, mp):

@ -567,7 +567,6 @@ class VariableOsDiskContent(ReadonlyVariable):
return map(lambda x: "",
self.Get('os_disk_dev'))
class VariableOsDiskFormat(ReadonlyVariable):
"""
Filesystem on device partitions
@ -584,6 +583,9 @@ class VariableOsDiskFormat(ReadonlyVariable):
fstab.getBy(what=fstab.TYPE, eq=dev) or \
prop.get('ID_FS_TYPE', '')
if fs == "btrfs":
if "compress" in fstab.getBy(what=fstab.OPTS,
eq=dev):
return "btrfs-compress"
try:
if Btrfs(dev).compression != "":
return "btrfs-compress"
@ -1349,6 +1351,8 @@ class VariableOsLocationFormat(LocationHelper, Variable):
'os_format_use', os_format_type=_format, limit=1) == "yes":
default_format = _format
break
else:
root_format = None
def wrap(info):
dev, mount, fs = info
@ -1357,14 +1361,18 @@ class VariableOsLocationFormat(LocationHelper, Variable):
return "swap"
elif mount.startswith('/boot/efi'):
return "vfat"
if dev in diskFormat and diskFormat[dev] in allAvailFS:
if mount.count('/') == 1 or mount == "/var/calculate":
if FileSystemManager.checkFSForTypeMount(
diskFormat[dev],
osInstallRootType, mount):
if mount == "/":
if root_format and root_format in allAvailFS:
return root_format
else:
if dev in diskFormat and diskFormat[dev] in allAvailFS:
if mount.count('/') == 1 or mount == "/var/calculate":
if FileSystemManager.checkFSForTypeMount(
diskFormat[dev],
osInstallRootType, mount):
return diskFormat[dev]
else:
return diskFormat[dev]
else:
return diskFormat[dev]
if default_format:
return default_format
return FileSystemManager.defaultFS.get(
@ -1784,7 +1792,9 @@ class VariableOsInstallDiskOptions(ReadonlyVariable):
else:
all_ssd = all(x in ssd_devices
for x in disk_parent.split(','))
yield FileSystemManager.getDefaultOpt(disk_format, all_ssd)
compression = self.Get('os_install_btrfs_compression')
yield FileSystemManager.getDefaultOpt(disk_format, all_ssd,
compression)
return list(generator())

Loading…
Cancel
Save