salt.modules.mount

Salt module to manage Unix mounts and the fstab file

salt.modules.mount.active(extended=False)

List the active mounts.

CLI Example:

salt '*' mount.active
salt.modules.mount.automaster(config='/etc/auto_salt')

List the contents of the auto master

CLI Example:

salt '*' mount.automaster
salt.modules.mount.delete_mount_cache(real_name)

New in version 2018.3.0.

Provide information if the path is mounted

CLI Example:

salt '*' mount.delete_mount_cache /mnt/share
salt.modules.mount.filesystems(config='/etc/filesystems')

New in version 2018.3.3.

List the contents of the filesystems

CLI Example:

salt '*' mount.filesystems
salt.modules.mount.fstab(config='/etc/fstab')

Changed in version 2016.3.2.

List the contents of the fstab

CLI Example:

salt '*' mount.fstab
salt.modules.mount.get_device_from_path(path)

Return the underlying device for a specified path.

New in version 3006.0.

path

The path for the function to evaluate.

CLI Example:

salt '*' mount.get_device_from_path /
salt.modules.mount.get_mount_from_path(path)

Return the mount providing a specified path.

New in version 3006.0.

path

The path for the function to evaluate.

CLI Example:

salt '*' mount.get_mount_from_path /opt/some/nested/path
salt.modules.mount.is_fuse_exec(cmd)

Returns true if the command passed is a fuse mountable application.

CLI Example:

salt '*' mount.is_fuse_exec sshfs
salt.modules.mount.is_mounted(name)

New in version 2014.7.0.

Provide information if the path is mounted

CLI Example:

salt '*' mount.is_mounted /mnt/share
salt.modules.mount.mount(name, device=False, mkmnt=False, fstype='', opts='defaults', user=None, util='mount')

Mount a device

CLI Example:

salt '*' mount.mount /mnt/foo /dev/sdz1 True
salt.modules.mount.read_mount_cache(name)

New in version 2018.3.0.

Provide information if the path is mounted

CLI Example:

salt '*' mount.read_mount_cache /mnt/share
salt.modules.mount.remount(name, device, mkmnt=False, fstype='', opts='defaults', user=None)

Attempt to remount a device, if the device is not already mounted, mount is called

CLI Example:

salt '*' mount.remount /mnt/foo /dev/sdz1 True
salt.modules.mount.rm_automaster(name, device, config='/etc/auto_salt')

Remove the mount point from the auto_master

CLI Example:

salt '*' mount.rm_automaster /mnt/foo /dev/sdg
salt.modules.mount.rm_filesystems(name, device, config='/etc/filesystems')

New in version 2018.3.3.

Remove the mount point from the filesystems

CLI Example:

salt '*' mount.rm_filesystems /mnt/foo /dev/sdg
salt.modules.mount.rm_fstab(name, device, config='/etc/fstab')

Changed in version 2016.3.2.

Remove the mount point from the fstab

CLI Example:

salt '*' mount.rm_fstab /mnt/foo /dev/sdg
salt.modules.mount.rm_vfstab(name, device, config='/etc/vfstab')

New in version 2016.3.2.

Remove the mount point from the vfstab

CLI Example:

salt '*' mount.rm_vfstab /mnt/foo /device/c0t0d0p0
salt.modules.mount.set_automaster(name, device, fstype, opts='', config='/etc/auto_salt', test=False, not_change=False, **kwargs)

Verify that this mount is represented in the auto_salt, change the mount to match the data passed, or add the mount if it is not present.

CLI Example:

salt '*' mount.set_automaster /mnt/foo /dev/sdz1 ext4
salt.modules.mount.set_filesystems(name, device, vfstype, opts='-', mount='true', config='/etc/filesystems', test=False, match_on='auto', not_change=False, **kwargs)

New in version 2018.3.3.

Verify that this mount is represented in the filesystems, change the mount to match the data passed, or add the mount if it is not present on AIX

If the entry is found via match_on and not_change is True, the current line will be preserved.

Provide information if the path is mounted

Parameters:
  • name -- The name of the mount point where the device is mounted.

  • device -- The device that is being mounted.

  • vfstype -- The file system that is used (AIX has two fstypes, fstype and vfstype - similar to Linux fstype)

  • opts -- Additional options used when mounting the device.

  • mount -- Mount if not mounted, default True.

  • config -- Configuration file, default /etc/filesystems.

  • match -- File systems type to match on, default auto

CLI Example:

salt '*' mount.set_filesystems /mnt/foo /dev/sdz1 jfs2
salt.modules.mount.set_fstab(name, device, fstype, opts='defaults', dump=0, pass_num=0, config='/etc/fstab', test=False, match_on='auto', not_change=False, **kwargs)

Verify that this mount is represented in the fstab, change the mount to match the data passed, or add the mount if it is not present.

If the entry is found via match_on and not_change is True, the current line will be preserved.

CLI Example:

salt '*' mount.set_fstab /mnt/foo /dev/sdz1 ext4
salt.modules.mount.set_vfstab(name, device, fstype, opts='-', device_fsck='-', pass_fsck='-', mount_at_boot='yes', config='/etc/vfstab', test=False, match_on='auto', not_change=False, **kwargs)

New in version 2016.3.2.

Verify that this mount is represented in the fstab, change the mount to match the data passed, or add the mount if it is not present.

If the entry is found via match_on and not_change is True, the current line will be preserved.

CLI Example:

salt '*' mount.set_vfstab /mnt/foo /device/c0t0d0p0 ufs
salt.modules.mount.swapoff(name)

Deactivate a named swap mount

Changed in version 2016.3.2.

CLI Example:

salt '*' mount.swapoff /root/swapfile
salt.modules.mount.swapon(name, priority=None)

Activate a swap disk

Changed in version 2016.3.2.

CLI Example:

salt '*' mount.swapon /root/swapfile
salt.modules.mount.swaps()

Return a dict containing information on active swap

Changed in version 2016.3.2.

CLI Example:

salt '*' mount.swaps
salt.modules.mount.umount(name, device=None, user=None, util='mount', lazy=False)

Attempt to unmount a device by specifying the directory it is mounted on

CLI Example:

salt '*' mount.umount /mnt/foo

New in version 2015.5.0.

salt '*' mount.umount /mnt/foo /dev/xvdc1
salt.modules.mount.vfstab(config='/etc/vfstab')

New in version 2016.3.2.

List the contents of the vfstab

CLI Example:

salt '*' mount.vfstab
salt.modules.mount.write_mount_cache(real_name, device, mkmnt, fstype, mount_opts)

New in version 2018.3.0.

Provide information if the path is mounted

Parameters:
  • real_name -- The real name of the mount point where the device is mounted.

  • device -- The device that is being mounted.

  • mkmnt -- Whether or not the mount point should be created.

  • fstype -- The file system that is used.

  • mount_opts -- Additional options used when mounting the device.

Returns:

Boolean if message was sent successfully.

CLI Example:

salt '*' mount.write_mount_cache /mnt/share /dev/sda1 False ext4 defaults,nosuid