Documentation
¶
Overview ¶
Package devicemapper is a collection of wrappers around libdevmapper / liblvm2.
Index ¶
- Constants
- func GetDeviceList() (devices []dmDevice, err error)
- func GetDeviceTable(name string) (targets []dmTarget, err error)
- type LVMError
- type LVMHandle
- func (lvm *LVMHandle) Close()
- func (lvm *LVMHandle) CreatePV(device string, size uint64) error
- func (lvm *LVMHandle) CreateVG(name string) (*VolumeGroup, error)
- func (lvm *LVMHandle) GetVGNames() (names []string)
- func (lvm *LVMHandle) GetVGUUIDs() (uuids []string)
- func (lvm *LVMHandle) OpenVG(name, mode string) (*VolumeGroup, error)
- func (lvm *LVMHandle) RemovePV(name string) error
- type LogicalVolume
- func (lv *LogicalVolume) Activate() error
- func (lv *LogicalVolume) Deactivate() error
- func (lv *LogicalVolume) GetAttrs() []byte
- func (lv *LogicalVolume) GetName() string
- func (lv *LogicalVolume) GetSize() uint64
- func (lv *LogicalVolume) GetUUID() string
- func (lv *LogicalVolume) IsActive() bool
- func (lv *LogicalVolume) Remove() error
- type PhysicalVolume
- type VolumeGroup
- func (vg *VolumeGroup) Close() error
- func (vg *VolumeGroup) CreateLVLinear(name string, size uint64) (*LogicalVolume, error)
- func (vg *VolumeGroup) Extend(device string) error
- func (vg *VolumeGroup) GetExtentCount() uint64
- func (vg *VolumeGroup) GetExtentSize() uint64
- func (vg *VolumeGroup) GetFreeExtentCount() uint64
- func (vg *VolumeGroup) GetFreeSize() uint64
- func (vg *VolumeGroup) GetMaxLV() uint64
- func (vg *VolumeGroup) GetName() string
- func (vg *VolumeGroup) GetPVCount() uint64
- func (vg *VolumeGroup) GetSequenceNum() uint64
- func (vg *VolumeGroup) GetSize() uint64
- func (vg *VolumeGroup) GetUUID() string
- func (vg *VolumeGroup) PVFromName(device string) (*PhysicalVolume, error)
- func (vg *VolumeGroup) PVFromUUID(uuid string) (*PhysicalVolume, error)
- func (vg *VolumeGroup) Remove() error
- func (vg *VolumeGroup) Write() error
Constants ¶
const ( LVM_VG_READ_ONLY = "r" LVM_VG_READ_WRITE = "w" )
const ( // Defined in <linux/loop.h> LOOP_SET_FD = 0x4c00 LOOP_CLR_FD = 0x4c01 LOOP_CTL_GET_FREE = 0x4c82 )
Variables ¶
This section is empty.
Functions ¶
func GetDeviceList ¶
func GetDeviceList() (devices []dmDevice, err error)
GetDeviceList returns a list of devmapper devices, including device number and name
func GetDeviceTable ¶
Types ¶
type LVMError ¶
type LVMError struct {
// contains filtered or unexported fields
}
LVMError represents an error from liblvm2.
type LVMHandle ¶
type LVMHandle struct {
// contains filtered or unexported fields
}
An LVMHandle is the base handle for interacting with liblvm2.
func InitLVM ¶
InitLVM returns an LVMHandle which can subsequently be used to open and create objects such as phsical volumes, volume groups, and logical volumes. Once all LVM operations have been completed, call Close() to release the handle and any associated resources.
func (*LVMHandle) Close ¶
func (lvm *LVMHandle) Close()
Close destroys an LVM handle that was created by InitLVM(). This method should be called after all volume groups have been closed, and the LVM handle should not be used again after it has been closed.
func (*LVMHandle) CreatePV ¶
CreatePV creates a physical volume on the specified absolute device name (e.g., /dev/sda1), with size `size` bytes. Size should be a multiple of 512 bytes. A size of zero bytes will use the entire device.
func (*LVMHandle) CreateVG ¶
func (lvm *LVMHandle) CreateVG(name string) (*VolumeGroup, error)
CreateVG creates a volume group object with default parameters. Upon success, other methods may be used to set non-default parameters, such as extent size. Once all parameters have been set, call Write() to commit the new VG to disk, and Close() to release the handle.
func (*LVMHandle) GetVGNames ¶
GetVGNames returns a list of names of all volume groups in the system.
func (*LVMHandle) GetVGUUIDs ¶
GetVGUUIDs returns a list of UUIDs of all volume groups in the system.
type LogicalVolume ¶
type LogicalVolume struct {
// contains filtered or unexported fields
}
A LogicalVolume represents an LVM logical volume object, and belongs to a parent volume group.
func (*LogicalVolume) Activate ¶
func (lv *LogicalVolume) Activate() error
Activate activates a logical volume, and is equivalent to the lvm command "lvchange -ay".
func (*LogicalVolume) Deactivate ¶
func (lv *LogicalVolume) Deactivate() error
Deactivate deactivates a logical volume, and is equivalent to the lvm command "lvchange -an".
func (*LogicalVolume) GetAttrs ¶
func (lv *LogicalVolume) GetAttrs() []byte
GetAttrs returns the current attributes of a logical volume, e.g.: "-wi-a-----".
func (*LogicalVolume) GetName ¶
func (lv *LogicalVolume) GetName() string
GetName returns the current name of a logical volume.
func (*LogicalVolume) GetSize ¶
func (lv *LogicalVolume) GetSize() uint64
GetSize returns the current size of a logical volume in bytes.
func (*LogicalVolume) GetUUID ¶
func (lv *LogicalVolume) GetUUID() string
GetUUID returns the current LVM UUID of a logical volume.
func (*LogicalVolume) IsActive ¶
func (lv *LogicalVolume) IsActive() bool
IsActive returns the current activation state of a logical volume.
func (*LogicalVolume) Remove ¶
func (lv *LogicalVolume) Remove() error
Remove removes a logical volume from its volume group. This function commits the change to disk and does not require calling Write().
type PhysicalVolume ¶
type PhysicalVolume struct {
// contains filtered or unexported fields
}
A PhysicalVolume represents an LVM physical volume object.
func (*PhysicalVolume) GetDevSize ¶
func (pv *PhysicalVolume) GetDevSize() uint64
GetDevSize returns the current size of a device underlying a physical volume, in bytes. This should be larger than the value returned by GetSize(), due to space occupied by metadata.
func (*PhysicalVolume) GetFree ¶
func (pv *PhysicalVolume) GetFree() uint64
GetFree returns the current unallocated space of a physical volume in bytes.
func (*PhysicalVolume) GetMDACount ¶
func (pv *PhysicalVolume) GetMDACount() uint64
GetMDACount returns the current number of metadata areas in a physical volume.
func (*PhysicalVolume) GetName ¶
func (pv *PhysicalVolume) GetName() string
GetName returns the current name of a physical volume, e.g., /dev/sda1.
func (*PhysicalVolume) GetSize ¶
func (pv *PhysicalVolume) GetSize() uint64
GetSize returns the current size of a physical volume in bytes. This should be smaller than the value returned by get GetDevSize(), due to space occupied by metadata.
func (*PhysicalVolume) GetUUID ¶
func (pv *PhysicalVolume) GetUUID() string
GetUUID returns the current LVM UUID of a physical volume.
type VolumeGroup ¶
type VolumeGroup struct {
// contains filtered or unexported fields
}
A VolumeGroup represents an LVM volume group object, can contain zero or more logical volumes, and is comprised of one or more physical volumes.
func (*VolumeGroup) Close ¶
func (vg *VolumeGroup) Close() error
Close releases a VG handle and any resources associated with it. Since many underlying liblvm2 functions only release memory when a VG handle is closed, this should be called when a VG object is no longer needed, to avoid leaking memory.
func (*VolumeGroup) CreateLVLinear ¶
func (vg *VolumeGroup) CreateLVLinear(name string, size uint64) (*LogicalVolume, error)
CreateLVLinear creates a linear logical volume. The size, specified in bytes, must be at least one sector (512 bytes), and will be rounded up to the next extent multiple. This method commits the change to disk, and does not require calling Write().
func (*VolumeGroup) Extend ¶
func (vg *VolumeGroup) Extend(device string) error
Extend adds a physical volume to a volume group. After extending a volume group, Write() must be called to commit the change to disk. Upon failure, retry the operation or release the VG handle with Close().
func (*VolumeGroup) GetExtentCount ¶
func (vg *VolumeGroup) GetExtentCount() uint64
GetExtentCount returns the current number of total extents in a volume group.
func (*VolumeGroup) GetExtentSize ¶
func (vg *VolumeGroup) GetExtentSize() uint64
GetExtentSize returns the current extent size of a volume group in bytes.
func (*VolumeGroup) GetFreeExtentCount ¶
func (vg *VolumeGroup) GetFreeExtentCount() uint64
GetFreeExtentCount returns the current number of free extents in a volume group.
func (*VolumeGroup) GetFreeSize ¶
func (vg *VolumeGroup) GetFreeSize() uint64
GetFreeSize returns the current unallocated space of a volume group in bytes.
func (*VolumeGroup) GetMaxLV ¶
func (vg *VolumeGroup) GetMaxLV() uint64
GetMaxLV returns the maximum number of logical volumes allowed in a volume group.
func (*VolumeGroup) GetName ¶
func (vg *VolumeGroup) GetName() string
GetName returns the current name of a volume group.
func (*VolumeGroup) GetPVCount ¶
func (vg *VolumeGroup) GetPVCount() uint64
GetPVCount returns the current number of physical volumes of a volume group.
func (*VolumeGroup) GetSequenceNum ¶
func (vg *VolumeGroup) GetSequenceNum() uint64
GetSequenceNum returns the current metadata sequence number of a volume group. The metadata sequence number is incrented for each metadata change. Applications may use the sequence number to determine if any LVM objects have changed from a prior query.
func (*VolumeGroup) GetSize ¶
func (vg *VolumeGroup) GetSize() uint64
GetSize returns the current size of a volume group in bytes.
func (*VolumeGroup) GetUUID ¶
func (vg *VolumeGroup) GetUUID() string
GetUUID returns the current LVM UUID of a volume group.
func (*VolumeGroup) PVFromName ¶
func (vg *VolumeGroup) PVFromName(device string) (*PhysicalVolume, error)
PVFromName returns an object representing the physical volume specified by name.
func (*VolumeGroup) PVFromUUID ¶
func (vg *VolumeGroup) PVFromUUID(uuid string) (*PhysicalVolume, error)
PVFromUUID returns an object representing the physical volume specified by UUID.
func (*VolumeGroup) Remove ¶
func (vg *VolumeGroup) Remove() error
Remove removes an underlying LVM handle to a volume group in memory, and requires calling Write() to commit the removal to disk.
func (*VolumeGroup) Write ¶
func (vg *VolumeGroup) Write() error
Write commits a volume group to disk. Upon error, retry the operation or release the VG handle with Close().