The following pull request was submitted through Github. It can be accessed and reviewed at: https://github.com/lxc/lxd/pull/2364
This e-mail was sent by the LXC bot, direct replies will not reach the author unless they happen to be subscribed to this list. === Description (from pull-request) === Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com>
From 00e6eaef89029d19043c6183a650911f06450155 Mon Sep 17 00:00:00 2001 From: Tycho Andersen <tycho.ander...@canonical.com> Date: Mon, 12 Sep 2016 10:37:51 -0600 Subject: [PATCH] init: use more intelligent logic for partition sizing Signed-off-by: Tycho Andersen <tycho.ander...@canonical.com> --- lxd/main.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lxd/main.go b/lxd/main.go index 8a3e9c8..b9041f4 100644 --- a/lxd/main.go +++ b/lxd/main.go @@ -829,7 +829,23 @@ func cmdInit() error { storageDevice = askString("Path to the existing block device: ", "", deviceExists) storageMode = "device" } else { - storageLoopSize = askInt("Size in GB of the new loop device (1GB minimum) [default=10]: ", 1, -1, "10") + st := syscall.Statfs_t{} + err := syscall.Statfs(shared.VarPath(), &st) + if err != nil { + return fmt.Errorf("couldn't statfs %s: %s", shared.VarPath(), err) + } + + /* choose 15 GB < x < 100GB, where x is 20% of the disk size */ + def := uint64(st.Frsize) * st.Blocks / (1024 * 1024 * 1024) / 5 + if def > 100 { + def = 100 + } + if def < 15 { + def = 15 + } + + q := fmt.Sprintf("Size in GB of the new loop device (1GB minimum) [default=%d]: ", def) + storageLoopSize = askInt(q, 1, -1, fmt.Sprintf("%d", def)) storageMode = "loop" } } else {
_______________________________________________ lxc-devel mailing list lxc-devel@lists.linuxcontainers.org http://lists.linuxcontainers.org/listinfo/lxc-devel