disk: ensure minimum size for filesystems
This commit fixes #2347 by ensuring that a minimum size of 1GB is set for all file systems. The only exception to this is the `/usr` which is set to 2GB, since this was the only mountpoint that was previously being checked.
This commit is contained in:
parent
ab306943d4
commit
62c44e86f9
5 changed files with 16 additions and 13 deletions
|
|
@ -21,7 +21,7 @@ type PartitionTable struct {
|
|||
func NewPartitionTable(basePT *PartitionTable, mountpoints []blueprint.FilesystemCustomization, imageSize uint64, rng *rand.Rand) (*PartitionTable, error) {
|
||||
newPT := basePT.Clone().(*PartitionTable)
|
||||
for _, mnt := range mountpoints {
|
||||
size := newPT.AlignUp(mnt.MinSize)
|
||||
size := newPT.AlignUp(clampFSSize(mnt.Mountpoint, mnt.MinSize))
|
||||
if path := entityPath(newPT, mnt.Mountpoint); len(path) != 0 {
|
||||
resizeEntityBranch(path, size)
|
||||
} else {
|
||||
|
|
@ -419,6 +419,21 @@ func (pt *PartitionTable) FindMountable(mountpoint string) Mountable {
|
|||
return path[0].(Mountable)
|
||||
}
|
||||
|
||||
func clampFSSize(mountpoint string, size uint64) uint64 {
|
||||
// set a minimum size of 1GB for all mountpoints
|
||||
var minSize uint64 = 1073741824
|
||||
if mountpoint == "/usr" {
|
||||
// set a minimum size of 2GB for `/usr` mountpoint
|
||||
// since this is current behaviour and the minimum
|
||||
// required to create a bootable image
|
||||
minSize = 2147483648
|
||||
}
|
||||
if minSize > size {
|
||||
return minSize
|
||||
}
|
||||
return size
|
||||
}
|
||||
|
||||
func resizeEntityBranch(path []Entity, size uint64) {
|
||||
if len(path) == 0 {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -466,9 +466,6 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
|||
|
||||
invalidMountpoints := []string{}
|
||||
for _, m := range mountpoints {
|
||||
if m.Mountpoint == "/usr" && m.MinSize < 2147483648 {
|
||||
m.MinSize = 2147483648
|
||||
}
|
||||
if !isMountpointAllowed(m.Mountpoint) {
|
||||
invalidMountpoints = append(invalidMountpoints, m.Mountpoint)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -549,9 +549,6 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
|||
|
||||
invalidMountpoints := []string{}
|
||||
for _, m := range mountpoints {
|
||||
if m.Mountpoint == "/usr" && m.MinSize < 2147483648 {
|
||||
m.MinSize = 2147483648
|
||||
}
|
||||
if !isMountpointAllowed(m.Mountpoint) {
|
||||
invalidMountpoints = append(invalidMountpoints, m.Mountpoint)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -537,9 +537,6 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
|||
|
||||
invalidMountpoints := []string{}
|
||||
for _, m := range mountpoints {
|
||||
if m.Mountpoint == "/usr" && m.MinSize < 2147483648 {
|
||||
m.MinSize = 2147483648
|
||||
}
|
||||
if !isMountpointAllowed(m.Mountpoint) {
|
||||
invalidMountpoints = append(invalidMountpoints, m.Mountpoint)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -492,9 +492,6 @@ func (t *imageType) checkOptions(customizations *blueprint.Customizations, optio
|
|||
|
||||
invalidMountpoints := []string{}
|
||||
for _, m := range mountpoints {
|
||||
if m.Mountpoint == "/usr" && m.MinSize < 2147483648 {
|
||||
m.MinSize = 2147483648
|
||||
}
|
||||
if !isMountpointAllowed(m.Mountpoint) {
|
||||
invalidMountpoints = append(invalidMountpoints, m.Mountpoint)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue