Hello
<subject>: Fixed in 4.2?!
config used for testing:
disk_config disk1
#<type> <mountpoint> <size> <filesystem> <mount_options> <fs_options>
primary - 4G- - -
disk_config lvm
vg vg_system disk1.1
vg_system-root - 1G - -
first run - no LVM volumes configured
(just to set up the volumes - works without patching)
Starting setup-storage 1.4
Using config file: /var/lib/fai/config/disk_config/DISK_TYPE3_2
Executing: parted -s /dev/sda unit TiB print
Executing: parted -s /dev/sda unit B print free
Executing: parted -s /dev/sda unit chs print free
Finding all volume groups
No volume groups found
Executing: mdadm --examine --scan --verbose -c partitions
Executing: parted -s /dev/sda mklabel msdos
Executing: parted -s /dev/sda mkpart primary "" 1048576B 10737418239B
Executing: parted -s /dev/sda set 1 lvm on
Executing: pvcreate -ff -y /dev/sda1
Executing: vgcreate vg_system /dev/sda1
Executing: vgchange -a y vg_system
Executing: lvcreate -n root -L 1024 vg_system
second run - right after the first one
(this always failed)
Starting setup-storage 1.4
Using config file: /var/lib/fai/config/disk_config/DISK_TYPE3_2
Executing: parted -s /dev/sda unit TiB print
Executing: parted -s /dev/sda unit B print free
Executing: parted -s /dev/sda unit chs print free
Finding all volume groups
Finding volume group "vg_system"
Finding all volume groups
Finding volume group "vg_system"
Finding all volume groups
Finding volume group "vg_system"
Finding all volume groups
Finding volume group "vg_system"
Executing: mdadm --examine --scan --verbose -c partitions
Executing: vgchange -a n vg_system
Executing: lvremove -f vg_system/root
Executing: vgremove vg_system
Executing: pvremove /dev/sda1
Executing: wipefs -a /dev/sda1
Executing: wipefs -a /dev/sda1
Executing: parted -s /dev/sda mklabel msdos
Executing: parted -s /dev/sda mkpart primary "" 1048576B 10737418239B
Executing: parted -s /dev/sda set 1 lvm on
Executing: pvcreate -ff -y /dev/sda1
Executing: vgcreate vg_system /dev/sda1
Executing: vgchange -a y vg_system
Executing: lvcreate -n root -L 1024 vg_system
Hurray! setup-storage successfully deletes existing logical volumes and volume
groups!
There were 2 bugs which prevented this.
a) command stack was built wrongly
'cmd' => 'lvremove -f vg_system/root',
'post' => 'lv_rm_vg_system/root,self_cleared_/dev/vg_system/root',
'pre' => 'wipefs_vg_system/root'
'cmd' => 'true',
'post' => 'self_cleared_VG_vg_system',
'pre' => 'vgchange_a_n_VG_vg_system,[...],self_cleared_root'
'self_cleared_root' is wrong, it should be 'self_cleared_/dev/vg_system/root'
I think this one is related to the change in LVM 2.02.89.
b) disable volume group, then trying to wipe a logical volume
I don't know where this is coming from, but it's impossible that this could
have ever worked. As soon as you disable a volume group all related volumes
are not available any longer. Either wipe-then-disable or just-disable. I
decided for the latter.
Patch is attached, it was built against the 4.2 package. I haven't checked
what happens if you try anything funny. May need some additional adjustments
(e.g. for preserving volumes).
bye
thomas
diff -Nur vanilla/usr/share/fai/setup-storage/Commands.pm patched/usr/share/fai/setup-storage/Commands.pm
--- vanilla/usr/share/fai/setup-storage/Commands.pm 2013-09-23 00:00:00.000000000 +0200
+++ patched/usr/share/fai/setup-storage/Commands.pm 2014-06-18 16:33:35.066381624 +0200
@@ -664,11 +664,8 @@
}
}
- &FAI::push_command( "wipefs -a $vg/$lv",
- "vgchange_a_n_VG_$vg$pre_deps_cl",
- "wipefs_$vg/$lv");
- &FAI::push_command( "lvremove -f $vg/$lv",
- "wipefs_$vg/$lv",
+ &FAI::push_command( "lvremove -f /dev/$vg/$lv",
+ "vgchange_a_n_VG_$vg",
"lv_rm_$vg/$lv,self_cleared_/dev/$vg/$lv");
$vg_setup_pre .= ",lv_rm_$vg/$lv";
}
@@ -689,11 +686,8 @@
join(",self_cleared_", @{ $FAI::current_dev_children{"/dev/$vg/$lv"} })
if (defined($FAI::current_dev_children{"/dev/$vg/$lv"}) &&
scalar(@{ $FAI::current_dev_children{"/dev/$vg/$lv"} }));
- &FAI::push_command( "wipefs -a $vg/$lv",
- "vgchange_a_n_VG_$vg$pre_deps_cl",
- "wipefs_$vg/$lv");
&FAI::push_command( "lvremove -f $vg/$lv",
- "wipefs_$vg/$lv",
+ "vgchange_a_n_VG_$vg",
"lv_rm_$vg/$lv,self_cleared_/dev/$vg/$lv");
$vg_destroy_pre .= ",lv_rm_$vg/$lv";
}
diff -Nur vanilla/usr/share/fai/setup-storage/Volumes.pm patched/usr/share/fai/setup-storage/Volumes.pm
--- vanilla/usr/share/fai/setup-storage/Volumes.pm 2013-09-23 00:00:00.000000000 +0200
+++ patched/usr/share/fai/setup-storage/Volumes.pm 2014-06-18 16:27:48.000000000 +0200
@@ -422,7 +422,8 @@
&FAI::convert_unit($lv_info{$lv_name}->{lv_size} .
$lv_info{$lv_name}->{lv_size_unit});
# add entry in device tree
- push @{ $FAI::current_dev_children{"VG_$vg"} }, $lv_name;
+ my $device = _make_lv_devicename($vg, $lv_name);
+ push @{ $FAI::current_dev_children{"VG_$vg"} }, $device;
}
# store the physical volumes
@@ -647,6 +648,22 @@
}
}
+sub _make_lv_devicename {
+ my $vg = shift;
+ my $lv = shift;
+
+ # LVM 2.02.88 or below: LV Name = /dev/<vg>/<lv>
+ if ($lv =~ m{\A \Q/dev/$vg/$lv\E \z}xms) {
+ return $lv;
+ }
+ # LVM 2.02.89 or higher: LV Name = <lv>, LV Path = /dev/<vg>/<lv>
+ elsif ($lv =~ m{\A \Q$lv\E \z}xms) {
+ return "/dev/$vg/$lv";
+ }
+ else {
+ croak("Unable to generate a device name for '$lv'");
+ }
+}
1;