|
20 | 20 | import cockpit from "cockpit";
|
21 | 21 | import client from "../client";
|
22 | 22 |
|
23 |
| -import { mdraid_name, validate_mdraid_name, get_available_spaces, prepare_available_spaces } from "../utils.js"; |
| 23 | +import { |
| 24 | + mdraid_name, validate_mdraid_name, get_available_spaces, prepare_available_spaces, |
| 25 | + encode_filename, decode_filename |
| 26 | +} from "../utils.js"; |
24 | 27 | import { dialog_open, TextInput, SelectOne, SelectSpaces } from "../dialog.jsx";
|
25 | 28 |
|
26 | 29 | const _ = cockpit.gettext;
|
27 | 30 |
|
| 31 | +async function mdraid_create(members, level, name, chunk, metadata_version) { |
| 32 | + if (!metadata_version || client.at_least("2.11")) { |
| 33 | + const opts = { }; |
| 34 | + if (metadata_version) |
| 35 | + opts.version = { t: "ay", v: encode_filename(metadata_version) }; |
| 36 | + await client.manager.MDRaidCreate(members, level, name, chunk, opts); |
| 37 | + } else { |
| 38 | + // Let's call mdadm explicitly if we need to set the metadata |
| 39 | + // version and UDisks2 is older than 2.11. |
| 40 | + |
| 41 | + // The member block devices are all empty already and we don't |
| 42 | + // need to wipe them. We need to wait for their D-Bus proxies |
| 43 | + // since they might have just been created by |
| 44 | + // prepare_available_spaces. |
| 45 | + |
| 46 | + const devs = []; |
| 47 | + for (const path of members) { |
| 48 | + devs.push(decode_filename((await client.wait_for(() => client.blocks[path])).PreferredDevice)); |
| 49 | + } |
| 50 | + |
| 51 | + await cockpit.spawn([ |
| 52 | + "mdadm", "--create", name, "--run", |
| 53 | + "--level=" + level, |
| 54 | + ...(chunk ? ["--chunk=" + String(chunk / 1024)] : []), |
| 55 | + "--metadata=" + metadata_version, |
| 56 | + "--raid-devices=" + String(devs.length), |
| 57 | + ...devs |
| 58 | + ], { superuser: "require", err: "message" }); |
| 59 | + } |
| 60 | +} |
| 61 | + |
28 | 62 | export function create_mdraid() {
|
29 | 63 | function mdraid_exists(name) {
|
30 | 64 | for (const p in client.mdraids) {
|
@@ -111,10 +145,14 @@ export function create_mdraid() {
|
111 | 145 | Action: {
|
112 | 146 | Title: _("Create"),
|
113 | 147 | action: function (vals) {
|
| 148 | + // When in Anaconda mode, we explicitly use metadata |
| 149 | + // version 1.0 since the default doesn't work for |
| 150 | + // things that the bootloaders need to access. |
| 151 | + // |
| 152 | + const metadata_version = client.in_anaconda_mode() ? "1.0" : null; |
| 153 | + |
114 | 154 | return prepare_available_spaces(client, vals.disks).then(paths => {
|
115 |
| - return client.manager.MDRaidCreate(paths, vals.level, |
116 |
| - vals.name, (vals.chunk || 0) * 1024, |
117 |
| - { }); |
| 155 | + return mdraid_create(paths, vals.level, vals.name, (vals.chunk || 0) * 1024, metadata_version); |
118 | 156 | });
|
119 | 157 | }
|
120 | 158 | }
|
|
0 commit comments