[lxc-devel] [lxd/master] lxd init: allow to create subvolume for btrfs pool
brauner on Github
lxc-bot at linuxcontainers.org
Mon Apr 17 19:32:38 UTC 2017
A non-text attachment was scrubbed...
Name: not available
Type: text/x-mailbox
Size: 364 bytes
Desc: not available
URL: <http://lists.linuxcontainers.org/pipermail/lxc-devel/attachments/20170417/064aa292/attachment.bin>
-------------- next part --------------
From 96db9f1489fc9e40ca4f77348874e881b5101d6c Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 17 Apr 2017 21:13:04 +0200
Subject: [PATCH 1/2] lxd init: allow to create subvolume for btrfs pool
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/main_init.go | 38 +++++++++++++++++++++++---------------
1 file changed, 23 insertions(+), 15 deletions(-)
diff --git a/lxd/main_init.go b/lxd/main_init.go
index 519f09b..72fedd9 100644
--- a/lxd/main_init.go
+++ b/lxd/main_init.go
@@ -334,23 +334,31 @@ func cmdInit() error {
}
storageDevice = askString("Path to the existing block device: ", "", deviceExists)
} else {
- st := syscall.Statfs_t{}
- err := syscall.Statfs(shared.VarPath(), &st)
- if err != nil {
- return fmt.Errorf("couldn't statfs %s: %s", shared.VarPath(), err)
- }
+ backingFs, err := filesystemDetect(shared.VarPath())
+ if err == nil && storageBackend == "btrfs" && backingFs == "btrfs" {
+ if askBool("Would you like to create a new subvolume for the BTRFS storage pool (yes/no) [default=yes]: ", "yes") {
+ storageDataset = shared.VarPath("storage-pools", storagePool)
+ }
+ } else {
- /* 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
- }
+ st := syscall.Statfs_t{}
+ err := syscall.Statfs(shared.VarPath(), &st)
+ if err != nil {
+ return fmt.Errorf("couldn't statfs %s: %s", shared.VarPath(), err)
+ }
- q := fmt.Sprintf("Size in GB of the new loop device (1GB minimum) [default=%dGB]: ", def)
- storageLoopSize = askInt(q, 1, -1, fmt.Sprintf("%d", def))
+ /* 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=%dGB]: ", def)
+ storageLoopSize = askInt(q, 1, -1, fmt.Sprintf("%d", def))
+ }
}
} else {
q := fmt.Sprintf("Name of the existing %s pool or dataset: ", strings.ToUpper(storageBackend))
From 71127bd583a245b048973ad637b7bb5fcca4e405 Mon Sep 17 00:00:00 2001
From: Christian Brauner <christian.brauner at ubuntu.com>
Date: Mon, 17 Apr 2017 21:17:20 +0200
Subject: [PATCH 2/2] lxd init: add all storage options
Signed-off-by: Christian Brauner <christian.brauner at ubuntu.com>
---
lxd/main.go | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lxd/main.go b/lxd/main.go
index 3258f3d..6901813 100644
--- a/lxd/main.go
+++ b/lxd/main.go
@@ -115,7 +115,7 @@ func run() error {
fmt.Printf(" --network-port PORT\n")
fmt.Printf(" Port to bind LXD to (default: 8443)\n")
fmt.Printf(" --storage-backend NAME\n")
- fmt.Printf(" Storage backend to use (zfs or dir, default: dir)\n")
+ fmt.Printf(" Storage backend to use (btrfs, dir, lvm or zfs, default: dir)\n")
fmt.Printf(" --storage-create-device DEVICE\n")
fmt.Printf(" Setup device based storage using DEVICE\n")
fmt.Printf(" --storage-create-loop SIZE\n")
More information about the lxc-devel
mailing list