Пример #1
0
    def zap_partition(self, device):
        """
        Device example: /dev/sda1
        Requirements: Must be a partition
        """
        if device.is_encrypted:
            # find the holder
            holders = [
                '/dev/%s' % holder
                for holder in device.sys_api.get('holders', [])
            ]
            for mapper_uuid in os.listdir('/dev/mapper'):
                mapper_path = os.path.join('/dev/mapper', mapper_uuid)
                if os.path.realpath(mapper_path) in holders:
                    self.dmcrypt_close(mapper_uuid)

        if system.device_is_mounted(device.abspath):
            mlogger.info("Unmounting %s", device.abspath)
            system.unmount(device.abspath)

        wipefs(device.abspath)
        zap_data(device.abspath)

        if self.args.destroy:
            mlogger.info("Destroying partition since --destroy was used: %s" %
                         device.abspath)
            disk.remove_partition(device)
Пример #2
0
    def zap_partition(self, device):
        """
        Device example: /dev/sda1
        Requirements: Must be a partition
        """
        if device.is_encrypted:
            # find the holder
            holders = [
                '/dev/%s' % holder for holder in device.sys_api.get('holders', [])
            ]
            for mapper_uuid in os.listdir('/dev/mapper'):
                mapper_path = os.path.join('/dev/mapper', mapper_uuid)
                if os.path.realpath(mapper_path) in holders:
                    self.dmcrypt_close(mapper_uuid)

        if system.device_is_mounted(device.abspath):
            mlogger.info("Unmounting %s", device.abspath)
            system.unmount(device.abspath)

        wipefs(device.abspath)
        zap_data(device.abspath)

        if self.args.destroy:
            mlogger.info("Destroying partition since --destroy was used: %s" % device.abspath)
            disk.remove_partition(device)