README
node-linux-blockdev
Linux Bockdevice library for Node.js
API
=> Promise( blockdev.findAll(options)Array(BlockDevice)
)
List all block devices
options.probe
probe devices for PARTUUID and PTUUID
=> Promise( blockdev.findByName(options)BlockDevice
)
Find information about block device
options.deviceName
device name, e.g. loop0options.probe
probe device for PARTUUID and PTUUID
=> Promise( blockdev.findByDevicePath(options)BlockDevice
)
Find information about block device
options.devicePath
device path, e.g. /dev/loop0options.probe
probe device for PARTUUID and PTUUID
BlockDevice
=> String BlockDevice.name
Name of the block device, e.g. "loop0"
=> Number BlockDevice.sizeInSectors
Size of block device in sectors (512-byte blocks)
=> Number BlockDevice.sizeInBytes
Size of block device in bytes
BlockDevice.deviceNode.major
Major device number
BlockDevice.deviceNode.minor
Minor device number
=> String BlockDevice.PTUUID
Partition table UUID, if probed and available
=> Promise( BlockDevice.open(params)FileHandle
)
params.flags
open flags, can be either"r"
,"w"
or"r+"
=> Array( BlockDevice.partitionsPartition
)
Partition
A partition has all fields of a block device, but additionally following fields.
=> Number Partition.startInSectors
Start offset of partition inside block device in sectors (512-byte blocks)
=> Number Partition.startInBytes
Start offset of partition inside block device in bytes
=> Number Partition.partition
Partition number
=> String Partition.PARTUUID
Partition UUID, if probed and available
Minimal example
import blockdev from "linux-blockdev";
const blockDevices = await blockdev.findAll();
console.log("blockDevices =", JSON.stringify(blockDevices, null, 2));