/[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.2 - (hide annotations) (download)
Sat Sep 17 02:01:29 2005 UTC (19 years, 1 month ago) by growell
Branch: MAIN
Changes since 1.1: +7 -2 lines
Bug 1269099: Call external script and add pop-up window - W.I.P.

1 growell 1.1 #!/bin/sh
2     set -x
3    
4     # exec 2>&1 >/tmp/raidconvert.out
5    
6     exec 2>&1
7    
8     # let's assume it's a SCSI system
9     if grep -q 'sda$' /proc/partitions; then
10     disk=sda
11     else
12     # No SCSI Drives is must be IDE
13     media=`cat /proc/ide/hda/media`
14     if [ $media == "disk" ] ; then
15     disk=hda
16     fi
17     fi
18    
19     set $disk
20     found=`echo $#`
21     if [ $found -gt "0" ] ; then
22     # Dump out current partitions
23     sfdisk -d /dev/$disk > /tmp/oldparts
24    
25     # Check if we have any ext2/3 or swap partitions
26     if grep -q 'Id=8[23]' /tmp/oldparts; then
27     echo -en "\n\nConverting partitions to RAID..." >/dev/tty3
28     # Convert ext2/3 and swap partitions to raid autodetect
29     sed 's/Id=8[32]/Id=fd/' /tmp/oldparts > /tmp/newparts
30    
31     # Find swap partition for future checks
32     swap=`grep 'Id=82' /tmp/oldparts | sed "s/$disk\([0-9]\+\) :.*/md\1/"`
33    
34     # Loop throught partitions and convert to degraded raid1
35     for part in `grep 'Id=8[23]' /tmp/oldparts | sed 's/ :.*//'`; do
36     mdpart=`echo $part | sed "s/$disk\([0-9]\+\)/md\1/"`
37    
38     echo -n "$part..." >/dev/tty3
39     mdadm --create $mdpart --run --level=1 --raid-devices=2 $part missing
40     if [ "$mdpart" == "$swap" ]; then
41     # Recreate swap partition
42     mkswap $swap
43     else
44     # Resize ext2/3 partitions (fix superblock - part 1)
45     resize2fs -f $mdpart
46     fi
47     done
48    
49     echo "done" >/dev/tty3
50    
51     # Write out new converted partition table
52     sfdisk --force /dev/$disk < /tmp/newparts
53    
54     echo -e "\nChecking filesystems on converted partitions. This may take a while." >/dev/tty3
55    
56     mkdir /mnt/tmp
57     for part in `grep 'Id=fd' /tmp/newparts | sed "s/$disk\([0-9]\+\) :.*/md\1/"`; do
58     if [ "$part" != "$swap" ]; then
59     # Resize ext2/3 partitions (fix superblock - part 2)
60     echo -e "\n\nChecking $part..." >/dev/tty3
61     e2fsck -f -C0 $part >/dev/tty3
62    
63     # Check for /etc/fstab on partitions and convert entries
64     mount $part /mnt/tmp
65     if [ -r /mnt/tmp/etc/fstab ]; then
66 growell 1.2 # XXX - FIXME - unportable hack for fstab.
67     # Only works for 6.x I suspect
68     cat /mnt/tmp/etc/fstab | sed "s/$disk\([0-9]\+\)/md\1/" | \
69     sed -e "s:LABEL=/boot1:/dev/md1:" | \
70     sed -e "s:LABEL=/:/dev/md3:" \
71     > /mnt/tmp/etc/fstab.tmp
72 growell 1.1 mv /mnt/tmp/etc/fstab.tmp /mnt/tmp/etc/fstab
73     fi
74     umount /mnt/tmp
75     fi
76     done
77     rmdir /mnt/tmp
78 growell 1.2 mdadm --stop --scan
79 growell 1.1 fi
80     fi

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