Change partition tables on edgeBase images to use 'LVM partitioning'. We need to ensure that LVM stages are done before LUKS stages (e.g. remove-key) or the pipelines will break (we cannot open a device when its password has changed). Add relevant tests on device_test.go plus a new test partition table on common_test.go
342 lines
8.1 KiB
Go
342 lines
8.1 KiB
Go
package osbuild
|
|
|
|
import "github.com/osbuild/osbuild-composer/internal/disk"
|
|
|
|
// This is a copy of `internal/disk/disk_test.go`
|
|
// (but ours has one more entry: "luks+lvm+clevisBind"):
|
|
var testPartitionTables = map[string]disk.PartitionTable{
|
|
|
|
"plain": {
|
|
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
|
Type: "gpt",
|
|
Partitions: []disk.Partition{
|
|
{
|
|
Size: 1048576, // 1MB
|
|
Bootable: true,
|
|
Type: disk.BIOSBootPartitionGUID,
|
|
UUID: disk.BIOSBootPartitionUUID,
|
|
},
|
|
{
|
|
Size: 209715200, // 200 MB
|
|
Type: disk.EFISystemPartitionGUID,
|
|
UUID: disk.EFISystemPartitionUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "vfat",
|
|
UUID: disk.EFIFilesystemUUID,
|
|
Mountpoint: "/boot/efi",
|
|
Label: "EFI-SYSTEM",
|
|
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 2,
|
|
},
|
|
},
|
|
{
|
|
Size: 1024000, // 500 MB
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.FilesystemDataUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Mountpoint: "/boot",
|
|
Label: "boot",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
{
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.RootPartitionUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Label: "root",
|
|
Mountpoint: "/",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
"luks": {
|
|
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
|
Type: "gpt",
|
|
Partitions: []disk.Partition{
|
|
{
|
|
Size: 1048576, // 1MB
|
|
Bootable: true,
|
|
Type: disk.BIOSBootPartitionGUID,
|
|
UUID: disk.BIOSBootPartitionUUID,
|
|
},
|
|
{
|
|
Size: 209715200, // 200 MB
|
|
Type: disk.EFISystemPartitionGUID,
|
|
UUID: disk.EFISystemPartitionUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "vfat",
|
|
UUID: disk.EFIFilesystemUUID,
|
|
Mountpoint: "/boot/efi",
|
|
Label: "EFI-SYSTEM",
|
|
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 2,
|
|
},
|
|
},
|
|
{
|
|
Size: 1024000, // 500 MB
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.FilesystemDataUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Mountpoint: "/boot",
|
|
Label: "boot",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
{
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.RootPartitionUUID,
|
|
Payload: &disk.LUKSContainer{
|
|
Label: "crypt-root",
|
|
Passphrase: "osbuild",
|
|
PBKDF: disk.Argon2id{
|
|
Memory: 32,
|
|
Iterations: 4,
|
|
Parallelism: 1,
|
|
},
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Label: "root",
|
|
Mountpoint: "/",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
"luks+lvm": {
|
|
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
|
Type: "gpt",
|
|
Partitions: []disk.Partition{
|
|
{
|
|
Size: 1048576, // 1MB
|
|
Bootable: true,
|
|
Type: disk.BIOSBootPartitionGUID,
|
|
UUID: disk.BIOSBootPartitionUUID,
|
|
},
|
|
{
|
|
Size: 209715200, // 200 MB
|
|
Type: disk.EFISystemPartitionGUID,
|
|
UUID: disk.EFISystemPartitionUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "vfat",
|
|
UUID: disk.EFIFilesystemUUID,
|
|
Mountpoint: "/boot/efi",
|
|
Label: "EFI-SYSTEM",
|
|
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 2,
|
|
},
|
|
},
|
|
{
|
|
Size: 1024000, // 500 MB
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.FilesystemDataUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Mountpoint: "/boot",
|
|
Label: "boot",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
{
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.RootPartitionUUID,
|
|
Size: 5 * 1024 * 1024 * 1024,
|
|
Payload: &disk.LUKSContainer{
|
|
Label: "crypt-root",
|
|
Passphrase: "osbuild",
|
|
PBKDF: disk.Argon2id{
|
|
Memory: 32,
|
|
Iterations: 4,
|
|
Parallelism: 1,
|
|
},
|
|
Payload: &disk.LVMVolumeGroup{
|
|
Name: "root",
|
|
Description: "root volume group",
|
|
LogicalVolumes: []disk.LVMLogicalVolume{
|
|
{
|
|
Size: 2 * 1024 * 1024 * 1024,
|
|
Name: "rootlv",
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Label: "root",
|
|
Mountpoint: "/",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
{
|
|
Size: 2 * 1024 * 1024 * 1024,
|
|
Name: "homelv",
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Label: "root",
|
|
Mountpoint: "/home",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
"luks+lvm+clevisBind": {
|
|
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
|
Type: "gpt",
|
|
Partitions: []disk.Partition{
|
|
{
|
|
Size: 1048576, // 1MB
|
|
Bootable: true,
|
|
Type: disk.BIOSBootPartitionGUID,
|
|
UUID: disk.BIOSBootPartitionUUID,
|
|
},
|
|
{
|
|
Size: 209715200, // 200 MB
|
|
Type: disk.EFISystemPartitionGUID,
|
|
UUID: disk.EFISystemPartitionUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "vfat",
|
|
UUID: disk.EFIFilesystemUUID,
|
|
Mountpoint: "/boot/efi",
|
|
Label: "EFI-SYSTEM",
|
|
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 2,
|
|
},
|
|
},
|
|
{
|
|
Size: 1024000, // 500 MB
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.FilesystemDataUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Mountpoint: "/boot",
|
|
Label: "boot",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
{
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.RootPartitionUUID,
|
|
Payload: &disk.LUKSContainer{
|
|
Label: "crypt_root",
|
|
Cipher: "cipher_null",
|
|
Passphrase: "osbuild",
|
|
PBKDF: disk.Argon2id{
|
|
Memory: 32,
|
|
Iterations: 4,
|
|
Parallelism: 1,
|
|
},
|
|
Clevis: &disk.ClevisBind{
|
|
Pin: "null",
|
|
Policy: "{}",
|
|
RemovePassphrase: true,
|
|
},
|
|
Payload: &disk.LVMVolumeGroup{
|
|
Name: "rootvg",
|
|
Description: "built with lvm2 and osbuild",
|
|
LogicalVolumes: []disk.LVMLogicalVolume{
|
|
{
|
|
Size: 9 * 1024 * 1024 * 1024, // 9 GB
|
|
Name: "rootlv",
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Label: "root",
|
|
Mountpoint: "/",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
|
|
"btrfs": {
|
|
UUID: "D209C89E-EA5E-4FBD-B161-B461CCE297E0",
|
|
Type: "gpt",
|
|
Partitions: []disk.Partition{
|
|
{
|
|
Size: 1048576, // 1MB
|
|
Bootable: true,
|
|
Type: disk.BIOSBootPartitionGUID,
|
|
UUID: disk.BIOSBootPartitionUUID,
|
|
},
|
|
{
|
|
Size: 209715200, // 200 MB
|
|
Type: disk.EFISystemPartitionGUID,
|
|
UUID: disk.EFISystemPartitionUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "vfat",
|
|
UUID: disk.EFIFilesystemUUID,
|
|
Mountpoint: "/boot/efi",
|
|
Label: "EFI-SYSTEM",
|
|
FSTabOptions: "defaults,uid=0,gid=0,umask=077,shortname=winnt",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 2,
|
|
},
|
|
},
|
|
{
|
|
Size: 1024000, // 500 MB
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.FilesystemDataUUID,
|
|
Payload: &disk.Filesystem{
|
|
Type: "xfs",
|
|
Mountpoint: "/boot",
|
|
Label: "boot",
|
|
FSTabOptions: "defaults",
|
|
FSTabFreq: 0,
|
|
FSTabPassNo: 0,
|
|
},
|
|
},
|
|
{
|
|
Type: disk.FilesystemDataGUID,
|
|
UUID: disk.RootPartitionUUID,
|
|
Size: 10 * 1024 * 1024 * 1024,
|
|
Payload: &disk.Btrfs{
|
|
Label: "rootfs",
|
|
Subvolumes: []disk.BtrfsSubvolume{
|
|
{
|
|
Size: 0,
|
|
Mountpoint: "/",
|
|
GroupID: 0,
|
|
},
|
|
{
|
|
Size: 5 * 1024 * 1024 * 1024,
|
|
Mountpoint: "/var",
|
|
GroupID: 0,
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
}
|