I am using RedHat 7.3 as my mail server with kernel 2.4.20-28.7. I would
like to install RAID mirroring on it without formating the whole system.
I have tried the section "Converting a non-RAID RedHat System to run on
Software RAID" from the Software-RAID-HOWTO.pdf file but I could not get it
work.
I could not get the resize2fs command done from Step-11 done on the root
filesystem ( /dev/md0) in that section.
It always says that resize2fs cannot be used on an already mounted
filesystem. I tried to copy the resize2fs to /sbin and then unmount the root
filesystem. The resize of the
root filesystem was then successful but after I rebooted the system I
received a kernel panic error saying something like could not read
superblock.
I tried to search around but could not find any suitable solution.
Please advise if anyone has done a successful RAID convertion (without
formatting).
Thanks a million
ld
There is a 'HOW-TO' doing it for Debian which I've used successfully -
but nothing in it is Debian specific from what I recall.
They repartition the new disk by copying the partition table from the
old disk, so no resizing is done.
What is the resize for?
I just read the procedure; there's no way I would carry out the
instructions as written - it involves forcing the md layer to
overwrite part of the live filesystem, which is a Really Stupid Idea (TM).
Here's what I would do to solve this problem...
*** Note: this procedure has not been tested. Don't even attempt this
*** unless you understand and agree with every step below. Backup your
*** data first and make sure your system recovery strategy actually works.
*** There are lots of missing details that depend on your particular setup -
*** you are expected to adapt the procedure to suit your system.
Suppose that the original disk with the data on is hda and the new
disk is hdc on a two IDE disk system.
0) Create a rescue floppy with grub, a kernel and initrd (if required)
that can boot the current system. Test it. The original boot loader
_will_ get trashed in this procedure so this step is not optional!
1) Copy the partition table to the second disk
sfdisk -d /dev/hda | sfdisk /dev/hdc
2) Create an /etc/raidtab file for a 2 disk mirror with hda and hdc, but
mark the partitions on the original disk, hda, as failed.
raiddev /dev/md0
raid-level 1
nr-raid-disks 2
nr-spare-disks 0
chunk-size 4
device /dev/hdc1
raid-disk 0
device /dev/hda1
failed-disk 1
# Repeat for /dev/md1 etc.
3) Run mkraid /dev/md0 (and md1 etc.) No force option should be
required if the disk is new.
4) Create filesystems on the new partitions
mke2fs -j /dev/md0
mke2fs -j /dev/md1
etc.
5) Mount the new partitions:
mkdir /mnt/newsystem
mount /dev/md0 /mnt/newsystem
tar -C / -lcf - | tar -C /mnt/newsystem -xpf -
# Repeat for other devices/partitions, eg.
mount /mnt/newsystem/usr
tar -C /usr -lcf - | tar -C /mnt/newsystem/usr -xpf -
etc. (Obviously change the device/mountpoints as required)
For the raided swap partition, don't forget to run mkswap on the md device.
6) Chroot into the raided system.
chroot /mnt/newsystem
7) Edit /etc/fstab to use the new locations, eg. /dev/md0 etc.
8) Create an initrd
mkinitrd -v /boot/initrd-<kernel-ver>.img <kernel-ver>
Red Hat will autodetect RAID based on the device names in /etc/fstab.
You should see the raid1 module listed.
9) Add the new kernel and initrd locations to /boot/grub/menu.lst
Note: the new disk is probably (hd1). Check that you have root=/dev/md0
or whatever's appropriate for your system.
10) Exit the chroot. Copy the updated /newsystem/boot/grub/menu.lst to
/boot/grub/menu.lst
11) Unmount the md devices, run /sbin/raidstop /dev/md0 etc.
12) Run fdisk and change the partition types on the new disk to FD
(Linux RAID Auto-detect).
13) Reboot into the new system.
If it doesn't boot, the old system should be largely intact. You'll
need to put the old /etc/fstab back before the system will boot fully.
14) If everything looks okay, copy the new partition table to the
original disk.
sfdisk -d /dev/hdc | sfdisk /dev/hda
15) Change the failed-disk entries to raid-disk in /etc/raidtab.
16) Run raidhotadd /dev/md0 /dev/hd1 etc. to add the mirror.
*** Note: Wait for the reconstruction of the partition ***
*** containing /boot to finish before doing the next step. ***
You can check the progress of the reconstruction with 'watch cat /proc/mdstat'
If there's a power cut now, you can boot the system from the rescue floppy you
created earlier.
17) Reinstall the bootloader.
eg. echo 'install (hd0,0)/boot/grub/stage1 (hd0) (hd0,0)/boot/grub/stage2 (hd0,0)/boot/grub/menu.lst' | grub --batch
(same for hd1)
18) Reboot.
Done.
Peter