1
0
mirror of https://github.com/rancher/os.git synced 2025-09-01 23:04:41 +00:00

Added LVM and LUKS

This commit is contained in:
Bernard Wagner
2018-10-31 15:36:59 +02:00
parent 6b41747e6d
commit 900c57b8c9
5 changed files with 83 additions and 0 deletions

View File

@@ -119,6 +119,28 @@ func Blkid(label string) (deviceName, deviceType string, err error) {
return
}
func BlkidType(deviceType string) (deviceNames []string, err error) {
// Not all blkid's have `blkid -L label (see busybox/alpine)
cmd := exec.Command("blkid")
cmd.Stderr = os.Stderr
out, err := cmd.Output()
if err != nil {
return nil, err
}
r := bytes.NewReader(out)
s := bufio.NewScanner(r)
for s.Scan() {
line := s.Text()
if !strings.Contains(line, `TYPE="`+deviceType+`"`) {
continue
}
d := strings.Split(line, ":")
deviceName := d[0]
deviceNames = append(deviceNames, deviceName)
}
return deviceNames, nil
}
// GetHypervisor tries to detect if we're running in a VM, and returns a string for its type
func GetHypervisor() string {
return cpuid.CPU.HypervisorName