--- setup_harddisks 2007-03-13 23:52:51.000000000 +0100 +++ setup_harddisks 2007-11-23 22:21:40.675121973 +0100 @@ -8,6 +8,7 @@ # This script is part of FAI (Fully Automatic Installation) # Copyright (c) 1999, 2000 by ScALE Workgroup, Universitaet zu Koeln # Copyright (c) 2000-2007 by Thomas Lange, Uni Koeln +# Copyright (c) 2007 by Maximilian Wilhelm # #********************************************************************* # This program is free software; you can redistribute it and/or modify @@ -152,7 +153,7 @@ # Variables #**************************************************** -my $Version = "version 0.43fai"; +my $Version = "version 0.43fai-xenu"; my $megabyte = 1024 * 1024; # guess # $gigabyte = 1024 * $megabyte; @@ -214,6 +215,23 @@ my $verbose = 0; $verbose = $ENV{verbose} if $ENV{verbose}; +# Get all classes in a list +my @classes = split (/\s+/, $ENV{"classes"}); + +# Check if we're running in a Xen dom-U and got partitions without +# getting a "disk"... +my $xen_dom_u = undef; +if (grep { /^XENU$/ } @classes and ! -e "/dev/xvda") { + for (my $n = 1; $n < 10; $n++) { + if (-e "/dev/xvda$n") { + $xen_dom_u = 1; + print STDERR "Detected Xen-U, will skip partitioning...\n"; + last; + } + } +} + + # Parse command line use Getopt::Std; @@ -237,13 +255,14 @@ $DOS_Alignment = "yes" if $opt_d; # track alignment # main part -&GetAllDisks; -&ParseAllConfigFiles; -&BuildNewPartTables; -&PartitionPersfdisk; -&FormatDisks; -&WriteFSTab; -&WriteFAIVariables; +GetAllDisks () unless (defined $xen_dom_u); +ParseAllConfigFiles (); +BuildNewPartTables () unless (defined $xen_dom_u); +PartitionPersfdisk () unless (defined $xen_dom_u); +FormatDisks (); +WriteFSTab (); +WriteFAIVariables (); + exit 0; #**************************************************** @@ -314,13 +333,13 @@ #**************************************************** sub ParseAllConfigFiles{ my $ConfigFileExists = 0; # no config file parsed yet - if ($ConfigFileName){ + if ($ConfigFileName) { # Read config filename &ParseConfigFile($ConfigFileName); $ConfigFileExists = 1; } else { # Read classes - foreach my $classfile (reverse split(/\s+/,$ENV{"classes"})){ + foreach my $classfile (reverse split(/\s+/,$ENV{"classes"})) { my $filename = "$ClassPath/$classfile"; if (($classfile) && (-r $filename)) { &ParseConfigFile($filename); @@ -329,7 +348,7 @@ ($ConfigFileExists) && last; } } - ($ConfigFileExists == 0) && die "ERROR: no config file for setup_harddisk found. Please check you classes and files in disk_config.\n"; + ($ConfigFileExists == 0) && die "ERROR: no config file for setup_harddisk found. Please check your classes and files in disk_config.\n"; } #**************************************************** @@ -380,7 +399,7 @@ $disk = mapdisk($2); ($DiskMountpoints{$disk}) && die "ERROR: there are more than one configuration of disk $disk.\n"; - ($DiskSize{$disk}) || die "ERROR: could not read device /dev/$disk\n"; + ($DiskSize{$disk} || defined $xen_dom_u) || die "ERROR: could not read device /dev/$disk\n"; ($test != 1) || (print "config: $disk\n"); $DiskMountpoints{$disk} = ""; $MPPrimary{"extended$disk"} = ""; @@ -503,7 +522,7 @@ # If not preserve we must know the filesystemtype ($options !~ /\b(ext2|ext3|auto|swap|dosfat16|winfat32|reiser|xfs)\b/i ) && ($options .= " auto"); } - if($size =~ /^(\d*)(\-?)(\d*)$/){ + if($size =~ /^(\d*)(\-?)(\d*)$/ && ! defined $xen_dom_u){ $Min = $1; $Min||= 1; $Max = $3;