upgrade text cdrom bootloader --location=mbr zerombr yes %post /sbin/syslogd & sleep 2 /sbin/e-smith/signal-event post-upgrade # HACK - fix selinux config perl -p -i -e 's/SELINUX=enforcing/SELINUX=disabled/' /etc/selinux/config %pre #!/bin/sh set -x # let's assume it's a SCSI system if grep -q 'sda$' /proc/partitions; then disk=sda else # No SCSI Drives is must be IDE media=`cat /proc/ide/hda/media` if [ $media == "disk" ] ; then disk=hda fi fi set $disk found=`echo $#` if [ $found -gt "0" ] ; then # Dump out current partitions sfdisk -d /dev/$disk > /tmp/oldparts # Check if we have any ext2/3 or swap partitions if grep -q 'Id=8[23]' /tmp/oldparts; then echo -n "Converting partitions to RAID..." >/dev/tty1 # Convert ext2/3 and swap partitions to raid autodetect sed 's/Id=8[32]/Id=fd/' /tmp/oldparts > /tmp/newparts # Find swap partition for future checks swap=`grep 'Id=82' /tmp/oldparts | sed "s/$disk\([0-9]\+\) :.*/md\1/"` # Loop throught partitions and convert to degraded raid1 for part in `grep 'Id=8[23]' /tmp/oldparts | sed 's/ :.*//'`; do mdpart=`echo $part | sed "s/$disk\([0-9]\+\)/md\1/"` echo -n "$part..." >/dev/tty1 mdadm --create $mdpart --run --level=1 --raid-devices=2 $part missing if [ "$mdpart" == "$swap" ]; then # Recreate swap partition mkswap $swap else # Resize ext2/3 partitions (fix superblock - part 1) resize2fs -f $mdpart fi done echo "done" >/dev/tty1 # Write out new converted partition table sfdisk --force /dev/$disk < /tmp/newparts echo "Checking filesystems on converted partitions. This may take a few minutes." >/dev/tty1 echo -n "Checking filesystems..." >/dev/tty1 mkdir /mnt/tmp for part in `grep 'Id=fd' /tmp/newparts | sed "s/$disk\([0-9]\+\) :.*/md\1/"`; do if [ "$part" != "$swap" ]; then # Resize ext2/3 partitions (fix superblock - part 2) echo -n "$part..." >/dev/tty1 e2fsck -f $part # Check for /etc/fstab on partitions and convert entries mount $part /mnt/tmp if [ -r /mnt/tmp/etc/fstab ]; then cat /mnt/tmp/etc/fstab | sed "s/$disk\([0-9]\+\)/md\1/" > /mnt/tmp/etc/fstab.tmp mv /mnt/tmp/etc/fstab.tmp /mnt/tmp/etc/fstab fi umount /mnt/tmp fi done echo "done" >/dev/tty1 rmdir /mnt/tmp mdadm --stop --scan fi fi