def _resize_part_and_fs(dev, start, old_sectors, new_sectors, flags):
 size = (new_sectors - start)
 end = (new_sectors - 1)
 dev_path = utils.make_dev_path(dev)
 partition_path = utils.make_dev_path(dev, partition=1)
 _repair_filesystem(partition_path)
 utils.execute('tune2fs', '-O ^has_journal', partition_path, run_as_root=True)
 if (new_sectors < old_sectors):
  try:
   utils.execute('resize2fs', partition_path, ('%ds' % size), run_as_root=True)
  except processutils.ProcessExecutionError as exc:
   LOG.error(six.text_type(exc))
   reason = _('Shrinking the filesystem down with resize2fs has failed, please check if you have enough free space on your disk.')
   raise exception.ResizeError(reason=reason)
 utils.execute('parted', '--script', dev_path, 'rm', '1', run_as_root=True)
 utils.execute('parted', '--script', dev_path, 'mkpart', 'primary', ('%ds' % start), ('%ds' % end), run_as_root=True)
 if ('boot' in flags.lower()):
  utils.execute('parted', '--script', dev_path, 'set', '1', 'boot', 'on', run_as_root=True)
 if (new_sectors > old_sectors):
  utils.execute('resize2fs', partition_path, run_as_root=True)
 utils.execute('tune2fs', '-j', partition_path, run_as_root=True)

def _resize_part_and_fs ( dev , start , old_sectors , new_sectors , flags ) : size = ( new_sectors - start ) end = ( new_sectors - 1 ) dev_path = utils . make_dev_path ( dev ) partition_path = utils . make_dev_path ( dev , partition = 1 ) _repair_filesystem ( partition_path ) utils . execute ( 'tune2fs' , '-O ^has_journal' , partition_path , run_as_root = True ) if ( new_sectors < old_sectors ) : try : utils . execute ( 'resize2fs' , partition_path , ( '%ds' % size ) , run_as_root = True ) except processutils . ProcessExecutionError as exc : LOG . error ( six . text_type ( exc ) ) reason = _ ( 'Shrinking the filesystem down with resize2fs has failed, please check if you have enough free space on your disk.' ) raise exception . ResizeError ( reason = reason ) utils . execute ( 'parted' , '--script' , dev_path , 'rm' , '1' , run_as_root = True ) utils . execute ( 'parted' , '--script' , dev_path , 'mkpart' , 'primary' , ( '%ds' % start ) , ( '%ds' % end ) , run_as_root = True ) if ( 'boot' in flags . lower ( ) ) : utils . execute ( 'parted' , '--script' , dev_path , 'set' , '1' , 'boot' , 'on' , run_as_root = True ) if ( new_sectors > old_sectors ) : utils . execute ( 'resize2fs' , partition_path , run_as_root = True ) utils . execute ( 'tune2fs' , '-j' , partition_path , run_as_root = True )
resize partition and fileystem .