support for mkfs.ext2 w/ badblock search
[bootmanager.git] / source / steps / InstallPartitionDisks.py
index 02245c2..f36e2e9 100644 (file)
@@ -50,7 +50,7 @@ import utils
 import BootServerRequest
 import compatibility
 
-
+import ModelOptions
 
 def Run( vars, log ):
     """
@@ -61,8 +61,6 @@ def Run( vars, log ):
     TEMP_PATH                somewhere to store what we need to run
     ROOT_SIZE                the size of the root logical volume
     SWAP_SIZE                the size of the swap partition
-    ALPINA_SERVER_DIR        directory on the boot servers containing alpina
-                             scripts and support files
     BOOT_CD_VERSION          A tuple of the current bootcd version
     
     Sets the following variables:
@@ -94,14 +92,12 @@ def Run( vars, log ):
         if SWAP_SIZE == "" or SWAP_SIZE == 0:
             raise ValueError, "SWAP_SIZE invalid"
 
-        ALPINA_SERVER_DIR= vars["ALPINA_SERVER_DIR"]
-        if ALPINA_SERVER_DIR == None:
-            raise ValueError, "ALPINA_SERVER_DIR"
-
         BOOT_CD_VERSION= vars["BOOT_CD_VERSION"]
         if BOOT_CD_VERSION == "":
             raise ValueError, "BOOT_CD_VERSION"
 
+        NODE_MODEL_OPTIONS= vars["NODE_MODEL_OPTIONS"]
+
     except KeyError, var:
         raise BootManagerException, "Missing variable in vars: %s\n" % var
     except ValueError, var:
@@ -189,11 +185,24 @@ def Run( vars, log ):
     # make swap
     utils.sysexec( "mkswap %s" % PARTITIONS["swap"], log )
 
-    # make root file system
-    utils.sysexec( "mkfs.ext2 -j %s" % PARTITIONS["root"], log )
-
-    # make vservers file system
-    utils.sysexec( "mkfs.ext2 -m 0 -j %s" % PARTITIONS["vservers"], log )
+    # check if badhd option has been set
+    option = ''
+    txt = ''
+    if NODE_MODEL_OPTIONS & ModelOptions.BADHD:
+        option = '-c'
+        txt = " with bad block search enabled, which may take a while"
+    
+    # filesystems partitions names and their corresponding
+    # reserved-blocks-percentages
+    filesystems = {"root":5,"vservers":0}
+
+    # make the file systems
+    for fs in filesystems.keys():
+        # get the reserved blocks percentage
+        rbp = filesystems[fs]
+        devname = PARTITIONS[fs]
+        log.write("formatting %s partition (%s)%s.\n" % (fs,devname,txt))
+        utils.sysexec( "mkfs.ext2 -q %s -m %d -j %s" % (option,rbp,devname), log )
 
     # save the list of block devices in the log
     log.write( "Block devices used (in lvm):\n" )
@@ -310,7 +319,10 @@ def create_lvm_physical_volume( part_path, vars, log ):
     try:
         # again, wipe any old data, this time on the partition
         utils.sysexec( "dd if=/dev/zero of=%s bs=512 count=1" % part_path, log )
-        utils.sysexec( "pvcreate -fy %s" % part_path, log )
+        ### patch Thierry Parmentelat, required on some hardware
+        import time
+        time.sleep(1)
+        utils.sysexec( "pvcreate -ffy %s" % part_path, log )
     except BootManagerException, e:
         log.write( "create_lvm_physical_volume failed.\n" )
         return 0