anchor.diff:                      $post_logical_volumes.append("echo '/dev/mapper/%s-%s %s xfs defaults 0 0' >> /mnt/sysimage/etc/fstab" % ($space_id, $volume_name, $volume_mount))
                   #end if
               #end if
  -            ##
  +            #######################################
           #end for
       #end for
       ##
  -    ## Cleaning disks
  -    #if $clearpart_drives
  -        #set $clearpart_drives_string = ','.join(list($clearpart_drives))
  -echo "clearpart --initlabel --all --drives=$clearpart_drives_string" >> /tmp/partition.ks
  -        #for $d in list($clearpart_drives)
  -/usr/sbin/parted -s "/dev/$d" mklabel gpt
  -        #end for
  -    #end if
       ##
  -    ## Creating bare partitions
  +    #######################################
  +    ## Actual cleaning drives
  +    #######################################
  +    #for $d in $clearpart_drives
  +dd if=/dev/zero of=/dev/$d bs=1M count=10
  +    #end for
  +    #######################################
  +    ## Actual configuring boot partitions
  +    #######################################
  +    #for $parted in $parted_commands
  +$parted
  +    #end for
  +    #######################################
  +    ## Actual creating plain partitions
  +    #######################################
       #for $partition in $partitions
   echo "$partition" >> /tmp/partition.ks
       #end for
  -    ##
  -    ## Creating physical volumes
  +    #######################################
  +    ## Actual creating physical volumes
  +    #######################################
       #for $pv in $physical_volumes
   echo "$pv" >> /tmp/partition.ks
       #end for
  -    ##
  -    ## Creating volume groups
  +    #######################################
  +    ## Actual creating volume groups
  +    #######################################
       #for $volgroup in $volume_groups.keys()
           #set $ks_pvs = " ".join($volume_groups.get($volgroup))
   echo "volgroup $volgroup $ks_pvs" >> /tmp/partition.ks
       #end for
  -    ##
  -    ## Creating logical volumes
  +    #######################################
  +    ## Actual creating raid volumes
  +    #######################################
  +    #for $raid in $raid_volumes
  +echo "$raidgroup" >> /tmp/partition.ks
  +    #end for
  +    #for $raidmount in $raid_groups.keys()
  +        #set $ks_raids = " ".join($raid_groups.get($raidmount))
  +        #set $md_name = "md%d" % $mdnum
  +echo "raid $raidmount --device $md_name --fstype ext3 --level=RAID1 $ks_raids" >> /tmp/partition.ks
  +        #set $mdnum += 1
  +    #end for
  +    #######################################
  +    ## Actual creating logical volumes
  +    #######################################
       #for $lv in $logical_volumes
   echo "$lv" >> /tmp/partition.ks
       #end for
  -    ##
  -    ## Creating logical volumes in %post section
  +    #######################################
  +    ## Actual creating logical volumes in %post section
  +    #######################################
   echo "%post --nochroot" > /tmp/post_partition.ks
       #for $lv in $post_logical_volumes
   echo "$lv" >> /tmp/post_partition.ks
       #end for
  -    ##
  +    #######################################
  +    ## Actual bootloader installing
  +    #######################################
  +    #set $drives = ",".join($grub_drives)
  +echo "bootloader --location=mbr --driveorder=$drives --append=' biosdevname=0 crashkernel=none'" > /tmp/bootloader.ks
       ##
   #end if
  
positive.code: echo > /tmp/partition.ks
  #import json
  #if $getVar("ks_spaces","{}") != "{}"
      ##
      #set $j = $getVar("ks_spaces","[]")
      #set $spaces = $json.loads($j)
      #set $clearpart_drives = $set([])
      #set $physical_volumes = []
      #set $partitions = []
      #set $volume_groups = {}
      #set $logical_volumes = []
      #set $post_logical_volumes = []
      #set $pvnum = 0
      ##
      #for $space in $spaces
          #set $space_id = $space.get("id")
          #set $space_type = $space.get("type")
          #set $space_volumes = $space.get("volumes")
          ##
          ## Adding disk to clearpart list of drives
          #if $space_type == "disk"
              $clearpart_drives.add($space_id)
          #end if
          ##
          #for $volume in $space_volumes
              #set $volume_id = $volume.get("id")
              #set $volume_type = $volume.get("type")
              ##
              ## Parsing volume groups and physical volumes
              #if $space_type == "disk" and $volume_type == "pv"
                  #set $volume_vg = $volume.get("vg")
                  #set $volume_size = $int($volume.get("size") or 0) / 1024 ** 2
                  #set $volume_name = "pv.%03d" % $pvnum
                  #if $volume_size > 0
                      $physical_volumes.append("partition %s --size=%s --ondisk=%s" % ($volume_name, $volume_size, $space_id))
  
negative.code:                     #set $pvnum += 1
                  #end if
              #end if
              #######################################
              ## Configuring raid partitions
              #######################################
              #if $space_type == "disk" and $volume_type == "raid"
                  #set $volume_mount = $volume.get("mount")
                  #set $volume_size = $int($volume.get("size") or 0)
                  #set $volume_name = "raid.%03d" % $raidnum
                  #if $volume_size > 0
                      $raid_volumes.append("partition %s --size=%s --ondisk=%s" % ($volume_name, $volume_size, $space_id))
                      #if not $raid_groups.get($volume_mount)
                          #set $raid_groups[$volume_mount] = [$volume_name]
                      #else
                          $raid_groups[$volume_mount].append($volume_name)
                      #end if
                      #set $raidnum += 1
                  #end if
              #end if
              #######################################
              ## Configuring logical volumes
              #######################################
              #if $space_type == "vg" and $volume_type == "lv"
                  #set $volume_mount = $volume.get("mount")
                  ## getting volume size in MB
                  #set $volume_size = $int($volume.get("size") or 0)
                  #set $volume_name = $volume.get("name")
                  ##
                  ## Anaconda has hard coded limitation of 16TB for ext3/4 and xfs filesystems (the only filesystems we are supposed to use).
  