lvm

package
v0.0.0-...-2be5f6d Latest Latest
Warning

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

Go to latest
Published: Jan 15, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	LVS = "lvs"
	VGS = "vgs"
	PVS = "pvs"
)
View Source
const FINDMNT = "findmnt"
View Source
const LBLK = "lsblk"

lsblk -J

{
   "blockdevices": [
      {
         "name": "nvme0n1",
         "maj:min": "259:0",
         "rm": false,
         "size": "1.9T",
         "ro": false,
         "type": "disk",
         "mountpoints": [
             null
         ],
         "children": [
            {
               "name": "nvme0n1p1",
               "maj:min": "259:1",
               "rm": false,
               "size": "512M",
               "ro": false,
               "type": "part",
               "mountpoints": [
                   "/boot/efi"
               ]
            },{
               "name": "nvme0n1p2",
               "maj:min": "259:2",
               "rm": false,
               "size": "1.9T",
               "ro": false,
               "type": "part",
               "mountpoints": [
                   null
               ],
               "children": [
                  {
                     "name": "olares--vg-swap",
                     "maj:min": "252:0",
                     "rm": false,
                     "size": "1G",
                     "ro": false,
                     "type": "lvm",
                     "mountpoints": [
                         "[SWAP]"
                     ]
                  },{
                     "name": "olares--vg-root",
                     "maj:min": "252:1",
                     "rm": false,
                     "size": "100G",
                     "ro": false,
                     "type": "lvm",
                     "mountpoints": [
                         "/"
                     ]
                  },{
                     "name": "olares--vg-data",
                     "maj:min": "252:2",
                     "rm": false,
                     "size": "1.8T",
                     "ro": false,
                     "type": "lvm",
                     "mountpoints": [
                         "/olares", "/var"
                     ]
                  }
               ]
            }
         ]
      }
   ]
}

Variables

This section is empty.

Functions

func AddNewPV

func AddNewPV(devicePath string, vg string) error

sudo pvcreate /dev/sdX1 sudo vgextend target_vg /dev/sdX1

func CommandFindMnt

func CommandFindMnt() *command[FindMntResult]

func CommandLBLK

func CommandLBLK() *command[BlkResult]

func CommandLVS

func CommandLVS() *command[LvsResult]

func CommandPVS

func CommandPVS() *command[PvsResult]

func CommandVGS

func CommandVGS() *command[VgsResult]

func DeactivateLv

func DeactivateLv(vg string) error

func DeleteDevicePartitions

func DeleteDevicePartitions(devicePath string) error

wipefs -a /dev/nvme0n1 sgdisk --zap-all /dev/nvme0n1

func ExtendLv

func ExtendLv(vg, lv string) error

lvextend -l +100%FREE "/dev/$VG_NAME/$LV_ROOT_NAME" resize2fs "/dev/$VG_NAME/$LV_ROOT_NAME"

func FindMountpointsByLvDmPath

func FindMountpointsByLvDmPath(lvDmPath string) ([]string, error)

func FindUnmountedDevices

func FindUnmountedDevices() (map[string]*BlkPart, error)

func MakePartOnDevice

func MakePartOnDevice(devicePath string) error

sudo parted /dev/sdX mklabel gpt sudo parted -a optimal /dev/sdX mkpart primary 1MiB 100%

func RemoveLv

func RemoveLv(lvpath string) error

func RemovePv

func RemovePv(pv string) error

func RemoveVg

func RemoveVg(vg string) error

Types

type BlkList

type BlkList[T any] []T

func (*BlkList[T]) UnmarshalJSON

func (s *BlkList[T]) UnmarshalJSON(b []byte) error

type BlkPart

type BlkPart struct {
	Name        string           `json:"name"`
	MajMin      string           `json:"maj:min"`
	Rm          bool             `json:"rm"`
	Size        string           `json:"size"`
	Ro          bool             `json:"ro"`
	Type        string           `json:"type"`
	Mountpoints BlkList[string]  `json:"mountpoints"`
	Children    BlkList[BlkPart] `json:"children,omitempty"`
}

type BlkResult

