From 2f22a362dadf9daaadab5ed0e4bba0bf4776febf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Mon, 25 Mar 2024 10:15:52 -0400 Subject: [PATCH] incus/admin/init: Use btrfs subvol in --auto MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Closes #379 Signed-off-by: Stéphane Graber --- cmd/incus/admin_init_auto.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cmd/incus/admin_init_auto.go b/cmd/incus/admin_init_auto.go index 3b66557252c..4af4e962cd8 100644 --- a/cmd/incus/admin_init_auto.go +++ b/cmd/incus/admin_init_auto.go @@ -52,15 +52,28 @@ func (c *cmdAdminInit) RunAuto(cmd *cobra.Command, args []string, d incus.Instan return nil, fmt.Errorf(i18n.G("Storage has already been configured")) } - // Defaults - if c.flagStorageBackend == "" { - c.flagStorageBackend = "dir" + // Detect the backing filesystem. + backingFs, err := linux.DetectFilesystem(internalUtil.VarPath()) + if err != nil { + backingFs = "dir" } + // Get the possible local storage drivers. + storageDrivers := linux.AvailableStorageDrivers(internalUtil.VarPath(), server.Environment.StorageSupportedDrivers, internalUtil.PoolTypeLocal) + + // Defaults if c.flagNetworkPort == -1 { c.flagNetworkPort = ports.HTTPSDefaultPort } + if c.flagStorageBackend == "" && c.flagStoragePool == "" && backingFs == "btrfs" && slices.Contains(storageDrivers, "btrfs") { + // Use btrfs subvol if running on btrfs. + c.flagStoragePool = internalUtil.VarPath("storage-pools", "default") + c.flagStorageBackend = "btrfs" + } else if c.flagStorageBackend == "" { + c.flagStorageBackend = "dir" + } + // Fill in the node configuration config := api.InitLocalPreseed{} config.Config = map[string]string{}