LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Fedora (https://www.linuxquestions.org/questions/fedora-35/)
-   -   how to use RAID in linux (https://www.linuxquestions.org/questions/fedora-35/how-to-use-raid-in-linux-412510/)

abhis_mail2002 02-07-2006 03:28 AM

how to use RAID in linux
 
I want RAID ti be implementd in linux.i have got a site http://www.tldp.org/HOWTO/Software-RAID-HOWTO-5.html
which gives explanation on raid,i am new to this concept,my boss has told me to implement RAID on 2.6 kernel.
i am having support for RAID as i have seen in my kernel building.but i cant see anywhere raid files,like conf,
can any tell me a site or procedure to implement RAID

tizzef 02-07-2006 03:50 AM

hy

You have two way to make your HD working in RAID.
There is the <hardware way> and the <logical way>.
The first one is based on a RAID controler which is an aditionnal card in your box.
The second one is based onto software into linux. Have you already installed the RAID tools ??
In which way are you going ??

Cheers

HelaWann 02-07-2006 04:45 AM

If you want to go the softwar way, user mdadm to stup the RAID system:

Code:

mdadm --create /dev/md0 --level=5 --raid-devices=3 /dev/sda /dev/sdb /dev/sdc
This should work, but use the correct devices at the end of the line ;)

Hela

abhis_mail2002 02-07-2006 04:56 AM

i am using software ie mdadm,but at first pt it is asking me to go to /etc/raidtab
file which i dont have.
i have installed mdadm,
and my file

cat /proc/mdstat
Personalities :
unused devices: <none

is like this

jschiwal 02-07-2006 05:32 AM

I was wondering what type of drives you are talking about. If you have scsi drives, I would recommend going the hardware route with a raid-5 controller. For ide even with an onboard raid controller, you are actually using soft-raid, regardless.

Many distro's allow you to set raid drives very easily with their partitioning programs. I've never set up raid-5 this way, but I have for raid-1. I've used raid with Mandrake and SuSE. Here is a page from a Red Hat manual on setting up raid using Disk Druid. I hope it isn't out of date. http://www.redhat.com/docs/manuals/l...ware-raid.html

The how-to in /usr/share/doc/packages/raidtools/ highly recommends that you use only one ide drive per ide bus. A slave drive will slow down performance and a failure in one drive could cause the second on the same bus to fail. Raid-5 can only handle one failed drive. This means that you want two ide-controller cards for a raid-5 array. ( This would allow for a hot spare drive ). If you have the raidtools package installed, there are also sample configurations in the same directory as the documentation.

The redhat instructions recommend partitioning the member drives identically. Withn the identical start-stop cylinder configurations for each partition. When I had raid-1, I did this. I used the first partition on /dev/hda1 for a non-raid /boot partition. This partition is typically not very large,fedora core partitioner so I decided to partition the 2nd drive the exact same way, and copied the contents of /boot to the second drive. That way, if the first drive went out, the contents of the boot partition would be contained in the second drive. This would be doubly advantageous for someone using grub to boot.

I wasn't able to boot if /boot was on a raid drive. Perhaps I should of re-compiled a new kernel, or lilo, but I took the easy way out. This would mean losing the ability of rebooting if the first ide drive goes out, without manually fixing up the contents of /etc/fstab and grubs menu.lst file. That may not be acceptable. I still don't understand how you can load in the kernel and initrd on a raid drive, if the kernel and initrd are needed for raid to work! Seems like a catch-22 situation for me, unless Lilo or Grub contains linux raid support (for raid-5).

Make sure you understand how the system boots and exactly how to handle a failed drive. I'm not certain, but I think booting from software raid may entail writing to the MBR of a drive (such as /dev/hda1) that is the first member of the raid-5 partition that contains /boot, rather then the MBR of the raid array itself.

I hope I haven't caused you to have more questions than answers!

Regards and Good Luck!

Jim

abhis_mail2002 02-08-2006 12:56 AM

dear jschiwal

i have seen the documentation u have mentioned.
i am using FC4, i went to the disk druid, i am having a two drives
1. hda in this i created three raid partions
2. sda in this i installed fc4

when i use fdisk -l i get this

[root@localhost ~]# fdisk -l

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1275 10241406 fd Linux raid autodetect
/dev/hda2 1276 2550 10241437+ fd Linux raid autodetect
/dev/hda3 2551 3825 10241437+ fd Linux raid autodetect

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 2550 20482843+ 83 Linux
/dev/sda2 2551 2811 2096482+ 82 Linux swap / Solaris

Disk /dev/md0: 10.4 GB, 10487070720 bytes
2 heads, 4 sectors/track, 2560320 cylinders
Units = cylinders of 8 * 512 = 4096 bytes

Disk /dev/md0 doesn't contain a valid partition table


now how can i test raid-1 here,is the thing i did right

jschiwal 02-08-2006 05:41 AM

Whoa Nelly! I think you may be misunderstanding how raid drives work. One advantage is to be able to read data from more that one drive simultaneously. (raid-1 and raid-5) This can give a speed advantage on reads.
The other advantage is redundancy in case one drive fails.
Even if the three raid partitions could be on the same drive, you lose all of the advantages of using a raid array. Not only that, but you will be trying to read or write to three parts of the disk at the same time. This will result in a severe case of drive thrashing. Also, with only one drive, if it fails, you can't reconstruct the array.

First you need to have 2 ide controllers dedicated for the array. An IDE controller will have 2 connectors for the ide-cables. On each connector, you could have 2 drives, one the slave and the other the master, however you don't want to use the slave. You will get better performance if all of the drives are masters.

Then you want to decide how you want your linux partitions setup. Using raid-5, if you want a 24 GB home partition, a 6 GB root partition and a 12 GB /usr partition, then create partitions on each of the drives 12 GB, 3 GB and 6 GB respectively. Each partition in a raid-5 array will be occupied with 1/3rd parity information. So the raid-5 array size will be twice the size of an individual partition on one of the disks. Make sure that the disks are identical, and partitioned identically. Then you will use disk druid to create a raid-5 array ( an md device ) for each of these partition ( /,/home,/usr) and join the respective drive partitions to the raid array. Next, you decide how the raid-partitions ( /dev/md0, dev/md1, etc) will be formatted ( ext3, reiserfs ), and give them names (/, /root, /usr, etc)
For example, you would create a raid partition (md0) for root and join hda1,hdb1,hdc1 to this partition. You would create (md1) for /home and join hda2,hdb2,hdc2 to the md2 raid-5 device. And so on for the others. After th

You may want to consider whether you will be able to boot from raid, or if you need /boot on a normal partition. Also, can you boot from your sata drive, or do you need to leave some space on the raid drives for the /boot parition. If it is the latter, I would recommend using /dev/hda1 for the boot partition. Using /dev/hdb1 as a copy of the boot partition (maybe mounted as /spare-boot for example). That would leave /dev/hdc1 which you might want to make a swap partition. This way, if /dev/hda failed, you could setup /dev/hdb1 as the new /boot partition. If /dev/hdb or /dev/hdc failed, you would be able to boot.

You may also want to have a 4th drive. If one of the first 3 drives failed, the 4th drive would automatically be replicated to replace it. That would give you some extra insurance before you replaced the bad drive.

A hardware scsi raid subsystem on a server would work differently. You would have the 3 or more drives that would be a part of the array. The array would present itself as a single device which you would then partition as if it were a single drive. If a drive went bad, you would replace it with an identical blank drive. The raid controller would then use the parity information of the other drives to recreate the information that was on the bad drive. On these systems, you purchase a server that has the raid system from the start, and the drives will be hot-swappable, so you don't have to power down the server to replace the bad drive. Sometimes a drive just has a write error on it for whatever reason, and reseating the drive will fix the problem.

barrulus 02-09-2006 10:58 AM

Hello People,

(Just posting this from another thread, because some of my statements will possibly help Abhis with his situation)

I have a server that recently had 4 x 300GB 15k RPM SCSI drives added to it.
They were added so that I can write my database to a highspeed array.

Unfortunately the host based RAID controller onboard the box is only geared for 1 RAID array and that is already in use for a RAID 1 stripe across 2 x 73GB SCSI drives for my host OS (Fedora Core 4 x86_64)

Ok, so now I have 1 x RAID 1 hardware controlled array, and I need some redundancy and high speed access.
My machines are Sunfire V40z's and have more than enough spare CPU and I/O to handle softare RAID so I am trying to configure the following: -

sdb1 + sdc1 = md1 (RAID 1)
sdd1 + sde1 = md2 (RAID 1)
md1 + md2 = md3 (RAID 0)

Ok, while in theory this is very simple, with Linux software RAID there are a few caveats...

1. you cannot use the raw drive (i.e. /dev/sdb) you have to create a partition on the drive and format it to be of partition type Linux RAID autodetect.
So I partition each drive, create 1 primary partition using all disk space, use fdisk to set the partion to Linux RAID Autodetect.
Doing this essentially gives the drives a "persistant superblock" so that the drives will be recognised at boot time.

Ok, /dev/md1 and /dev md2 are both easy and are recognised by my kernel/OS when booting and I have two functional RAID 1 mirrors with no data.

I now need to make a RAID 0 stripe across these two mirrors to get my RAID 1+0 (10) up.

I use:
mdadm -C /dev/md3 --level=raid0 --raid-devices=2 /dev/md1 /dev/md2
to create a RAID 0 array using the four disks in the aforementioned config.
This works greate, I can now create and mount my filesystem:
mkfs.reiserfs /dev/md3
mount /dev/md3 /data/

Alright at this point I have almost 600GB of useable space in exactly the configuration I want.
My problem is this:

How do I make this persistant across boots?
only my two RAID 1 arrays are persistant across boots, no matter what I try the RAID 0 stripe fails.

I have tried scripting using mdadm to rebuild the array (assemble) but it just tells me that the drives are part of an existing array.
I have tried fdisking the /dev/md3 and creating a Linux RAID Autodetect partition /dev/md31 to get the persistant superblock happening but this fails on boot as /dev/md3 does not exist until Linux has booted to a point.

Any help here would be greatly appreciated.

(I got this reply from sam_vde)

I think you can achieve this by using the /etc/raidtab file. Persistent superblocks are required to boot from a software raid, but for your particular setup raidtab could work fine.

Another option (my personal preference that is) is using LVM. You can add your RAID1 sets into a Volume Group (lineair or striped) and create Logical Volumes from it. This will give you more flexibility (e.g. not allocating all space yet so you can grow the volumes afterwards) and you can work with meaningful device names (e.g. /dev/oracle/db).

Beware if you should go for LVM and you create a striped Volume Group, you cannot expand this with more physical devices afterwards!

(-end sam_vde)

Ok, my problem is that I don't want to compile raidtools for my FC4 x86_64 installation, and I have not seen it anywhere available so am not even sure it is a maintained system.
That being said, does anyone here know how I can go about gfetting my RAID 0 sripe to work?

Barry

jschiwal 02-10-2006 12:06 AM

Try this link. I don't know if the response is correct however.
http://www.issociate.de/board/goto/5...uperblock.html

There is a book named: Managing Raid on Linux. That may be a worthwhile investment.
http://linuxcentral.com/catalog/inde...=C1CCigyQugXCK

Here is a wiki on setting up a raid-10 array.
"http://www.mythtv.org/wiki/index.php/RAID#RAID_10 The difference is that persistance superblocks aren't used. /etc/mdadm.conf is created using the output of
mdadm --detail --scan
after manually configuring the array, just like you did. However the author didn't use persistant-superblocks to be able to have it assembled by the kernel as you are trying.

You are more experienced at this then I am. Can you, with an upgraded mdadm program, use the array you created to produce an /etc/mdadm.conf configuration file and then use "mdadm -C /etc/mdadm.conf --level=raid10"?

----

I downloaded the source for mdadm-2.3.1
Look at this part of the man file:
Quote:

-l, --level=
Set raid level. When used with --create, options are: linear, raid0, 0, stripe, raid1, 1, mir‐
ror, raid4, 4, raid5, 5, raid6, 6, raid10, 10, multipath, mp, fautly. Obviously some of these
are synonymous.
You may need to upgrade to a newer version of mdadm. Your version may not support raid10 in the way you want.

When I compared this with the version for OpenSuSE 10, the raid10 level was missing. You probably might want to google for "mdadm.conf raid10" and see if there is a sample config file for building a --level raid10 array.

barrulus 02-10-2006 06:49 AM

>Here is a wiki on setting up a raid-10 array.
>"http://www.mythtv.org/wiki/index.php/RAID#RAID_10 The difference is that persistance

I have already tried this, just seemed to me that the order that the raid arrays started in was random, i.e. it would attempt to create /dev/md3 before /dev/md1...

>You are more experienced at this then I am. Can you, with an upgraded mdadm program,
> use the array you created to produce an /etc/mdadm.conf configuration file and then use
>"mdadm -C /etc/mdadm.conf --level=raid10"?

My current mdadm does not (it appears) directly support RAID 10.
I will upgrade this and will post my results here, I just have to wait for a maintenance window (Sunday 2am) to do this in.

>I downloaded the source for mdadm-2.3.1
>Look at this part of the man file:

Thanks for the heads up, I have been googling, ultraseeking, altavistaing and trawling wikipedias, forums and newgroups for about a month trying to get this worked out...
Seems I am not the only one :)

As I said, I will post my results here (and the process for any others interested).

I am very curious to see, because if the new version of mdadm allows me to set it up like this without the use of persistant superblocks, I can remove the partitions I have created on the disks so that my disk overhead is slightly reduced...

B

jschiwal 02-10-2006 03:10 PM

If your /root or /etc partition is located on the raid10 device being installed, then I think you will still need persistent superblocks. The new mdadm program will probably correctly set them up for the kernel. Another idea is to use the GUI tool to set up a raid10 array. This may do something so that the kernel doesn't try to assemble md2 before md1 & md0 when md0 & md1 are components of md2.

If on the other hand, the / and /etc partitions are available, then the array can be assembled from an /etc/mdadm.conf file.

abhis_mail2002 02-14-2006 03:33 AM

dear jschiwal
i have created raid parition using Disk druid interface at the time of installation,the partions are for /root and swap..........its working fine. now i have created more two paritions of RAID type the display of fdisk -l is:

Disk /dev/hda: 40.0 GB, 40020664320 bytes
255 heads, 63 sectors/track, 4865 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/hda1 * 1 1275 10241406 fd Linux raid autodetect
/dev/hda2 1276 1543 2152710 fd Linux raid autodetect
/dev/hda3 1544 4865 26683965 5 Extended
/dev/hda5 1544 2789 10008463+ fd Linux raid autodetect
/dev/hda6 2790 4035 10008463+ fd Linux raid autodetect

Disk /dev/sda: 80.0 GB, 80026361856 bytes
255 heads, 63 sectors/track, 9729 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes

Device Boot Start End Blocks Id System
/dev/sda1 * 1 1275 10241406 fd Linux raid autodetect
/dev/sda2 1276 1543 2152710 fd Linux raid autodetect
/dev/sda3 1544 9729 65754045 5 Extended
/dev/sda5 1544 2789 10008463+ fd Linux raid autodetect
/dev/sda6 2790 4035 10008463+ fd Linux raid autodetect


now i have created /etc/raidtab file and included this two new paritions for raid array,
-----------
my /etc/raidtab file is
-------------
raiddev /dev/md2
raid-level 1
nr-raid-disks 2
# nr-spare-disks 0
persistent-superblock 1
chunk-size 32
device /dev/sda5
raid-disk 0
device /dev/hda5
raid-disk 1

raiddev /dev/md3
raid-level 1
nr-raid-disks 2
# nr-spare-disks 0
persistent-superblock 1
chunk-size 32
device /dev/sda6
raid-disk 0

-------------

now when i do mkraid /dev/md2 it is not creating the array it is giving error

mkraid /dev/md2
handling MD device /dev/md2
analyzing super-block
couldn't call stat() on device /dev/sda5 -- No such file or directory
mkraid: aborted, see the syslog and /proc/mdstat for potential clues

