Operating System - Linux
1819791 Members
3290 Online
109607 Solutions
New Discussion юеВ

software raid 1 (mirroring)

 
Vanja
Frequent Advisor

software raid 1 (mirroring)

Hi,

I currently have a RedHat AS 2.1 system set up with the following partitions on 1 scsi disk:

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/ida/c0d0p5 3.9G 3.1G 660M 83% /
/dev/ida/c0d0p1 50M 18M 29M 38% /boot
/dev/ida/c0d0p2 14G 8.0G 4.9G 62% /home
none 1.8G 0 1.8G 0% /dev/shm
/dev/ida/c0d0p6 3.9G 2.6G 1.1G 69% /usr
$

I have installed the raidtools rpm and would like to set up software raid 1 (mirroring) to another scsi disk (c1d0). I have used mirroring in HPUX in the past, but am some problems with linux. I have tried a few sets of procedures that I have found online but have had troubles. Does anyone have a tested method that I can use?

Thank you in advance!
15 REPLIES 15
Steven E. Protter
Exalted Contributor

Re: software raid 1 (mirroring)

Shalom,

First use fdisk -l to list the partitions on the original disk.

Then use fdisk to carefully set up partitions on the secondary disk.

http://www.linuxjournal.com/article/5653

The article above is useful for completing the task. The hairy part is properly partitioning the second disk. There will probably be some wasted disk, which you might want to set up for some unprotected scratch space.

In the above article are good links to more resources on raid 1.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Ivan Ferreira
Honored Contributor

Re: software raid 1 (mirroring)

From your command ouput, it seems that you already have a RAID or at least a raid controller.

You should use your raid controller features to enable hardware raid.

There are chances that you can do a hardware raid without loosing the data. Check your controller model and documentation.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Serviceguard for Linux
Honored Contributor

Re: software raid 1 (mirroring)

http://www.tldp.org/HOWTO/Software-RAID-HOWTO.html

Since you are on RH 2.1 you will need to use the "raidtab" functions and not "mdadm". The differences in these two should be clear in the howto. I didn't check to see that mdadm is there but I did see some of the raidtab documentation.

BTW - for RH 2.1 I believe it is difficult to set up /boot on raid. It may be documented in the howto.
Ivan Ferreira
Honored Contributor

Re: software raid 1 (mirroring)

Here is another document:

http://fy.chalmers.se/~appro/linux/HOWTO-mirror-root.html

The trick is to create the raid specifying your current "used" partition as failed, otherwise you will loose all data.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Vanja
Frequent Advisor

Re: software raid 1 (mirroring)

Thanks for the replies. I really never had any issues to mirror a non root filesystem. Its fairly straight forward.

However I am not able to mirror the / (root) filesystem. I also need some advice on setting up the boot loader. Has anyone done this before? Can I set up the raidtab file for / as md0 and run raidstart while the filesystem is mounted - or will that corrupt my root fs?? If tried to boot in recovery mode to mirror the root fs and still had issues.

If anybody has a cookbook on how to set up a mirror of all of my filesystems including / and /boot I would appreciate that.

The filesystems that I have are:

$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/ida/c0d0p5 3.9G 3.1G 660M 83% /
/dev/ida/c0d0p1 50M 18M 29M 38% /boot
/dev/ida/c0d0p2 14G 8.0G 4.9G 62% /home
none 1.8G 0 1.8G 0% /dev/shm
/dev/ida/c0d0p6 3.9G 2.6G 1.1G 69% /usr
$


Thanks!
Ivan Ferreira
Honored Contributor

Re: software raid 1 (mirroring)

The last link I posted shows how to do that, as I said, if you don't follow the right procedure, you can loss your data. Try the procedure on a test machinie, here is another document about how to migrate to RAID 1 your partitions, including root and boot:

http://trinityhome.org/misc/bootable-raid1.html
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?

Re: software raid 1 (mirroring)

Hi,

Just in case you don't realize, and as Ivan said, I saw that your scsi controler seems to be a Raid one.
/dev/ida is the linux device for Compaq/HP smart array raid controler.
Then, I don't really understand why you're trying to use software raid instead of hardware raid, even if soft raid works well.

Regards,
Lionel
Vanja
Frequent Advisor

Re: software raid 1 (mirroring)

Hi,

The scsi controller can handle raid 1, but I believe its set up as raid 0 now. This is how it was installed. If I went ahead to change to raid 1 the disk would get reformatted.

Thanks,
Vanja
Steven E. Protter
Exalted Contributor

Re: software raid 1 (mirroring)

If its a boot disk, the system will halt when you do that.

If its not a boot disk, all data will be lost.

You need to back up the data prior to trying this.

SEP
Steven E Protter
Owner of ISN Corporation
http://isnamerica.com
http://hpuxconsulting.com
Sponsor: http://hpux.ws
Twitter: http://twitter.com/hpuxlinux
Founder http://newdatacloud.com
Vanja
Frequent Advisor

Re: software raid 1 (mirroring)

I was able to mirror the devices. I can boot from both disks by changing lilo.conf and rebooting, but am still runing into some problems when I try to boot from the /dev/md0 device.

[root@linux22 root]# cat /etc/fstab
/dev/cciss/c0d1p5 / ext3 defaults
1 1
/dev/cciss/c0d1p1 /boot ext3 defaults
1 2
none /dev/pts devpts gid=5,mode=620 0 0
/dev/cciss/c0d1p2 /home ext3 defaults
1 2
none /proc proc defaults 0 0
none /dev/shm tmpfs defaults 0 0
/dev/cciss/c0d1p3 /usr ext3 defaults
1 2
/dev/cciss/c0d1p6 swap swap defaults 0 0
/dev/cdrom /mnt/cdrom iso9660 noauto,owner,kudzu,ro 0
0
/dev/fd0 /mnt/floppy auto noauto,owner,kudzu 0 0
[root@linux22 root]# cat /etc/raidtab
raiddev /dev/md0
raid-level 1
nr-raid-disks 2
chunk-size 4
persistent-superblock 1
device /dev/cciss/c0d0p5
raid-disk 0
device /dev/cciss/c0d1p5
raid-disk 1

