def partition(self, doit): if not doit: return # I'll make the sequence: root, then swap then home(/DATA). # But swap and/or home may be absent. # root and swap are created as primary partitions, home(/DATA) # as logical (to ensure that ny unallocated space may also be used). # The actual partitioning is done, but the formatting is # handled - given the appropriate information - by the # installation stage. If a swap partition is created that will, # however, be formatted. startpart = 2 if self.keep1 else 1 # Remove all existing partitions from startpart ui.progressPopup.start() ui.progressPopup.add(_("Removing all partitions on %s,\n" " starting from number %d") % (self.device, startpart)) if not backend.rmparts(self.device, startpart): return diskinfo = DiskInfo(self.device) # Check that the free space corresponds to what is expected. # Convert GB to cylinders for (self.disksize - self.p1size) allfreecyls = diskinfo.get_freecyls() bytespercyl = diskinfo.cyl2B() deviation = abs(self.disksize - self.p1size - (allfreecyls * bytespercyl / 10**9)) if deviation > 1: fatal_error("BUG in autopart: free space deviation = %5.1f" % deviation) # Allocate number of cylinders for the largest partition last, # just in case it gets tight ... newparts = [] maxp = None maxs = 0 boots = 0.2 if self.larchboot: boots += self.live_gb * 1.5 for m, s, t in ( ("/boot", boots, "primary"), ("swap", self.swapsize, "primary"), ("/", self.rootsize, "logical"), ("/home/DATA" if self.homedata else "/home", self.datasize, "logical"), ("", self.unallocated, None)): if s > 0.1: # Convert GB to cylinders entry = [t, int((s * 10**9 / bytespercyl) + 0.5), m] newparts.append(entry) if s > maxs: maxs = s maxp = entry sum = 0 for ps in newparts: if ps != maxp: sum += ps[1] maxp[1] = allfreecyls - sum # Create the partitions iparts = [] for t, s, m in newparts: if not t: continue swap = (m=="swap") ui.progressPopup.add(_("Creating %s partition for %s") % (t, m)) part = backend.newpart(self.device, t.startswith("p"), s, swap) if not part: iparts = None break if swap and not backend.mkswap(part, self.swapcheck): iparts = None break else: # [mount-point, device, size, format] iparts.append([m, part, "" if swap else "ext2" if m == "/boot" else "ext4"]) ui.progressPopup.add(" ---> " + part) ui.progressPopup.end() # Go to installation stage if iparts: ui.sendsignal("&install!", iparts)