/[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.1 - (hide annotations) (download)
Fri Sep 16 22:11:45 2005 UTC (19 years, 3 months ago) by growell
Branch: MAIN
Bug 1269099: Hack (for now) in raid conversion

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     cat /mnt/tmp/etc/fstab | sed "s/$disk\([0-9]\+\)/md\1/" > /mnt/tmp/etc/fstab.tmp
67     mv /mnt/tmp/etc/fstab.tmp /mnt/tmp/etc/fstab
68     fi
69     umount /mnt/tmp
70     fi
71     done
72     rmdir /mnt/tmp
73     mdadm --stop --scan
74     fi
75     fi

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