def mkfs(device, fs_type, **kwargs):
 kwarg_map = {'block_size': 'b', 'check': 'c', 'direct': 'D', 'ext_opts': 'E', 'fragment_size': 'f', 'force': 'F', 'blocks_per_group': 'g', 'number_of_groups': 'G', 'bytes_per_inode': 'i', 'inode_size': 'I', 'journal': 'j', 'journal_opts': 'J', 'blocks_file': 'l', 'label': 'L', 'reserved': 'm', 'last_dir': 'M', 'test': 'n', 'number_of_inodes': 'N', 'creator_os': 'o', 'opts': 'O', 'revision': 'r', 'super': 'S', 'usage_type': 'T', 'uuid': 'U'}
 opts = ''
 for key in kwargs:
  if (key in kwarg_map):
   opt = kwarg_map[key]
   if (kwargs[key] == 'True'):
    opts += '-{0} '.format(opt)
   else:
    opts += '-{0} {1} '.format(opt, kwargs[key])
 cmd = 'mke2fs -F -t {0} {1}{2}'.format(fs_type, opts, device)
 out = __salt__['cmd.run'](cmd, python_shell=False).splitlines()
 ret = []
 for line in out:
  if (not line):
   continue
  elif line.startswith('mke2fs'):
   continue
  elif line.startswith('Discarding device blocks'):
   continue
  elif line.startswith('Allocating group tables'):
   continue
  elif line.startswith('Writing inode tables'):
   continue
  elif line.startswith('Creating journal'):
   continue
  elif line.startswith('Writing superblocks'):
   continue
  ret.append(line)
 return ret

def mkfs ( device , fs_type , ** kwargs ) : kwarg_map = { 'block_size' : 'b' , 'check' : 'c' , 'direct' : 'D' , 'ext_opts' : 'E' , 'fragment_size' : 'f' , 'force' : 'F' , 'blocks_per_group' : 'g' , 'number_of_groups' : 'G' , 'bytes_per_inode' : 'i' , 'inode_size' : 'I' , 'journal' : 'j' , 'journal_opts' : 'J' , 'blocks_file' : 'l' , 'label' : 'L' , 'reserved' : 'm' , 'last_dir' : 'M' , 'test' : 'n' , 'number_of_inodes' : 'N' , 'creator_os' : 'o' , 'opts' : 'O' , 'revision' : 'r' , 'super' : 'S' , 'usage_type' : 'T' , 'uuid' : 'U' } opts = '' for key in kwargs : if ( key in kwarg_map ) : opt = kwarg_map [ key ] if ( kwargs [ key ] == 'True' ) : opts += '-{0} ' . format ( opt ) else : opts += '-{0} {1} ' . format ( opt , kwargs [ key ] ) cmd = 'mke2fs -F -t {0} {1}{2}' . format ( fs_type , opts , device ) out = __salt__ [ 'cmd.run' ] ( cmd , python_shell = False ) . splitlines ( ) ret = [ ] for line in out : if ( not line ) : continue elif line . startswith ( 'mke2fs' ) : continue elif line . startswith ( 'Discarding device blocks' ) : continue elif line . startswith ( 'Allocating group tables' ) : continue elif line . startswith ( 'Writing inode tables' ) : continue elif line . startswith ( 'Creating journal' ) : continue elif line . startswith ( 'Writing superblocks' ) : continue ret . append ( line ) return ret
format filesystem example:: from fabtools .