raiddev /dev/md1
raid-level 1
nr-raid-disks 2
chunk-size 4
persistent-superblock 1
device /dev/cciss/c0d0p1
raid-disk 0
device /dev/cciss/c0d1p1
raid-disk 1

raiddev /dev/md2
raid-level 1
nr-raid-disks 2
chunk-size 4
persistent-superblock 1
device /dev/cciss/c0d0p2
raid-disk 0
device /dev/cciss/c0d1p2
raid-disk 1

raiddev /dev/md3
raid-level 1
nr-raid-disks 2
chunk-size 4
persistent-superblock 1
device /dev/cciss/c0d0p3
raid-disk 0
device /dev/cciss/c0d1p3
raid-disk 1
[root@linux22 root]#

This is my lilo.conf file:

[root@linux22 root]# more /etc/lilo.conf
prompt
timeout=50
default=linux
boot=/dev/cciss/c0d1
map=/boot/map
install=/boot/boot.b
message=/boot/message
linear

image=/boot/vmlinuz-2.4.9-e.3smp
label=linux
initrd=/boot/initrd-2.4.9-e.3smp.img
read-only
root=/dev/cciss/c0d1p5

image=/boot/vmlinuz-2.4.9-e.3
label=linux-up
initrd=/boot/initrd-2.4.9-e.3.img
read-only
root=/dev/cciss/c0d1p5
[root@linux22 root]#

I can change the c0d1 and c0d1p5 to c0d0 and c0d0p5 to boot from the other root disk. However I'm not able to boot from the /dev/md0 device when I set "root=/dev/md0"

[root@linux22 root]# lilo -V
LILO version 21.4-4
[root@linux22 root]#

Also if my system is set up to boot using lilo.conf - how can I change it to boot using grub.conf.

The grub.conf reads:

[root@linux22 root]# more /etc/grub.conf
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/cciss/c0d0p5
# initrd /initrd-version.img
#boot=/dev/cciss/c0d0
default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux Advanced Server (2.4.9-e.3smp)
root (hd0,0)
kernel /vmlinuz-2.4.9-e.3smp ro root=/dev/cciss/c0d0p5
initrd /initrd-2.4.9-e.3smp.img
title Red Hat Linux Advanced Server-up (2.4.9-e.3)
root (hd0,0)
kernel /vmlinuz-2.4.9-e.3 ro root=/dev/cciss/c0d0p5
initrd /initrd-2.4.9-e.3.img
[root@linux22 root]#

And also how would I need to modify the grub.conf to be able to boot from /dev/md0?

Any help appreciated.

Thanks
Ivan Ferreira
Honored Contributor

Re: software raid 1 (mirroring)

Probably, you need to create a new initial ram disk with mkinitrd that preload the raid modules.

Try something like this:

# mkinitrd --preload raid1 /boot/initrd-`uname -r`.img `uname -r`
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Ivan Ferreira
Honored Contributor

Re: software raid 1 (mirroring)

Also modify your lilo.conf, boot=/dev/md0 and root=/dev/md0. If you want to use grub, you must remove lilo and install grub to the boot partition with grub-install /dev/.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Vanja
Frequent Advisor

Re: software raid 1 (mirroring)

Ivan,

Thanks again for the follow up. I've already tried that route. I thnik I'm gonna give up on the sw raid - trying to boot from /dev/md0 anyway.

Since I have a DL760 I'm gonna try to reinstall the OS with the same partition sizes as the original on a HW raid 1 device (comprised of 2 x 36GB disks) and then copy the OS from the original install filesystems to the new raid 1 devices.

Since the OS/kernel level will be the same on the new image as on the old would it be safe to do a "cp -a" for all of the old filesystems - ie. /, /boot, /usr, and /home? Should I omit any files when doing this copy. I assume to omit /etc/fstab and /etc/lilo.conf - is there anything else that I should omit with the copy or anything else to watch out for since I've never done this before.

Thanks,
Vanja
Ivan Ferreira
Honored Contributor

Re: software raid 1 (mirroring)

I have never done something like that, normally, after a fresh install, I just copy the configuration files needed, not all the operating system. You can of course safely copy your data file systems, like /home. You can also copy /etc/group, passwd, shadow, etc. I think that is better if you copy only the configuration files that you need instead of copying over all the files.
Por que hacerlo dificil si es posible hacerlo facil? - Why do it the hard way, when you can do it the easy way?
Vanja
Frequent Advisor

Re: software raid 1 (mirroring)

I'm going to try to mirror one more time - this time using grub to boot from /dev/md0 (md0 is the / partition). When I create the mirror what do I need to change in grub.conf and is it OK to vi this file?

Here's the content of the grub.conf:

default=0
timeout=10
splashimage=(hd0,0)/grub/splash.xpm.gz
title Red Hat Linux Advanced Server (2.4.9-e.3smp)
root (hd0,0)
kernel /vmlinuz-2.4.9-e.3smp ro root=/dev/cciss/c0d0p5
initrd /initrd-2.4.9-e.3smp.img
title Red Hat Linux Advanced Server-up (2.4.9-e.3)
root (hd0,0)
kernel /vmlinuz-2.4.9-e.3 ro root=/dev/cciss/c0d0p5
initrd /initrd-2.4.9-e.3.img


Thanks,
Vanja