Mount a filesystem on a remote server in ruby
linux manual

Basic Usage

require 'kanrisuru'
host = Kanrisuru::Remote::Host.new(host: '', username: 'ubuntu', keys: ['~/.ssh/id_rsa'])

result = host.mount(
  label: 'backup-disk',
  uuid: '5fbaea960d09e2ad',
  type: 'ext4',
  fs_opts: { 
    async: true, 
    auto: true, 
    group: true, 
    relatime: true, 
    owner: true 
  device: '/dev/vda2',
  directory: '/mnt/backup'



Field Type Description
label string
Human readable filesystem identifier.
uuid string
Filesystem universally unique identifier. The format of the UUID is usually a series of hex digits separated by hyphens.
fake string
Causes everything to be done except for the actual system call; if it’s not obvious, this "fakes" mounting the filesystem.
internal_only string
Don’t call the /sbin/mount.filesystem helper even if it exists.
sloppy string
Tolerate sloppy mount options rather than failing. This will ignore mount options not supported by a filesystem type. Not all filesystems support this option.
no_mtab string
Mount without writing in /etc/mtab. This is necessary for example when /etc is on a read-only filesystem.
no_canonicalize boolean
Don’t canonicalize paths. The mount command canonicalizes all paths (from the command line or fstab) by default. It is strongly recommended to not use this command-line option for normal mount operations.
type string
The filysystem type. See Fs Mount Opts for a list of all file system types.
fs_opts string
Combination of the common options, and file system specific options. See Fs Mount Opts for a list of all options.
all boolean
Mount all filesystems (of the given types) mentioned in fstab (except for those whose line contains the noauto keyword).
device string
Which device should be mounted.
directory string
The directory to mount a device.


No explicit data struct returned, only option is success?, failure?, and status to see if the program exited properly.

Exit Status

Code Description
0 Success
1 Incorrect invocation or permissions
2 System error (out of memory, cannot fork, no more loop devices)
4 Internal mount bug
8 User interrupt
16 Problems writing or locking /etc/mtab
32 Mount failure
64 Some mount failed, some succeeded

Tested On

  • Ubuntu, Debian, Centos, Fedora, Redhat, OpenSuse, SLES