.. versionchanged:: 2016.3.2

    Remove the mount point from the fstab

    CLI Example:

    .. code-block:: bash

        salt '*' mount.rm_fstab /mnt/foo /dev/sdg
762129
def rm_fstab(name, device, config='/etc/fstab'):
    '''
    
    '''
    modified = False

    if __grains__['kernel'] == 'SunOS':
        criteria = _vfstab_entry(name=name, device=device)
    else:
        criteria = _fstab_entry(name=name, device=device)

    lines = []
    try:
        with salt.utils.files.fopen(config, 'r') as ifile:
            for line in ifile:
                line = salt.utils.stringutils.to_unicode(line)
                try:
                    if criteria.match(line):
                        modified = True
                    else:
                        lines.append(line)

                except _fstab_entry.ParseError:
                    lines.append(line)
                except _vfstab_entry.ParseError:
                    lines.append(line)

    except (IOError, OSError) as exc:
        msg = "Couldn't read from {0}: {1}"
        raise CommandExecutionError(msg.format(config, exc))

    if modified:
        try:
            with salt.utils.files.fopen(config, 'wb') as ofile:
                ofile.writelines(salt.utils.data.encode(lines))
        except (IOError, OSError) as exc:
            msg = "Couldn't write to {0}: {1}"
            raise CommandExecutionError(msg.format(config, exc))

    # Note: not clear why we always return 'True'
    # --just copying previous behavior at this point...
    return True
638322
def detect_mountpoint(self):
        

        if self.info.get('lastmountpoint'):
            return self.info.get('lastmountpoint')
        if not self.mountpoint:
            return None

        result = None
        paths = os.listdir(self.mountpoint)
        if 'grub' in paths:
            result = '/boot'
        elif 'usr' in paths and 'var' in paths and 'root' in paths:
            result = '/'
        elif 'bin' in paths and 'lib' in paths and 'local' in paths and 'src' in paths and 'usr' not in paths:
            result = '/usr'
        elif 'bin' in paths and 'lib' in paths and 'local' not in paths and 'src' in paths and 'usr' not in paths:
            result = '/usr/local'
        elif 'lib' in paths and 'local' in paths and 'tmp' in paths and 'var' not in paths:
            result = '/var'
        # elif sum(['bin' in paths, 'boot' in paths, 'cdrom' in paths, 'dev' in paths, 'etc' in paths, 'home' in paths,
        #          'lib' in paths, 'lib64' in paths, 'media' in paths, 'mnt' in paths, 'opt' in paths,
        #          'proc' in paths, 'root' in paths, 'sbin' in paths, 'srv' in paths, 'sys' in paths, 'tmp' in paths,
        #          'usr' in paths, 'var' in paths]) > 11:
        #    result = '/'

        if result:
            self.info['lastmountpoint'] = result
            if not self.info.get('label'):
                self.info['label'] = self.info['lastmountpoint']
            logger.info("Detected mountpoint as {0} based on files in volume".format(self.info['lastmountpoint']))

        return result
881175
def mount(self, mount_point=None):
        
        cmd = ["podman", "mount", self._id or self.get_id()]
        output = run_cmd(cmd, return_output=True).rstrip("\n\r")
        return output
749931
def mount(name, device, mkmnt=False, fstype='', opts='defaults', user=None, util='mount'):
    '''
    
    '''
    if util != 'mount':
        # This functionality used to live in img.mount_image
        if util == 'guestfs':
            return __salt__['guestfs.mount'](name, root=device)
        elif util == 'qemu_nbd':
            mnt = __salt__['qemu_nbd.init'](name, device)
            if not mnt:
                return False
            first = next(six.iterkeys(mnt))
            __context__['img.mnt_{0}'.format(first)] = mnt
            return first
        return False

    # Darwin doesn't expect defaults when mounting without other options
    if 'defaults' in opts and __grains__['os'] in ['MacOS', 'Darwin', 'AIX']:
        opts = None

    if isinstance(opts, six.string_types):
        opts = opts.split(',')

    if not os.path.exists(name) and mkmnt:
        __salt__['file.mkdir'](name, user=user)

    args = ''
    if opts is not None:
        lopts = ','.join(opts)
        args = '-o {0}'.format(lopts)

    if fstype:
        # use of fstype on AIX differs from typical Linux use of -t
        # functionality AIX uses -v vfsname, -t fstype mounts all with
        # fstype in /etc/filesystems
        if 'AIX' in __grains__['os']:
            args += ' -v {0}'.format(fstype)
        elif 'solaris' in __grains__['os'].lower():
            args += ' -F {0}'.format(fstype)
        else:
            args += ' -t {0}'.format(fstype)

    cmd = 'mount {0} {1} {2} '.format(args, device, name)
    out = __salt__['cmd.run_all'](cmd, runas=user, python_shell=False)
    if out['retcode']:
        return out['stderr']
    return True
1036539
function removeFile (project_dir, src) {
    var file = path.resolve(project_dir, src);
    shell.rm('-Rf', file);
}
994652
def _defragment_mountpoint(mountpoint):
    '''
    
    '''
    out = __salt__['cmd.run_all']("btrfs filesystem defragment -f {0}".format(mountpoint))
    return {
        'mount_point': mountpoint,
        'passed': not out['stderr'],
        'log': out['stderr'] or False,
        'range': False,
    }
