def resetRootDevice(self): """ Formats root device (according LVM default scheme) and adjusts all pointers to allow reinstall the system correctly. Important: this method is directly related to LVM default partitioning scheme. It assumes that root device is under /dev/mapper/vg_root-lv_root path. If this default scheme changes on future, this method must be revisited to assure its functionality. @rtype: bool @return: True if everything is ok, False otherwise """ # restart LVM volume groups to assure its functionality self.__logger.info('Restarting LVM...') lvm.stop() lvm.start(self.__tolerantMode) # wait for udev to handle all events if run(CMD_UDEV_SETTLE) != 0: raise RuntimeError('Error: udevadm settle failure') # Do not trust content from / partition. User can screw up # with its / partition and try a reinstall to fix it. Thus # our code cannot trust on reading content from old and dirty # / partition. We can just infere /boot partition by # appending 2 to the detected disk. installed_disk = self.getPreviousInstalledDisk() boot_partition = self.genBootPartitionName(installed_disk) self.__bootDevice = boot_partition # check multipath self.__hasMultipath = self.__diskParameters[installed_disk.split('/')[-1]]['mpath'] # as consequence, configure prep device path self.__prepDevice = self.__bootDevice[:-1] + "1" # update root, log, data and swap paths self.__rootDevice = '/dev/mapper/%s-%s' % (VGROOT, LVROOT) self.__logDevice = '/dev/mapper/%s-%s' % (VGLOG, LVLOG) self.__dataDevice = '/dev/mapper/%s-%s' % (VGDATA, LVDATA) self.__swapDevice = '/dev/mapper/%s-%s' % (VGSWAP, LVSWAP) self.__logger.debug("resetRootDevice(): __prepDevice = %s" % self.__prepDevice) self.__logger.debug("resetRootDevice(): __bootDevice = %s" % self.__bootDevice) self.__logger.debug("resetRootDevice(): __rootDevice = %s" % self.__rootDevice) self.__logger.debug("resetRootDevice(): __logDevice = %s" % self.__logDevice) self.__logger.debug("resetRootDevice(): __dataDevice = %s" % self.__dataDevice) self.__logger.debug("resetRootDevice(): __swapDevice = %s" % self.__swapDevice) # format boot, root and swap devices formatPartition(self.__bootDevice) formatPartition(self.__rootDevice) formatSwapPartition(self.__swapDevice) return True
def __createLVMEntities(self, hasMultipath): """ Calls methods to create LVM entities on system. This method creates all required physical volumns, volumn groups and logical volumns to install the system. @rtype: None @return: Nothing """ # can't create PVs: abort self.__logger.info('Creating physical volumns...') self.__logger.debug('LVM PV Create List:\n%s' % str(self.__pvCreateList)) if not lvm.createPVs(self.__pvCreateList, hasMultipath): raise PKVMError("PARTITIONER", "LVM", "CREATE_LVM") # can't create VGs: abort self.__logger.info('Creating volumn groups...') self.__logger.debug('LVM VG Create List:\n%s' % str(self.__vgCreateList)) if not lvm.createVGs(self.__vgCreateList, hasMultipath): raise PKVMError("PARTITIONER", "LVM", "CREATE_LVM") # can't create LVs: abort self.__logger.info('Creating logical volumns...') self.__logger.debug('LVM LV Create List:\n%s' % str(self.__lvCreateList)) if not lvm.createLVs(self.__lvCreateList): raise PKVMError("PARTITIONER", "LVM", "CREATE_LVM") # can't resize LVM entities: abort self.__logger.info('Resizing LVMs entities...') self.__logger.debug('LVM Reuse List:\n%s' % str(self.__lvUseList)) if not lvm.resizeLVs(self.__lvUseList): raise PKVMError("PARTITIONER", "LVM", "CREATE_LVM") # can't adjust PVs: abort self.__logger.info('Adjusting physical volumns...') self.__logger.debug('LVM Adjust PVs List:\n%s' % str(self.__vgUseList)) if not lvm.adjustPVs(self.__vgUseList, hasMultipath): raise PKVMError("PARTITIONER", "LVM", "CREATE_LVM") # restart LVM volume groups to avoid any problems later self.__logger.info('Restarting LVM...') lvm.stop() lvm.start(self.__tolerantMode)