how can i proceed further

jschiwal 02-14-2006 09:56 PM

joined split line
 
The md2 section of your raidtab looks correct to me. Maybe there actually is something wrong /dev/hda5. The raidtab manpage states that the parsing code isn't very "bright", but you have followed the same order as in the manpage.

The device /dev/hda6 is missing from the /dev/md3 definition.
device /dev/hda5
raid-disk 1
Perhaps, it's just in the posting. Try to create md2 again, after starting "tail -f /var/log/messages" in another virtual terminal. The -f will follow the new messages created when you try it again.

If you already have 2 raid devices, why aren't they listed in /etc/raidtab?

How did diskdruid set them up? Perhaps using mdadm? Is there an /etc/mdadm.conf file. If so, it may be better to use mdadm to manage your new raid devices also.
Since Diskdruid was able to successfully install your first 2 raid devices, you may give it a try creating these two as well.

abhis_mail2002 02-15-2006 02:22 AM

dear jschiwal
i ahve used the mdadm command then i created it, its working now.but i have doubt now, in my /dev directory first it was showing md0........md12 but now its only showing me md0,md1,md2,md3 i am not able to see other mds , how can i get it again

jschiwal 02-15-2006 09:10 PM

This might not be a problem. If you were to more hard drives to your system, I think they would be added after you rebooted.
The script that creates the md devices during boot up, may have deferred to the contents of /etc/mdadm.conf in determining the number of md devices to create. You might want to check the output of the "dmesg" command, or the /var/log/boot.msg or /var/log/boot.log. I think the interesting lines will start with the "md:" string. Look for when the devices are created.

