From: Fabian Ebner <f.ebner@proxmox.com>
To: pbs-devel@lists.proxmox.com
Subject: [pbs-devel] [PATCH proxmox-backup 1/2] mount zpools created via API under /mnt/datastore
Date: Thu, 5 Nov 2020 14:36:28 +0100 [thread overview]
Message-ID: <20201105133629.9802-1-f.ebner@proxmox.com> (raw)
as we do for other file systems
Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
---
docs/storage.rst | 2 +-
src/api2/node/disks/zfs.rs | 12 ++++++------
2 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/docs/storage.rst b/docs/storage.rst
index 8541237b..022d951e 100644
--- a/docs/storage.rst
+++ b/docs/storage.rst
@@ -57,7 +57,7 @@ create a datastore at the location ``/mnt/datastore/store1``:
You can also create a ``zpool`` with various raid levels from **Administration
-> Disks -> Zpool** in the web interface, or by using ``zpool create``. The command
below creates a mirrored ``zpool`` using two disks (``sdb`` & ``sdc``) and
-mounts it on the root directory (default):
+mounts it under ``/mnt/datastore/zpool1``:
.. code-block:: console
diff --git a/src/api2/node/disks/zfs.rs b/src/api2/node/disks/zfs.rs
index 79094012..ef7b7c67 100644
--- a/src/api2/node/disks/zfs.rs
+++ b/src/api2/node/disks/zfs.rs
@@ -243,7 +243,7 @@ pub fn zpool_details(
permission: &Permission::Privilege(&["system", "disks"], PRIV_SYS_MODIFY, false),
},
)]
-/// Create a new ZFS pool.
+/// Create a new ZFS pool. Will be mounted under '/mnt/datastore/<name>'.
pub fn create_zpool(
name: String,
devices: String,
@@ -303,10 +303,11 @@ pub fn create_zpool(
bail!("{:?} needs at least {} disks.", raidlevel, min_disks);
}
+ let mount_point = format!("/mnt/datastore/{}", &name);
+
// check if the default path does exist already and bail if it does
- // otherwise we get an error on mounting
- let mut default_path = std::path::PathBuf::from("/");
- default_path.push(&name);
+ // otherwise 'zpool create' aborts after partitioning, but before creating the pool
+ let default_path = std::path::PathBuf::from(&mount_point);
match std::fs::metadata(&default_path) {
Err(_) => {}, // path does not exist
@@ -322,7 +323,7 @@ pub fn create_zpool(
let mut command = std::process::Command::new("zpool");
- command.args(&["create", "-o", &format!("ashift={}", ashift), &name]);
+ command.args(&["create", "-o", &format!("ashift={}", ashift), "-m", &mount_point, &name]);
match raidlevel {
ZfsRaidLevel::Single => {
@@ -371,7 +372,6 @@ pub fn create_zpool(
}
if add_datastore {
- let mount_point = format!("/{}", name);
crate::api2::config::datastore::create_datastore(json!({ "name": name, "path": mount_point }))?
}
--
2.20.1
next reply other threads:[~2020-11-05 13:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-11-05 13:36 Fabian Ebner [this message]
2020-11-05 13:36 ` [pbs-devel] [PATCH proxmox-backup 2/2] bail if mount point already exists for directories Fabian Ebner
2020-11-10 8:37 ` [pbs-devel] applied: " Thomas Lamprecht
2020-11-10 8:37 ` [pbs-devel] applied: [PATCH proxmox-backup 1/2] mount zpools created via API under /mnt/datastore Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20201105133629.9802-1-f.ebner@proxmox.com \
--to=f.ebner@proxmox.com \
--cc=pbs-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox