npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

linux-mountutils

v1.0.2

Published

Utilities for mounting/unmounting drives in Linux

Downloads

71

Readme

node-linux-mountutils

Node.js wrapper for Linux mount/umount.

Usage

var mountutil = require('linux-mountutils');

isMounted(path, isDevice)

isMounted checks to see if a specific mount exists, either by mountpoint or device. It takes 2 arguments:

  • path - the mountpoint or device
  • isDevice - true means to look for a device, else a mountpoint

The function returns an object with details of the mount if it exists. ret.mounted is always a boolean that indicates whether a mount exists. If there was an error, ret.error will contain a description. If the mount is there, there will be additional fields (see below).

Example:

// See if device /dev/sda1 is mounted
var ret = mountutil.isMounted("/dev/sda1",true);
console.log(JSON.stringify(ret));
// Returns: 
//   {"mounted":true,"device":"/dev/sda1","mountpoint":"/boot","fstype":"ext2","fsopts":"rw,relatime,errors=continue"}

// See if device /dev/notarealdevice is mounted
ret = mountutil.isMounted("/dev/notarealdevice",true);
// Returns: 
//   {"mounted":false}

// See if a device is mounted at /boot
ret = mountutil.isMounted("/boot",false);
// Returns:
//    {"mounted":true,"device":"/dev/sda1","mountpoint":"/boot","fstype":"ext2","fsopts":"rw,relatime,errors=continue"}

mount(dev, path, options, callback)

mount is an asynchronous wrapper around the system mount binary. It will mount (or try to mount) a device (or network filesystem) 'dev' at the mountpoint 'path'. When it finishes, it calls the callback function with a single JSON object with result details.

Valid options:

  • fstype - filesystem type (ie. nfs, ext4, etc). Default autodetected
  • readonly - mount device read only
  • fsopts - mount options for filesystem (ie. acl,quota)
  • mountPath - path to mount binary (defaults to /bin/mount)
  • sudoPath - path to sudo binary (defaults to /usr/bin/sudo)
  • noSudo - don't use sudo when calling binaries (default: use sudo)
  • createDir - create the mountpoint 'path' if it doesn't exist (default: no)
  • dirMode - mode to use for mountpoint if createDir is true

Example:

// Mount /dev/sdc1 to /tmp/testmount
mountutil.mount("/dev/sdc1","/tmp/testmount", { "createDir": true }, function(result) {
  if (result.error) {
    // Something went wrong!
    console.log(result.error);
  } else {
    // mount succeeded - do stuff here
  }
});

umount(path, isDevice, options, callback)

umount is an asynchronous wrapper around the system umount binary. It will umount a device or mountpoint.

Arguments:

  • path - the mountpoint or device
  • isDevice - true means to look for a device, else a mountpoint
  • options - object, see below
  • callback - function, will be called with success or fail

Valid options:

  • umountPath - path to mount binary (defaults to /bin/mount)
  • sudoPath - path to sudo binary (defaults to /usr/bin/sudo)
  • noSudo - don't use sudo when calling binaries (default: use sudo)
  • removeDir - remove mountpoint after umount (default no)

Example:

// Unmount device mounted at /tmp/testmount and delete mountpoint
mountutil.umount("/tmp/testmount", false, { "removeDir": true }, function(result) {
  if (result.error) {
    // Something went wrong!
    console.log(result.error);
  } else {
    // umount succeeded - do stuff here
  }
});