Introduction
go-libzfs currently implements basic manipulation of ZFS pools and data sets. Plan is to add more in further development, improve documentation with more examples, and add more tests. go-libzfs use libzfs C library and does not wrap OpenZFS CLI tools. Goal is to let easy using and manipulating OpenZFS form with in go, and tries to map libzfs C library in to go style package respecting golang common practice.
Note
This golang package is only used and tested on Linux.
- Version tagged as v0.1 is latest used and compatible with ZFS On Linux version 0.6.5.x
- Version tagged as v0.2 is latest used and compatible with ZFS On Linux version 0.7.x
Main features
- Creating, destroying, importing and exporting pools.
- Reading and modifying pool properties.
- Creating, destroying and renaming of filesystem datasets and volumes.
- Creating, destroying and rollback of snapshots.
- Cloning datasets and volumes.
- Reading and modifying dataset and volume properties.
- Send and receive snapshot streams
Requirements:
- OpenZFS on Linux and libzfs with development headers installed.
- Developed using go1.9
Installing
go get github.com/bicomsystems/go-libzfs
Testing
cd $GOPATH/src/github.com/bicomsystems/go-libzfs
go test
Usage example
props := make(map[ZFSProp]Property)
strSize := "1073741824"
props[DatasetPropVolsize] = Property{Value: strSize}
props[DatasetPropVolblocksize] = Property{Value: "4096"}
props[DatasetPropReservation] = Property{Value: strSize}
d, err := DatasetCreate("TESTPOOL/VOLUME1", DatasetTypeVolume, props)
if err != nil {
println(err.Error())
return
}
defer d.Close()
println("Created zfs volume TESTPOOL/VOLUME1")
Special thanks to
- Bicom Systems for supporting this little project and that way making it possible.
- OpenZFS as the main ZFS software collective.