# Raid5 question

## Rustylinux

Hello,

I currently have a server with a hardware raid controller in it and 3 80GB drives setup as a raid 5 for my data.  My question is how would I go about expanding this array?  After i put the 4th new drive in and set it up in the raid controller how do i setup the file allocation tables in the linux os to expand the raid 5 onto the new drive / volume.  Or what do I have to do to get that new 4th drive part of the other raid 5 volume?

To better explain my question in windows after you add the new drive to the raid5 configuration on the raid controller you would extend the raid 5 volume onto the new unallocated space.  How would i accomplish this with gentoo / linux ?

----------

## Rob1n

Is it a true hardware RAID controller (megaraid, 3ware, etc)?

If so, you'll need to expand the array in the controller config (if it supports expansion - some older controllers don't).  This'll then show up as a larger disk under Linux (try "fdisk -l /dev/sda" - it should show the disk size at the top).  You can then either create a new partition or extend the existing partition.  To increase the size of a partition just delete it using fdisk and recreate it with the same starting point but a larger size.  You can then extend the filesystem using resize2fs, resize_reiserfs or whatever.

If it's a firmware RAID controller then you'll be using dmraid I guess - I've no idea how to expand that I'm afraid.

And if it's a software RAID array then mdadm will allow you to grow the array.  You'll then need to expand the partition and filesystem as above.

----------

## Rustylinux

Hello,

Thanks for the post. The raid controller is a 3com and it does allow for the expansion of a raid 5 howerver it was the software part after that which is what i was unsure about.  In the process you layed out with using fdisk -l and removing and readding the partion I would loose data with that process wouldn't I ?? the extension has to be done with out loosing data.  Will this work without losing any data?

----------

## Cyker

I think the least scary option is gparted - It's basically Partition Magic for Linux  :Smile: 

Alternatives:

If you have LVM, there is a way to extend the LVM partition, then expand the ext3 filesystem with resize2fs to fill the new partition.

I'm using Linux software RAID5, and was a bit sneaky - I put my ext3 filesystem directly into /dev/md0, so if I ever expand the array I can just use 

```
resize2fs
```

 to frow the filesystem into the extra space without needing to partiton  :Mr. Green: 

The fdisk option I've heard bandied around - fdisk doesn't wipe the diak data, just the partition table, so theoretically it's possible to delete the partiton, and re-create it in exactly the same place, only bigger, and then use resize2fs.

This is scary 'tho and I wouldn't dare do it without backing up first.

But then again if you can back up the whole partiton first, it's easier just to backup, wipe, recreate, restore...

----------

## Rob1n

 *Rustylinux wrote:*   

> Hello,
> 
> Thanks for the post. The raid controller is a 3com and it does allow for the expansion of a raid 5 howerver it was the software part after that which is what i was unsure about.  In the process you layed out with using fdisk -l and removing and readding the partion I would loose data with that process wouldn't I ?? the extension has to be done with out loosing data.  Will this work without losing any data?

 

The partition data is stored separately from the filesystem so you can quite safely delete & recreate partitions.  The only issue will be if you dont recreate it with the same starting point, in which case it will just fail to mount and you can retry (this is unlikely to happen though as partitions are usually created without any gaps, so the default start position will be immediately after the end of the last partition, which will also be the start position of the old partition).  Just make sure you store the output of "fdisk -l -u" before doing anything so you can recreate the original partitions if needed.

As pointed out, gparted is another option (providing your array isn't too large - it seems to fail with > 2TB array) which does exactly the same thing behind the scenes but presents a more friendly face.

----------