type BlkResult struct {
	Blockdevices BlkList[BlkPart] `json:"blockdevices"`
}

type Filesystem

type Filesystem struct {
	Target  string `json:"target"`
	Source  string `json:"source"`
	Fstype  string `json:"fstype"`
	Options string `json:"options"`
}

findmnt -n -J --target /olares

{
   "filesystems": [
      {
         "target": "/olares",
         "source": "/dev/mapper/olares--vg-data[/olares]",
         "fstype": "ext4",
         "options": "rw,relatime"
      }
   ]
}

type FindMntResult

type FindMntResult struct {
	Filesystems []Filesystem `json:"filesystems"`
}

type LvItem

type LvItem struct {
	LvName          string   `json:"lv_name"`
	VgName          string   `json:"vg_name"`
	LvAttr          string   `json:"lv_attr"`
	LvSize          string   `json:"lv_size"`
	PoolLv          string   `json:"pool_lv"`
	Origin          string   `json:"origin"`
	DataPercent     string   `json:"data_percent"`
	MetadataPercent string   `json:"metadata_percent"`
	MovePv          string   `json:"move_pv"`
	MirrorLog       string   `json:"mirror_log"`
	CopyPercent     string   `json:"copy_percent"`
	ConvertLv       string   `json:"convert_lv"`
	LvPath          string   `json:"lv_path"`
	LvDmPath        string   `json:"lv_dm_path"`
	Mountpoints     []string `json:"mountpoints"`
}
{
    "report": [
        {
            "lv": [
                {"lv_name":"data", "vg_name":"olares-vg", "lv_attr":"-wi-ao----", "lv_size":"1.76t", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""},
                {"lv_name":"root", "vg_name":"olares-vg", "lv_attr":"-wi-ao----", "lv_size":"100.00g", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""},
                {"lv_name":"swap", "vg_name":"olares-vg", "lv_attr":"-wi-ao----", "lv_size":"1.00g", "pool_lv":"", "origin":"", "data_percent":"", "metadata_percent":"", "move_pv":"", "mirror_log":"", "copy_percent":"", "convert_lv":""}
            ]
        }
    ]
}

func FindLvByVgName

func FindLvByVgName(vgName string) ([]*LvItem, error)

type LvsResult

type LvsResult struct {
	Report []struct {
		Lv []LvItem `json:"lv"`
	} `json:"report"`
}

type PvItem

type PvItem struct {
	PvName string `json:"pv_name"`
	VgName string `json:"vg_name"`
	PvFmt  string `json:"pv_fmt"`
	PvAttr string `json:"pv_attr"`
	PvSize string `json:"pv_size"`
	PvFree string `json:"pv_free"`
}
{
    "report": [
        {
            "pv": [
                {"pv_name":"/dev/nvme0n1p2", "vg_name":"olares-vg", "pv_fmt":"lvm2", "pv_attr":"a--", "pv_size":"1.86t", "pv_free":"0 "}
            ]
        }
    ]
}

type PvsResult

type PvsResult struct {
	Report []struct {
		Pv []PvItem `json:"pv"`
	} `json:"report"`
}

type VgItem

type VgItem struct {
	VgName    string `json:"vg_name"`
	PvCount   string `json:"pv_count"`
	LvCount   string `json:"lv_count"`
	SnapCount string `json:"snap_count"`
	VgAttr    string `json:"vg_attr"`
	VgSize    string `json:"vg_size"`
	VgFree    string `json:"vg_free"`
	PvName    string `json:"pv_name"`
}
{
    "report": [
        {
            "vg": [
                {"vg_name":"olares-vg", "pv_count":"1", "lv_count":"3", "snap_count":"0", "vg_attr":"wz--n-", "vg_size":"1.86t", "vg_free":"0 "}
            ]
        }
    ]
}

func FindCurrentLVM

func FindCurrentLVM() ([]*VgItem, error)

func FindVgsOnDevice

func FindVgsOnDevice(devicePaths []string) ([]*VgItem, error)

type VgsResult

type VgsResult struct {
	Report []struct {
		Vg []VgItem `json:"vg"`
	} `json:"report"`
}

Jump to

Keyboard shortcuts

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