feat: make partitions on additional disk without size occupy full disk
Fixes #2214 Signed-off-by: Andrey Smirnov <smirnov.andrey@gmail.com>
This commit is contained in:
parent
3934c78c94
commit
70a65cbb01
@ -188,6 +188,10 @@ func (t *Target) Partition(bd *blockdevice.BlockDevice) (err error) {
|
||||
default:
|
||||
typeID := "AF3DC60F-8384-7247-8E79-3D69D8477DE4"
|
||||
opts = append(opts, partition.WithPartitionType(typeID))
|
||||
|
||||
if t.Size == 0 {
|
||||
opts = append(opts, partition.WithMaximumSize(true))
|
||||
}
|
||||
}
|
||||
|
||||
part, err := pt.Add(uint64(t.Size), opts...)
|
||||
|
@ -228,6 +228,7 @@ network:
|
||||
Used to partition, format and mount additional disks.
|
||||
Since the rootfs is read only with the exception of `/var`, mounts are only valid if they are under `/var`.
|
||||
Note that the partitioning and formating is done only once, if and only if no existing partitions are found.
|
||||
If `size:` is omitted, the partition is sized to occupy full disk.
|
||||
|
||||
Type: `array`
|
||||
|
||||
@ -237,8 +238,8 @@ Examples:
|
||||
disks:
|
||||
- device: /dev/sdb
|
||||
partitions:
|
||||
- size: 10000000000
|
||||
mountpoint: /var/lib/extra
|
||||
- mountpoint: /var/lib/extra
|
||||
size: 10000000000
|
||||
|
||||
```
|
||||
|
||||
|
@ -285,6 +285,10 @@ func (gpt *GPT) Add(size uint64, setters ...interface{}) (table.Partition, error
|
||||
|
||||
if opts.MaximumSize {
|
||||
end = gpt.header.LastUsableLBA
|
||||
|
||||
if end <= start {
|
||||
return nil, fmt.Errorf("requested partition with maximum size, but no space available")
|
||||
}
|
||||
} else {
|
||||
end = start + size/gpt.lba.LogicalBlockSize
|
||||
|
||||
|
@ -121,13 +121,15 @@ type MachineConfig struct {
|
||||
// Used to partition, format and mount additional disks.
|
||||
// Since the rootfs is read only with the exception of `/var`, mounts are only valid if they are under `/var`.
|
||||
// Note that the partitioning and formating is done only once, if and only if no existing partitions are found.
|
||||
// If `size:` is omitted, the partition is sized to occupy full disk.
|
||||
// examples:
|
||||
// - |
|
||||
// disks:
|
||||
// - device: /dev/sdb
|
||||
// partitions:
|
||||
// - size: 10000000000
|
||||
// mountpoint: /var/lib/extra
|
||||
// - mountpoint: /var/lib/extra
|
||||
// size: 10000000000
|
||||
//
|
||||
MachineDisks []runtime.Disk `yaml:"disks,omitempty"` // Note: `size` is in units of bytes.
|
||||
// description: |
|
||||
// Used to provide instructions for bare-metal installations.
|
||||
|
@ -106,6 +106,16 @@ func (c *Config) Validate(mode runtime.Mode) error {
|
||||
}
|
||||
}
|
||||
|
||||
if c.MachineConfig.MachineDisks != nil {
|
||||
for _, disk := range c.MachineConfig.MachineDisks {
|
||||
for i, pt := range disk.Partitions {
|
||||
if pt.Size == 0 && i != len(disk.Partitions)-1 {
|
||||
result = multierror.Append(result, fmt.Errorf("partition for disk %q is set to occupy full disk, but it's not the last partition in the list", disk.Device))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return result.ErrorOrNil()
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user