Run the update-initramfs -u command after changing mdadm.conf, to sync it into any ramdisk for use at boot time.
---- Changes since 1.480 ----
Raw disks with no partitions can now also be used as RAID members.
+Spare groups can now be created and used when creating a RAID device.
'value' => 0 } ] } );
}
+# Parse spare group
+if ($in{'group_mode'} == 1) {
+ push(@members, { 'name' => 'spare-group',
+ 'value' => $in{'group'} });
+ }
+elsif ($in{'group_mode'} == 2) {
+ $in{'newgroup'} =~ /^[a-z0-9\_]+$/i ||
+ &error($text{'create_enewgroup'});
+ push(@members, { 'name' => 'spare-group',
+ 'value' => $in{'newgroup'} });
+ }
+
&create_raid($raid);
&unlock_raid_files();
if ($err = &make_raid($raid, $in{'force'}, $in{'missing'})) {
#!/usr/local/bin/perl
-# index.cgi
# Display all RAID devices
require './raid-lib.pl';
create_edisks2=At least 2 partitions must be selected for mirroring
create_espare=Spare partition $1 cannot also be a RAID partition
create_epdisk=Parity partition cannot also be a RAID partition
+create_group=Member of spare group
+create_nogroup=None (use own spares only)
+create_oldgroup=Existing group
+create_newgroup=New group
+create_enewgroup=Missing or non-alphnumeric spare group name
view_title=RAID Device
view_header=RAID device options
view_mountmsg=Enter a directory and click this button to go to a form for mounting the RAID device, which must already contain a filesystem.
view_mountmsg2=Click this button to use this RAID device for virtual memory on your system.
view_blocks=$1 blocks
+view_sparegroup=Spare group
mkfs_title=Create Filesystem
mkfs_header2=This form allows you to build a new $2 filesystem on $1. <b>All</b> existing data will be erased!
close(MDSTAT);
push(@get_raidtab_cache, $md);
}
+
+ # Merge in info from mdadm.conf
+ local $lref = &read_file_lines($config{'mdadm'});
+ foreach my $l (@$lref) {
+ if ($l =~ /^ARRAY\s+(\S+)\s*(.*)/) {
+ local $dev = $1;
+ local %opts = map { split(/=/, $_, 2) }
+ split(/\s+/, $2);
+ local ($md) = grep { $_->{'value'} eq $dev }
+ @get_raidtab_cache;
+ if ($md) {
+ push(@{$md->{'members'}},
+ { 'name' => 'spare-group',
+ 'value' => $opts{'spare-group'} });
+ }
+ }
+ }
}
return \@get_raidtab_cache;
}
foreach $d (&find("device", $_[0]->{'members'})) {
push(@devices, $d->{'value'});
}
+ local $sg = &find_value("spare-group", $_[0]->{'members'});
local $lref = &read_file_lines($config{'mdadm'});
local $lvl = &find_value('raid-level', $_[0]->{'members'});
$lvl = $lvl =~ /^\d+$/ ? "raid$lvl" : $lvl;
push(@$lref, "DEVICE ".join(" ", @devices));
push(@$lref, "ARRAY $_[0]->{'value'} level=$lvl devices=".
- join(",", @devices));
+ join(",", @devices).
+ ($sg ? " spare-group=$sg" : ""));
&flush_file_lines();
&update_initramfs();
}
&ui_yesno_radio("missing", 0));
}
+# Spare-group name option
+if ($raid_mode eq 'mdadm') {
+ @opts = ( [ 0, $text{'create_nogroup'} ] );
+ @groups = ( );
+ foreach $c (@$conf) {
+ $sg = &find_value("spare-group", $c->{'members'});
+ push(@groups, $sg) if ($sg);
+ }
+ if (@groups) {
+ push(@opts, [ 1, $text{'create_oldgroup'},
+ &ui_select("group", undef, \@groups) ]);
+ }
+ push(@opts, [ 2, $text{'create_newgroup'},
+ &ui_textbox("newgroup", undef, 30) ]);
+ print &ui_table_row($text{'create_group'},
+ &ui_radio_table("group_mode", 0, \@opts, 1));
+ }
+
# Force creation
print &ui_table_row($text{'create_force'},
&ui_yesno_radio("force", 0));
if ($sp) {
print &ui_table_row($text{'view_spares'}, $sp);
}
+
+# Display spare group, if any
+$sg = &find_value("spare-group", $raid->{'members'});
+if ($sg) {
+ print &ui_table_row($text{'view_sparegroup'}, "<tt>$sg</tt>");
+ }
+
print &ui_table_end();
print &ui_hr();