/[smeserver]/cdrom.image/updates/raidconvert
ViewVC logotype

Annotation of /cdrom.image/updates/raidconvert

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.5 - (hide annotations) (download)
Fri Dec 22 23:52:44 2006 UTC (17 years, 10 months ago) by slords
Branch: MAIN
Changes since 1.4: +52 -69 lines
Fix raidconvert script to not clobber data

1 growell 1.1 #!/bin/sh
2 slords 1.5
3 growell 1.1 set -x
4 slords 1.5 exec 2>&1
5 growell 1.1
6 slords 1.5 device=$(sed -n 's|.*[0-9]\s\+\([^ ]\+[^0-9]\)$|\1|p;s#.*[0-9]\s\+\(\(rd\|ida\|cciss\|i2o\)/.*[^0-9p][0-9]\+\)$#\1#p' /proc/partitions | head -1)
7 growell 1.1
8 slords 1.5 if [ -n "$device" ]
9     then
10     sfdisk -d /dev/$device > /tmp/oldparts
11     sed 's/Id=8[32]/Id=fd/' /tmp/oldparts > /tmp/newparts
12    
13     mkdir /mnt/tmp
14     for part in $(awk '/^\/dev\/.*Id=8[23]/{ print $1 }' /tmp/oldparts)
15     do
16     md=/dev/md$(echo $part | sed 's|^.*[^0-9]||')
17    
18     if grep -q "^$part .*Id=83" /tmp/oldparts
19     then
20     e2fsck -f -C0 $part
21     partsize=$(resize2fs -f $part 2>&1| sed -n 's|.* \([0-9]\+\) blocks long.*|\1|p')
22     resize2fs -fp $part $(($partsize-72))
23     fi
24    
25     mdadm -C $md -l 1 -n 2 -R $part missing
26     echo "DEVICE $part" >> /tmp/mdadm.conf
27    
28     if grep -q "^$part .*Id=83" /tmp/oldparts
29     then
30     e2fsck -f -C0 $md
31     resize2fs -fp $md
32    
33     mount $md /mnt/tmp
34     [ -r /mnt/tmp/etc/fstab ] && root=$md
35     umount /mnt/tmp
36    
37    
38     elif grep -q "^$part .*Id=82" /tmp/oldparts
39     then
40     mkswap $md
41     fi
42     done
43    
44     echo >> /tmp/mdadm.conf
45     mdadm -Es -c /tmp/mdadm.conf >> /tmp/mdadm.conf
46    
47     if [ -n "$root" ]
48     then
49     mount $root /mnt/tmp
50     sed -i "s|/dev/$device\([0-9]\+\)|/dev/md\1|" /mnt/tmp/etc/fstab
51     cp /tmp/mdadm.conf /mnt/tmp/etc/mdadm.conf
52     umount /mnt/tmp
53     fi
54     rmdir /mnt/tmp
55 growell 1.1
56 slords 1.5 mdadm --stop --scan
57 growell 1.1
58 slords 1.5 sfdisk --force /dev/$device < /tmp/newparts
59 growell 1.1 fi

admin@koozali.org
ViewVC Help
Powered by ViewVC 1.2.1 RSS 2.0 feed