[lxc-devel] [lxd/master] init: use more intelligent logic for partition sizing
tych0 on Github
lxc-bot at linuxcontainers.org
Mon Sep 12 16:38:39 UTC 2016
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 361 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20160912/f97c6802/attachment.bin>
-------------- next part --------------
From 00e6eaef89029d19043c6183a650911f06450155 Mon Sep 17 00:00:00 2001
From: Tycho Andersen <tycho.andersen at 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.andersen at 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 {
More information about the lxc-devel
mailing list