mount zpools created via API under /mnt/datastore
as we do for other file systems Signed-off-by: Fabian Ebner <f.ebner@proxmox.com>
This commit is contained in:
parent
9a3ddcea33
commit
f5d9f2534b
|
@ -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
|
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
|
-> Disks -> Zpool** in the web interface, or by using ``zpool create``. The command
|
||||||
below creates a mirrored ``zpool`` using two disks (``sdb`` & ``sdc``) and
|
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
|
.. code-block:: console
|
||||||
|
|
||||||
|
|
|
@ -243,7 +243,7 @@ pub fn zpool_details(
|
||||||
permission: &Permission::Privilege(&["system", "disks"], PRIV_SYS_MODIFY, false),
|
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(
|
pub fn create_zpool(
|
||||||
name: String,
|
name: String,
|
||||||
devices: String,
|
devices: String,
|
||||||
|
@ -303,10 +303,11 @@ pub fn create_zpool(
|
||||||
bail!("{:?} needs at least {} disks.", raidlevel, min_disks);
|
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
|
// check if the default path does exist already and bail if it does
|
||||||
// otherwise we get an error on mounting
|
// otherwise 'zpool create' aborts after partitioning, but before creating the pool
|
||||||
let mut default_path = std::path::PathBuf::from("/");
|
let default_path = std::path::PathBuf::from(&mount_point);
|
||||||
default_path.push(&name);
|
|
||||||
|
|
||||||
match std::fs::metadata(&default_path) {
|
match std::fs::metadata(&default_path) {
|
||||||
Err(_) => {}, // path does not exist
|
Err(_) => {}, // path does not exist
|
||||||
|
@ -322,7 +323,7 @@ pub fn create_zpool(
|
||||||
|
|
||||||
|
|
||||||
let mut command = std::process::Command::new("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 {
|
match raidlevel {
|
||||||
ZfsRaidLevel::Single => {
|
ZfsRaidLevel::Single => {
|
||||||
|
@ -371,7 +372,6 @@ pub fn create_zpool(
|
||||||
}
|
}
|
||||||
|
|
||||||
if add_datastore {
|
if add_datastore {
|
||||||
let mount_point = format!("/{}", name);
|
|
||||||
crate::api2::config::datastore::create_datastore(json!({ "name": name, "path": mount_point }))?
|
crate::api2::config::datastore::create_datastore(json!({ "name": name, "path": mount_point }))?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue