Changeset 2149 in MondoRescue for devel/mindi/sbin
- Timestamp:
- Feb 16, 2009, 5:50:07 PM (15 years ago)
- Location:
- devel/mindi/sbin
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
devel/mindi/sbin/mindi
r2003 r2149 18 18 use File::Copy; 19 19 use File::stat; 20 use File::Temp qw(tempdir);21 use POSIX qw(strftime);22 20 use Digest::MD5 qw(md5_hex); 23 21 use lib qw (lib); 22 use POSIX qw(strftime); 24 23 use ProjectBuilder::Base; 25 24 use ProjectBuilder::Conf; 26 25 use ProjectBuilder::Distribution; 26 use ProjectBuilder::Display; 27 use MondoRescue::Mindi::LVM; 28 use MondoRescue::Base; 27 29 28 30 # Global variables … … 161 163 # 162 164 my $MINDI_VERSION = "PBVER-rPBREV"; 163 my $MINDI_PREFIX = " PBPREFIX";164 my $MINDI_CONF = " PBCONF";165 my $MINDI_LIB = " PBLIB";165 my $MINDI_PREFIX = "XXX"; 166 my $MINDI_CONF = "YYY"; 167 my $MINDI_LIB = "LLL"; 166 168 my $MINDI_SBIN = "$MINDI_PREFIX/sbin"; 167 169 my $MINDI_FDISK = "$MINDI_SBIN/parted2fdik"; … … 246 248 # LVM setup 247 249 # 248 my $LVM = "none"; 249 my $LVMCMD = ""; 250 if (-d "/proc/lvm") { 251 # Version 1 252 $LVM = "v1"; 253 } elsif (-d "/dev/mapper") { 254 # Version 2 255 $LVM = "v2"; 256 $LVMCMD = "lvm"; 257 } 258 pb_log(0,"LVM set to $LVM"); 259 pb_log(0,"-------------------------------------"); 250 my ($lvmver,$lvmcmd) = mr_lvm_check(); 251 252 pb_log(0,"LVM $lvmver command set to $lvmcmd"); 253 pb_log(0,"-------------------------------------"); 254 mr_exit(0); -
devel/mindi/sbin/mranalyze-lvm
r2119 r2149 15 15 use Data::Dumper; 16 16 use English; 17 use File::Basename;18 use File::Copy;19 use File::stat;20 use File::Temp qw(tempdir);21 use POSIX qw(strftime);22 17 use lib qw (lib); 23 18 use ProjectBuilder::Base; 24 19 use ProjectBuilder::Distribution; 20 use MondoRescue::Base; 21 use MondoRescue::Mindi::LVM; 25 22 26 23 =pod … … 137 134 138 135 # -------------------------------- main ----------------------------------- 139 my ($lvmver,$lvmcmd) = mr_lvm_check();140 141 136 # Where to send the output 142 137 my $OUTPUT = \*STDOUT; … … 146 141 } 147 142 148 print $OUTPUT "LVM:$lvmver";143 my $ret = mr_lvm_analyze($OUTPUT); 149 144 150 # Analyze the existing physical volumes 151 open(LVM,"$lvmcmd pvdisplay -c |") || mr_exit(-1,"Unable to execute $lvmcmd pvdisplay -c"); 152 while (<LVM>){153 print $OUTPUT "PV:$_";145 if ($ret == 0) { 146 pb_log(1,"No LVM handling") 147 } else { 148 pb_log(1,"LVM v$lvmver Structure Analyzed") 154 149 } 155 close(LVM); 156 157 # Analyze the existing volume groups 158 open(LVM,"$lvmcmd vgdisplay -c |") || mr_exit(-1,"Unable to execute $lvmcmd vgdisplay -c"); 159 while (<LVM>) { 160 print $OUTPUT "VG:$_"; 161 } 162 close(LVM); 163 164 # Analyze the existing logical volumes 165 open(LVM,"$lvmcmd lvdisplay -c |") || mr_exit(-1,"Unable to execute $lvmcmd lvdisplay -c"); 166 while (<LVM>) { 167 print $OUTPUT "LV:$_"; 168 } 169 close(LVM); 170 150 close($OUTPUT); 171 151 mr_exit(0,undef); 172 173 sub mr_exit {174 175 my $code = shift;176 my $msg = shift;177 178 close(OUTPUT);179 print $msg."\n" if ((defined $msg) and ($pbdebug >= 0));180 die "ERROR returned\n" if ($code < 0);181 print "No LVM handling\n" if (($code > 0) and ($pbdebug >= 0));182 exit($code);183 } -
devel/mindi/sbin/mrprepare-lvm
r2135 r2149 15 15 use Data::Dumper; 16 16 use English; 17 use File::Basename;18 use File::Copy;19 use File::stat;20 use File::Temp qw(tempdir);21 use POSIX qw(strftime);22 17 use lib qw (lib); 23 18 use ProjectBuilder::Base; 24 19 use ProjectBuilder::Distribution; 20 use MondoRescue::Base; 21 use MondoRescue::Mindi::LVM; 25 22 26 23 =pod … … 149 146 150 147 # -------------------------------- main ----------------------------------- 151 my ($lvmver,$lvmcmd) = mr_lvm_check();152 153 148 # Where to send the output 154 149 my $OUTPUT = \*STDOUT; … … 165 160 } 166 161 162 mr_lvm_prepare($INPUT,$OUTPUT,$mrmult); 167 163 168 # Generate the startup scrit needed to restore LVM conf 169 # from what is given on input 170 # Multiply by the multiplier given in input or 1 of none 171 print $OUTPUT "# Desactivate Volume Groups\n"; 172 print $OUTPUT "$lvmcmd vgchange -an\n"; 173 print $OUTPUT "\n"; 174 175 my $firsttime = 0; 176 while (<INPUT>) { 177 if (/^PV:/) { 178 my ($tag,$pvname,$vgname,$pvsize,$ipvn,$pvstat,$pvna,$lvnum,$pesize,$petot,$pefree,$pelloc) = split(/:/); 179 print $OUTPUT "# Creating Physical Volumes $pvname\n"; 180 print $OUTPUT "$lvmcmd pvcreate -ff -y -s ".$pesize*$mrmult." $pvname\n"; 181 print $OUTPUT "\n"; 182 } elsif (/^VG:/) { 183 my ($tag,$vgname,$vgaccess,$vgstat,$vgnum,$lvmaxnum,$lvnum,$ocalvinvg,$lvmaxsize,$pvmaxnum,$cnumpv,$anumpv,$vgsize,$pesize,$penum,$pealloc,$pefree,$uuid) = split(/:/); 184 if ($lvmver < 2) { 185 print $OUTPUT "# Removing device first as LVM v1 doesn't do it\n"; 186 print $OUTPUT "rm -Rf /dev/$vgname\n"; 187 } 188 $lvmaxnum = 255 if ($lvmaxnum > 256); 189 $pvmaxnum = 255 if ($pvmaxnum > 256); 190 print $OUTPUT "# Create Volume Group $vgname\n"; 191 # Pb sur pesize unite ? 192 print $OUTPUT "$lvmcmd vgcreate $vgname -p $pvmaxnum -s $pesize -l $lvmaxnum\n"; 193 print $OUTPUT "\n"; 194 } elsif (/^LV:/) { 195 if ($firsttime eq 0) { 196 print $OUTPUT "\n"; 197 print $OUTPUT "# Activate All Volume Groups\n"; 198 print $OUTPUT "$lvmcmd vgchange -ay\n"; 199 print $OUTPUT "\n"; 200 $firsttime = 1; 201 } 202 my ($tag,$lvname,$vgname,$lvaccess,$lvstat,$lvnum,$oclv,$lvsize,$leinlv,$lealloc,$allocpol,$readahead,$major,$minor) = split(/:/); 203 print $OUTPUT "# Create Logical Volume $lvname\n"; 204 print $OUTPUT "$lvmcmd lvcreate -n $lvname -L ".$lvsize*$mrmult." -r $readahead $vgname\n"; 205 #[ "$stripes" ] && output="$output -i $stripes" 206 #[ "$stripesize" ] && output="$output -I $stripesize" 207 } 208 } 209 print $OUTPUT "\n"; 210 print $OUTPUT "# Scanning again Volume Groups\n"; 211 print $OUTPUT "$lvmcmd vgscan\n"; 212 print $OUTPUT "\n"; 213 214 164 close($INPUT); 165 close($OUTPUT); 215 166 #WriteShutdownScript 216 167 mr_exit(0,"End of mrprepare-lvm"); 217 218 sub mr_exit {219 220 my $code = shift;221 my $msg = shift || "";222 223 close(OUTPUT);224 print $msg."\n";225 die "ERROR returned\n" if ($code < 0);226 print "No LVM handling\n" if ($code > 0);227 exit(0);228 }
Note:
See TracChangeset
for help on using the changeset viewer.