> -----Original Message----- > From: Thomas Lange [mailto:[EMAIL PROTECTED]] > Sent: Friday, January 24, 2003 5:38 AM > To: Bruce Edge > Cc: linux-fai > Subject: Re: raid support > > > Rewriting setup_harddisk is on the TODO list since a long timne (over > a year). There are som ideas about a new format for disk_config files > and there's a beta version for a perl wrapper to libparted. But since > now I had no time to work on this project, because there are other > things in fai that needs work. And setup_harddisk seems to work for > most of the people in its current state. > > I think a new setup_harddisk tools (which support for reiserfs, xfs, > lvm, raid,...) needs more than one year time for development. Please > do not start a project, when you do net feel to have a lot of time for > it. It's not worth to start something that can't be finished by you, > and nobody else will finish it for you. > > Back to you Bruce. Why can't you live with hooks right now? > > -- > Thomas >
I looked at the raid setup implemented hooks posted by Cristian posted here: http://ftp.axis.se/pub/users/cii/fai/ and it just had far too many files associated with it. I also wanted to have everything defined in one place, ie: not have to change 4 files to get a different drive map. Then I looked at setup_harddisks a bit and decided that you were right, that was a can of worms I didn't want to get into. So, I did end up with a hook solution, but by making a few assumptions and restrictions, etc, it all boils down to one hook file with no dependencies on other config files. It lets setup_harddisks format the first disk, then it copies that partition map to all the others, then generates the raidtab file, does a bunch of hacking to disk_var.sh, and fstab, and that's about it. I've only tested it with raid1, hdc and hdd, but is should be OK for other configurations too. BTW, thanks Cristian, your example made it very easy. -Bruce. #! /bin/sh -xe # # Assumptions: # Raid devices are /dev/md* # There are enough /dev/md* devices in your NFSROOT tree, default is 16, create more if needed # All logical partitions will be mapped to raid partitions, primary ones won't # the swap partition is primary # the boot partition is primary, grub can't see raid partitions, Grrr. # You remember to copy raidtab file onto target at some point ifclass IDE_RAID1_CD && { # These are fixed, should probably make them variable. DISKP=hd DISKS=(c d) NSPARES=0 RAIDLEVEL=1 RTAB=$LOGDIR/raidtab # Change logical partition types to raid autodetect # This would bugger up a logical swap partition d0=$DISKP${DISKS[0]} perl -pi -e"s/(^\D+)(\d\d|[5-9])(.+Id=)(\w*) *\w*/\1\2\3fd/" $LOGDIR/$d0.sfdisk cp $LOGDIR/$d0.sfdisk $LOGDIR/map.sfdisk # Create new partition tables for d in ${DISKS[*]}; do dx=$DISKP$d cat $LOGDIR/map.sfdisk | sed -e "s/$d0/$dx/" > $LOGDIR/$dx.sfdisk LC_ALL=C sfdisk -q /dev/$dx < $LOGDIR/$dx.sfdisk done # Fix disk_var.sh to use md instead of $DISKP perl -pi -e "s/(OOT_PARTITION=\/dev)\/$d0/\$1\/md/" $diskvar # Handle any formatting needed on physical partitions, ie: non-raid, non-swap, like /boot for pp0 in `cat $LOGDIR/$d0.sfdisk | grep -e"Id= \+[^5]$" | grep -e"size= \+[1-9]" | cut -d: -f 1 | grep -v -e"device" ` ; do for d in ${DISKS[*]}; do ppx=`echo $pp0 | sed -e "s/$d0/$DISKP$d/"` mkreiserfs -f $ppx done done # Generate raidtab file from partition table touch $RTAB # Map each logical partition to a raid device. # We skip partitions 1-4, which are the physical ones. for p1 in `cat $LOGDIR/$d0.sfdisk | grep $d0 | cut -d: -f 1 | grep -v -e device -e "hdc[0-4] "` ; do rp=`echo $p1 | sed -e "s/$d0/md/"` cat >>$RTAB <<-EOT raiddev $rp raid-level $RAIDLEVEL nr-raid-disks ${#DISKS[*]} nr-spare-disks $NSPARES chunk-size 4 persistent-superblock 1 EOT dnum=0 for d in ${DISKS[*]}; do dx=$DISKP$d # Add disk specific bit to raittab ppath=`echo $p1 | sed -e "s/$d0/$dx/"` pnum=`echo $ppath | sed -e "s/[^0-9]\+//g"` cat >>$RTAB <<-EOT device $ppath raid-disk $dnum EOT # Fix partition type to raid autodetect # if [ `sfdisk --print-id /dev/$dx $pnum | grep -v -e"Warning" -e"DOS"` -ne 82 ]; then # sfdisk --change-id /dev/$dx $pnum FD # fi let dnum=$dnum+1 done mkraid --really-force -c $RTAB $rp # Put a reiser partition on each mkreiserfs -f $rp done cp $LOGDIR/fstab $LOGDIR/fstab.save perl -pi -e "s/^(\/dev\/)(\D+)(\d\d|[5-9])/\1md\3 /" $LOGDIR/fstab }
