Ignore:
Timestamp:
Feb 16, 2009, 5:50:07 PM (11 years ago)
Author:
Bruno Cornec
Message:

Begining f devl branch coding nd preliminary organisation

File:
1 edited

Legend:

Unmodified
Added
Removed
  • devel/mindi/sbin/mrprepare-lvm

    r2135 r2149  
    1515use Data::Dumper;
    1616use English;
    17 use File::Basename;
    18 use File::Copy;
    19 use File::stat;
    20 use File::Temp qw(tempdir);
    21 use POSIX qw(strftime);
    2217use lib qw (lib);
    2318use ProjectBuilder::Base;
    2419use ProjectBuilder::Distribution;
     20use MondoRescue::Base;
     21use MondoRescue::Mindi::LVM;
    2522
    2623=pod
     
    149146
    150147# -------------------------------- main -----------------------------------
    151 my ($lvmver,$lvmcmd) = mr_lvm_check();
    152 
    153148# Where to send the output
    154149my $OUTPUT = \*STDOUT;
     
    165160}
    166161
     162mr_lvm_prepare($INPUT,$OUTPUT,$mrmult);
    167163
    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 
     164close($INPUT);
     165close($OUTPUT);
    215166#WriteShutdownScript
    216167mr_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.