disks

package
v1.15.0 Latest Latest
Warning

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

Go to latest
Published: Dec 12, 2024 License: Apache-2.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrRAIDNotFound = fmt.Errorf("cannot find raid device")
)

Functions

func ApplyLoopDevice added in v1.12.0

func ApplyLoopDevice(ctx context.Context, executor exec.Interface, imagePath, symlinkPath string, sizeBytes int64) (bool, error)

ApplyLoopDevice creates an image for loop device, actual loop device and symlink associated with provided name. Creation of loop device consist of following steps: 1. Creating an image file for the loop device using the provided image and sizeBytes parameters. 2. Attaching loop device to the created image file. 3. Creating a symbolic link under /dev/loops with the specified name. False is returned when there was nothing to do, meaning such loop device, image and symlink already exists.

func DeleteLoopDevice added in v1.12.0

func DeleteLoopDevice(ctx context.Context, executor exec.Interface, deviceSymlinkPath, devicePath, imagePath string) error

DeleteLoopDevice removes loop device and files associated with it like image and symlink.

func GetBlockSize

func GetBlockSize(device string, sysfsPath string) (int, error)

func GetDeviceWithName added in v1.12.0

func GetDeviceWithName(ctx context.Context, executor exec.Interface, devtmpfsPath, name string) (string, error)

GetDeviceWithName finds a device path to the raid array with given name. Because mdadm - tool used for array creation - doesn't always use the name we provide, we need to find the device using several heuristics. Different versions of mdadm behaves differently, so there are multiple steps of it. 1. Try provided name, it could be a reference to a device - if it exists, resolve and return it. 2. Try expected name and location /dev/md/name - if file exists, that's the device. 3. Try expected name and location /dev/loops/name - if file exists, resolve symlink and return the device it points to. 4. List /dev/disk/by-id/md-name-* files, if name we search for is a suffix, then the symlink points to the raid device. 5. Parse mdadm report and find the device by checking name stored in metadata. It supports passing either a name of raid device, or full /dev/md/name pattern.

func MakeFS

func MakeFS(ctx context.Context, executor exec.Interface, device string, blockSize int, fsType string) (bool, error)

func MakeRAID0

func MakeRAID0(ctx context.Context, executor exec.Interface, sysfsPath, devtmpfsPath, name string, devices []string, udevControlEnabled bool) (changed bool, err error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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