On some systems, the devices may be created by /linuxrc in the /boot/initrd-<version> ram disk. I just checked on my laptop, and my initrd filesystem is empty.

On my system there is an /etc/init.d/boot.d/ directory that contains the the scripts that run when the system boots.
The K06boot.md script shows how the system checks for either the mdadm.conf or raidtab files. I just noticed that it first checks for /etc/mdadm.conf. The check for /etc/raidtab and /etc/mdtab are contained in later elseif blocks. If your system is similar, then that would answer what your previous problem was. Diskdruid setup and configured your first two raid partitions using mdadm. Then the test for a /etc/raidtab file may have been skipped over. So setting it up manually, you could assemble and use the raid devices, but during the boot process, /etc/raidtab wasn't noticed and the corresponding raid service wasn't started.

Code:

case "$1" in
    start)
        #
        # maybe we use "Multiple devices".  So initialize MD.
        #
        if test -f /etc/mdadm.conf -a -x /sbin/mdadm ; then
            echo "Initializing Multiple Devices..."
            /sbin/mdadm --assemble --scan
        elif test -f /etc/raidtab -a -x /sbin/raid0run ; then
            echo "Initializing Multiple Devices..."
            /sbin/raid0run -a
            if test -x /sbin/raidstart ; then
                /sbin/raidstart -a
            fi
        elif test -f /etc/mdtab -a -x /sbin/mdadd ; then
            echo "Initializing Multiple Devices..."
            /sbin/mdadd -ar && MDADD_RETURN=0 || MDADD_RETURN=1
            if test $MDADD_RETURN -ne 0 ; then
                if test  -x /sbin/ckraid ; then
                    echo "Initializing Multiple Devices failed.  Trying to recover it..."
                    /sbin/mdstop -a
                    for i in /etc/raid?.conf ; do
                        /sbin/ckraid --fix $i
                    done
                    /sbin/mdadd -ar
                    rc_status -v1 -r
                else
                    rc_status -v1 -r
                fi
            fi
        fi
        if test -f /sbin/raidautorun ; then
            /sbin/raidautorun
        fi

Here I searched the boot scripts for the "mknod" command. So on my system, I would investigate boot.device-mapper and devmap_mknod.sh.

Code:

hpamd64:/etc/init.d/boot.d # grep mknod *
K16boot.device-mapper:  if test -x /sbin/devmap_mknod.sh ; then
K16boot.device-mapper:      /sbin/devmap_mknod.sh
S06boot.device-mapper:  if test -x /sbin/devmap_mknod.sh ; then
S06boot.device-mapper:      /sbin/devmap_mknod.sh



All times are GMT -5. The time now is 09:30 AM.