示例#1
0
    def format(self, partition):
        self.preFormat(partition)

        cmd_path = sysutils.find_executable("mke2fs")
        if not cmd_path:
            cmd_path = sysutils.find_executable("mkfs.ext3")

        if not cmd_path:
            e = "Command not found to format %s filesystem" %(self.name())
            raise FSError, e

        # bug 5616: ~100MB reserved-blocks-percentage
        reserved_percentage = int(math.ceil(100.0 * 100.0 / partition.getMB()))

        # Use hashed b-trees to speed up lookups in large directories
        cmd = "%s -O dir_index -j -m %d %s" %(cmd_path,
                                              reserved_percentage,
                                              partition.getPath())

        p = os.popen(cmd)
        o = p.readlines()
        if p.close():
            raise YaliException, "ext3 format failed: %s" % partition.getPath()

        # for Disabling Lengthy Boot-Time Checks
        self.tune2fs(partition)
示例#2
0
    def format(self, partition):
        self.preFormat(partition)

        cmd_path = sysutils.find_executable("mke2fs")
        if not cmd_path:
            cmd_path = sysutils.find_executable("mke2fs")

        if not cmd_path:
            e = "Command not found to format %s filesystem" % (self.name())
            raise FSError, e

        cmd = "%s -j %s" % (cmd_path, partition.getPath())

        p = os.popen(cmd)
        o = p.readlines()
        if p.close():
            raise YaliException, "ext3 format failed: %s" % partition.getPath()
示例#3
0
 def setLabel(self, partition, label):
     label = self.availableLabel(label)
     cmd_path = sysutils.find_executable("mkswap")
     cmd = "%s -v1 -L %s %s" % (cmd_path, label, partition.getPath())
     try:
         p = os.popen(cmd)
         p.close()
     except:
         return False
     return True
示例#4
0
    def format(self, partition):
        self.preFormat(partition)

        cmd_path = sysutils.find_executable("mke2fs")
        if not cmd_path:
            cmd_path = sysutils.find_executable("mkfs.ext3")

        
        if not cmd_path:
            e = "Command not found to format %s filesystem" %(self.name())
            raise FSError, e

        # Use hashed b-trees to speed up lookups in large directories
        cmd = "%s -O dir_index -j %s" %(cmd_path, partition.getPath())

        p = os.popen(cmd)
        o = p.readlines()
        if p.close():
            raise YaliException, "ext3 format failed: %s" % partition.getPath()
示例#5
0
文件: storage.py 项目: Tayyib/uludag
 def list_edd_signatures(self):
     sigs = {}
     if not os.path.exists(self.edd_dir):
         cmd_path = sysutils.find_executable("modprobe")
         cmd = "%s %s" %(cmd_path,"edd")
         p = os.popen(cmd)
         o = p.readlines()
         if p.close():
             raise YaliException, "Inserting EDD Module failed !"
     for d in os.listdir(self.edd_dir):
         bios_num = d[9:]
         sigs[bios_num] = self.get_edd_sig(bios_num)
     return sigs
示例#6
0
    def tune2fs(self, partition):
        cmd_path = sysutils.find_executable("tune2fs")
        if not cmd_path:
            e = "Command not found to tune the filesystem"
            raise FSError, e

        # Disable mount count and use 6 month interval to fsck'ing disks at boot
        cmd = "%s -c 0 -i 6m %s" % (cmd_path, partition.getPath())

        p = os.popen(cmd)
        o = p.readlines()
        if p.close():
            raise YaliException, "tune2fs tuning failed: %s" % partition.getPath()
示例#7
0
    def minResizeMB(self, partition):
        cmd_path = sysutils.find_executable("dumpe2fs")

        if not cmd_path:
            e = "Command not found to get information about %s" %(partition)
            raise FSError, e 

        lines = os.popen("%s -h %s" % (cmd_path, partition.getPath())).readlines()

        total_blocks = long(filter(lambda line: line.startswith('Block count'), lines)[0].split(':')[1].strip('\n').strip(' '))
        free_blocks  = long(filter(lambda line: line.startswith('Free blocks'), lines)[0].split(':')[1].strip('\n').strip(' '))
        block_size   = long(filter(lambda line: line.startswith('Block size'), lines)[0].split(':')[1].strip('\n').strip(' '))

        return (((total_blocks - free_blocks) * block_size) / parteddata.MEGABYTE) + 150
示例#8
0
    def format(self, partition):
        self.preFormat(partition)

        cmd_path = sysutils.find_executable("mkreiserfs")
        
        if not cmd_path:
            e = "Command not found to format %s filesystem" %(self.name())
            raise FSError, e

        cmd = "%s  %s" %(cmd_path, partition.getPath())

        p = os.popen(cmd, "w")
        p.write("y\n")
        if p.close():
            raise YaliException, "reiserfs format failed: %s" % partition.getPath()
示例#9
0
    def resize(self, size_mb, partition):
        if size_mb < self.minResizeMB(partition):
            return False

        cmd_path = sysutils.find_executable("resize2fs")

        if not cmd_path:
            e = "Command not found to format %s filesystem" %(self.name())
            raise FSError, e 
        
        cmd = "%s %s %sM" % (cmd_path, partition.getPath(), str(size_mb)) 
        
        try:
            p = os.popen(cmd)
            p.close()
        except:
            return False
        return True
示例#10
0
文件: storage.py 项目: Tayyib/uludag
def setOrderedDiskList():
    devices = detectAll()
    devices.sort()

    import yali.gui.context as ctx

    # Check EDD Module
    if not os.path.exists("/sys/firmware/edd"):
        cmd_path = sysutils.find_executable("modprobe")
        cmd = "%s %s" % (cmd_path, "edd")
        res = sysutils.run(cmd)
        if not res:
            ctx.installData.orderedDiskList = devices
            ctx.debugger.log("ERROR : Inserting EDD Module failed !")
            return

    edd = EDD()
    sortedList = []
    edd_list = edd.list_edd_signatures()
    mbr_list = edd.list_mbr_signatures()
    edd_keys = edd_list.keys()
    edd_keys.sort()
    for bios_num in edd_keys:
        edd_sig = edd_list[bios_num]
        if mbr_list.has_key(edd_sig):
            sortedList.append(mbr_list[edd_sig])

    if len(devices) > 1:
        a = ctx.installData.orderedDiskList = sortedList
        b = devices
        # check consistency of diskList
        if not len(filter(None, map(lambda x: x in a,b))) == len(b):
            ctx.installData.orderedDiskList = devices
            ctx.isEddFailed = True
    else:
        ctx.installData.orderedDiskList = devices
示例#11
0
def requires(command):
    cmd_path = sysutils.find_executable(command)
    if not cmd_path:
        raise FSError, "Command not found: %s " % command
    return cmd_path