943303
def swap(name, persist=True, config='/etc/fstab'):
    '''
    
    '''
    ret = {'name': name,
           'changes': {},
           'result': True,
           'comment': ''}
    on_ = __salt__['mount.swaps']()

    if __salt__['file.is_link'](name):
        real_swap_device = __salt__['file.readlink'](name)
        if not real_swap_device.startswith('/'):
            real_swap_device = '/dev/{0}'.format(os.path.basename(real_swap_device))
        else:
            real_swap_device = real_swap_device
    else:
        real_swap_device = name

    if real_swap_device in on_:
        ret['comment'] = 'Swap {0} already active'.format(name)
    elif __opts__['test']:
        ret['result'] = None
        ret['comment'] = 'Swap {0} is set to be activated'.format(name)
    else:
        __salt__['mount.swapon'](real_swap_device)

        on_ = __salt__['mount.swaps']()

        if real_swap_device in on_:
            ret['comment'] = 'Swap {0} activated'.format(name)
            ret['changes'] = on_[real_swap_device]
        else:
            ret['comment'] = 'Swap {0} failed to activate'.format(name)
            ret['result'] = False

    if persist:
        device_key_name = 'device'
        if 'AIX' in __grains__['os']:
            device_key_name = 'dev'
            if '/etc/fstab' == config:
                # Override default for AIX
                config = "/etc/filesystems"
            fstab_data = __salt__['mount.filesystems'](config)
        else:
            fstab_data = __salt__['mount.fstab'](config)
        if __opts__['test']:
            if name not in fstab_data and name not in [fstab_data[item]['device'] for item in fstab_data]:
                ret['result'] = None
                if name in on_:
                    ret['comment'] = ('Swap {0} is set to be added to the '
                                      'fstab and to be activated').format(name)
            return ret

        if 'none' in fstab_data:
            if fstab_data['none'][device_key_name] == name and \
               fstab_data['none']['fstype'] != 'swap':
                return ret

        if 'AIX' in __grains__['os']:
            out = None
            ret['result'] = False
            ret['comment'] += '. swap not present in /etc/filesystems on AIX.'
            return ret
        else:
            # present, new, change, bad config
            # Make sure the entry is in the fstab
            out = __salt__['mount.set_fstab']('none',
                                              name,
                                              'swap',
                                              ['defaults'],
                                              0,
                                              0,
                                              config)
        if out == 'present':
            return ret
        if out == 'new':
            ret['changes']['persist'] = 'new'
            ret['comment'] += '. Added new entry to the fstab.'
            return ret
        if out == 'change':
            ret['changes']['persist'] = 'update'
            ret['comment'] += '. Updated the entry in the fstab.'
            return ret
        if out == 'bad config':
            ret['result'] = False
            ret['comment'] += '. However, the fstab was not found.'
            return ret
    return ret
460711
def mount_point(cls, file_path):
		
		mount = None

		for mp in cls.mounts():
			mp_path = mp.path()
			if file_path.startswith(mp_path) is True:
				if mount is None or len(mount.path()) <= len(mp_path):
					mount = mp

		return mount
896308
def transit_delete_key(self, name, mount_point='transit'):
        
        url = '/v1/{0}/keys/{1}'.format(mount_point, name)
        return self._adapter.delete(url)
641429
def unmount(self, force=None, auth_no_user_interaction=None):
        """"""
        return self._M.Filesystem.Unmount(
            '(a{sv})',
            filter_opt({
                'force': ('b', force),
                'auth.no_user_interaction': ('b', auth_no_user_interaction),
            })
        )
1080197
def _clean_args(sys_argv, args):
    
    base = [x for x in sys_argv if
            x.startswith("-") or not args.datadir == os.path.abspath(os.path.expanduser(x))]
    # Remove installer only options we don't pass on
    base = [x for x in base if x not in set(["--minimize-disk"])]
    if "--nodata" in base:
        base.remove("--nodata")
    else:
        base.append("--data")
    return base
771640
def _remove_tmp_path(self, tmp_path):
        
        LOG.debug('_remove_tmp_path(%r)', tmp_path)
        if tmp_path is None and ansible.__version__ > '2.6':
            tmp_path = self._connection._shell.tmpdir  # 06f73ad578d
        if tmp_path is not None:
            self._connection.get_chain().call_no_reply(
                ansible_mitogen.target.prune_tree,
                tmp_path,
            )
        self._connection._shell.tmpdir = None
812591
def mount(self,
              fstype=None,
              options=None,
              auth_no_user_interaction=None):
        """"""
        return self._M.Filesystem.Mount(
            '(a{sv})',
            filter_opt({
                'fstype': ('s', fstype),
                'options': ('s', ','.join(options or [])),
                'auth.no_user_interaction': ('b', auth_no_user_interaction),
            })
        )
538458
def rm(self, fname=None):
        
        if fname is not None:
            return (self / fname).rm()
        try:
            self.remove()
        except OSError:
            pass
867752
def delete_mountpoints(self, paths=None, folder_ids=None):
        
        self.delete_folders(paths=paths, folder_ids=folder_ids, f_type='link')
957663
def remove(name, conf_file=default_conf):
    '''
    
    '''
    command = "logadm -f {0} -r {1}".format(conf_file, name)
    result = __salt__['cmd.run_all'](command, python_shell=False)
    if result['retcode'] != 0:
        return dict(
            Error='Failure in removing log. Possibly already removed?',
            Output=result['stderr']
        )
    return dict(Result='Success')
981014
function deleteSystemV (name, callback) {
  const filepath = `/etc/init.d/${name}`
  console.log(`Removing service on: ${filepath}`)
  fs.exists(filepath, exists => {
    if (exists) {
      fs.unlink(filepath, err => {
        if (err) {
          callback(err)
          return
        }
        callback(err, 'SystemD service removed succesfully')
      })
    } else {
      callback(`Service doesn't exists, nothing to uninstall`)
    }
  })
}