block

package
v0.0.0-...-9da7e33 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 10, 2026 License: AGPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const DevDiskByID = "/dev/disk/by-id"

DevDiskByID represents the system's path for disks identified by their ID.

Variables

This section is empty.

Functions

func ClearBlock

func ClearBlock(blockPath string, blockOffset int64) error

ClearBlock fully resets a block device or disk file using the most efficient mechanism available. For files, it will truncate them down to zero and back to their original size. For blocks, it will attempt a variety of discard options, validating the result with marker files and eventually fallback to full zero-ing.

An offset can be specified to only reset a part of a device.

func DiskBlockSize

func DiskBlockSize(path string) (uint32, error)

DiskBlockSize returns the physical block size of a block device.

func DiskFSType

func DiskFSType(pathName string) (string, error)

DiskFSType detects the filesystem type of the block device.

func DiskFSUUID

func DiskFSUUID(pathName string) (string, error)

DiskFSUUID returns the UUID of a filesystem on the device. An empty string is returned in case of a pristine disk.

func DiskSizeBytes

func DiskSizeBytes(blockDiskPath string) (int64, error)

DiskSizeBytes returns the size of a block disk (path can be either block device or raw file).

func GetDiskDevicePath

func GetDiskDevicePath(diskNamePrefix string, diskPathFilter devicePathFilterFunc) (string, error)

GetDiskDevicePath checks whether the disk device with a given prefix and suffix exists in /dev/disk/by-id directory. A device path is returned if the device is found, otherwise an error is returned.

func GetDisksByID

func GetDisksByID(filterPrefix string) ([]string, error)

GetDisksByID returns all disks whose ID contains the filter prefix.

func LoopDeviceSetupAlign

func LoopDeviceSetupAlign(sourcePath string) (string, error)

LoopDeviceSetupAlign creates a forced 512-byte aligned loop device.

func RefreshDiskDeviceSize

func RefreshDiskDeviceSize(ctx context.Context, diskPath string) error

RefreshDiskDeviceSize refreshes ISCSI multipath device-mapper device size.

func WaitDiskDeviceGone

func WaitDiskDeviceGone(ctx context.Context, diskPath string) bool

WaitDiskDeviceGone waits for the disk device to disappear from /dev/disk/by-id. It periodically checks for the device to disappear and returns once the device is gone. If the device does not disappear within the timeout, an error is returned.

func WaitDiskDevicePath

func WaitDiskDevicePath(ctx context.Context, diskNamePrefix string, diskPathFilter devicePathFilterFunc) (string, error)

WaitDiskDevicePath waits for the disk device to appear in /dev/disk/by-id. It periodically checks for the device to appear and returns the device path once it is found. If the device does not appear within the timeout, an error is returned.

func WaitDiskDeviceResize

func WaitDiskDeviceResize(ctx context.Context, diskPath string, newSizeBytes int64) error

WaitDiskDeviceResize waits until the disk device reflects the new size.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL