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

zfs-utils

v1.3.0

Published

A Node.js wrapper around zfs/zpool

Downloads

25

Readme

                  __                             ___ 
                 /\ \                          /'___\
  ___     ___    \_\ \     __           ____  /\ \__/  ____
/' _ `\  / __`\  /'_` \  /'__`\ _______/\_ ,`\\ \ ,__\/',__\
/\ \/\ \/\ \L\ \/\ \L\ \/\  __//\______\/_/  /_\ \ \_/\__, `\
\ \_\ \_\ \____/\ \___,_\ \____\/______/ /\____\\ \_\\/\____/
 \/_/\/_/\/___/  \/__,_ /\/____/         \/____/ \/_/ \/___/

Build Status

node-zfs

node-zfs is a simple wrapper around the zfs and zpool commands. It enables ZFS management scripting using Node.js under SmartOS, Solaris, OpenIndiana and FreeBSD. Node-zfs is also tested successfully on Ubuntu.

Installation

Using npm:

$ npm install --save zfs

Usage

var zfs-filesystem = require('zfs');

Now you can address the zfs library as follows:

To use the zfs command implementation:

zfs-filesystem.zfs.

To use the zpool implementation:

zfs-filesystem.zpool.

Implemented commands for the ZFS tool

ZFS list

The list command lists a specific zfs dataset or all datasets. All possible options can be found inside the lib/zfs.js file.

zfs-filesystem.zfs.list(function (err, list) {
    console.log(list)
});

ZFS get

Get the parameters of a specific dataset or all datasets. All possible options can be found inside the lib/zfs.js file.

var opts = {
    name: 'my-dataset-name',
    property: 'quota'
};

zfs-filesystem.zfs.get(opts, function (err, options) {
    console.log(options);
});

ZFS set

Set a specific option for a given dataset. All possible options can be found inside the lib/zfs.js file.

var opts = {
    name: 'my-dataset-name',
    property: 'quota',
    value: '1024G'
};

zfs-filesystem.zfs.set(opts, function (err, output) {
    console.log(output);
});

ZFS Destroy

Remove a dataset from the ZFS filesystem

var opts = {
    name: 'my-dataset-name'
};

zfs-filesystem.zfs.destroy(opts, function (err, output) {
    console.log(output);
});

ZFS Create

Create a new dataset inside the ZFS filesystem. All possible options can be found inside the lib/zfs.js file.

var opts = {
    name: 'my-new-dataset-name'
};

zfs-filesystem.zfs.create(opts, function (err, output) {
    console.log(output);
});

ZFS Snapshot

Creates a snapshot with the given name. All possible options can be found inside the lib/zfs.js file.

var opts = {
    name: 'my-new-snapshot-name',
    dataset: 'my-dataset-name'
};

zfs-filesystem.zfs.snapshot(opts, function (err, output) {
    console.log(output);
});

ZFS Rollback

Rolls back to a snapshot with the given name. All possible options can be found inside the lib/zfs.js file.

var opts = {
    name: 'my-snapshot-name',
    dataset: 'my-dataset-name'
};

zfs-filesystem.zfs.rollback(opts, function (err, output) {
    console.log(output);
});

ZFS Clone

Creates a clone of the given snapshot. All possible options can be found inside the lib/zfs.js file.

var opts = {
    snapshot: 'my-snapshot-name',
    dataset: 'my-mountpoint-name'
};

zfs-filesystem.zfs.clone(opts, function (err, output) {
    console.log(output);
});

ZFS Mount

Mount the filesystem with the specified name or all filesystems. All possible options can be found inside the lib/zfs.js file.

var opts = {
    dataset: 'my-filesystem-name'
};

zfs-filesystem.zfs.mount(opts, function (err, output) {
    console.log(output);
});

ZFS Unmount

Unmount the filesystem or the mountpoint or all filesystems. All possible options can be found inside the lib/zfs.js file.

var opts = {
    name: 'my-filesystem-name',
    force: true
};

zfs-filesystem.zfs.unmount(opts, function (err, output) {
    console.log(output);
});

ZFS Send

Initiates a send of a given snapshot and returns a readable stream. All possible options can be found inside the lib/zfs.js file.

var opts = {
    snapshot : '/pool/dataset@snapshot',
    verbose : true
};

zfs-filesystem.zfs.send(opts, function (err, sendStream) {
    sendStream.on('error', function (err) {
        console.error(err);
    });

    sendStream.on('verbose', function (data) {
        console.log(data);
    });

    sendStream.pipe(process.stdout).on('end', function () {
        console.log('done');
    });
});

ZFS Receive

Initiates a receive and returns a writable stream to which a send stream may be written. All possible options can be found inside the lib/zfs.js file.

var opts = {
    dataset : '/pool2/dataset',
    verbose : true
};

zfs-filesystem.zfs.receive(opts, function (err, receiveStream) {
    receiveStream.on('error', function (err) {
        console.error(err);
    });

    receiveStream.on('verbose', function (data) {
        console.log(data);
    });

    process.stdin.pipe(receiveStream).on('end', function () {
        console.log('done');
    });
});

Implemented commands for the ZPool tool

###ZPool Create

Creates a new storage pool containing the virtual devices specified. All possible options can be found inside the lib/zpool.js file.

var opts = {
    name: 'my-datastore',
    devices: ['/dev/vdb', '/dev/vdc']
};

zfs-filesystem.zpool.create(opts, function (err, output) {
    console.log(output);
});

###ZPool Add

Adds the specified virtual devices to the given pool. All possible options can be found inside the lib/zpool.js file.

var opts = {
    name: 'my-datastore',
    devices: '/dev/vdd'
};

zfs-filesystem.zpool.add(opts, function (err, output) {
    console.log(output);
});

###ZPool Set

Sets the given property on the specified pool. See the zpool manpage for possible options and values.

var opts = {
    name: 'my-datastore',
    property: 'comment',
    value: 'Added some comment to a datastore'
};

zfs-filesystem.zpool.set(opts, function (err, output) {
    console.log(output);
});

###ZPool Destroy

Destroys the given pool, freeing up any devices for other use.

var opts = {
    name: 'my-datastore',
};

zfs-filesystem.zpool.destroy(opts, function (err, output) {
    console.log(output);
});

###ZPool List

Lists the given pools along with a health status and space usage. If no pools are specified, all pools in the system are listed.

zfs-filesystem.zpool.list(function (err, output) {
    console.log(output);
});

###ZPool Get

Retrieves the given list of properties. When no name and property specified, it shows all properties for all datastores. See the zpool manpage for possible options and values.

zfs-filesystem.zpool.get(function (err, output) {
    console.log(output);
});

License

MIT