# [SOLVED] Mdadm and RAID without mdadm.conf?

## humbletech99

I have (or had) a RAID5 array of 4x160Gb disks with mdadm. I removed the mdadm.conf to see if I could reassemble the array without it but didn't manage, it kept complaining that the conf was missing, so I re-created the array, which seems to have given it a new uuid number and has begun re-initialising the array as a new one as follows:

```
 mdadm --detail /dev/md0

/dev/md0:

        Version : 00.90.00

  Creation Time : Sun Apr  2 14:35:46 2006

     Raid Level : raid5

     Array Size : 468864768 (447.14 GiB 480.12 GB)

    Device Size : 156288256 (149.05 GiB 160.04 GB)

   Raid Devices : 4

  Total Devices : 5

Preferred Minor : 0

    Persistence : Superblock is persistent

    Update Time : Sun Apr  2 14:37:27 2006

          State : active, degraded, recovering

 Active Devices : 3

Working Devices : 4

 Failed Devices : 1

  Spare Devices : 1

         Layout : left-symmetric

     Chunk Size : 32K

 Rebuild Status : 58% complete

           UUID : 6c91295a:88927f21:104c4e0e:4ef9559c

         Events : 0.3

    Number   Major   Minor   RaidDevice State

       0       3        1        0      active sync   /dev/hda1

       1       3       65        1      active sync   /dev/hdb1

       2      33        1        2      active sync   /dev/hde1

       3       0        0        3      faulty

       4      33       65        4      spare rebuilding   /dev/hdf1

```

I can have the array mounted at the moment and I can see all the files on it... I'm not really experienced in linux's software raid so I was wondering if it is at all possible to recover a raid for which you no longer have the mdadm.conf and hence no longer have the original uuid of the array?

Iirc I thought that a persistent superblock meant that it should just be possible to re-initialise the array without any conf file since the raid info should be contained in the superblock...

----------

## R!tman

You don't need the conf file (I think). I have the same thing, raid5 with 4 160GB drives and I have the conf file on the raid, where it is not available during the raid assembly. But I have a save conf on my boot partition  :Wink: .

A couple of week ago I resized my raid and lost the config. Even though my superblock was not persistent anymore I could reconstruct the raid without the config.

----------

## humbletech99

what is the best way to recover the array in that instance, will recreating the array in the same disk order do it, because this is what I did and despite it thinking it's a new array and it's still setting it up (I had to confirm to overwrite the superblock), I can mount it and use all the stuff on it...

I couldn't see any other way of doing this since I couldn't reassemble the array without the conf, it seemed to work to just recreate the array with the same disks..., although now I have to wait for it finish doing that failed disk rebuilding misnomer stuff before I get the usual status back...

----------

## R!tman

 *humbletech99 wrote:*   

> what is the best way to recover the array in that instance, will recreating the array in the same disk order do it, because this is what I did and despite it thinking it's a new array and it's still setting it up (I had to confirm to overwrite the superblock), I can mount it and use all the stuff on it...
> 
> I couldn't see any other way of doing this since I couldn't reassemble the array without the conf, it seemed to work to just recreate the array with the same disks..., although now I have to wait for it finish doing that failed disk rebuilding misnomer stuff before I get the usual status back...

 

Acually, I am not quite sure how I resolved my superblock stuff... A little fiddling around with "--assemble" "--force" and "--update" I guess. 

You should keep in mind, that the array should be able to be assembled by the kernel alone, without any config file. Once you assemble an array the device name is somehow saved within the superblock. I'll give you an example:

1) create array

```
mdadm --create /dev/md1 --level 5 /dev/sd[a-d]3
```

2) format, mount and create a file on the array

```
mkfs.reiserfs /dev/md1 && mount /dev/md1 /mnt/gentoo && echo "Hello World" >> /mnt/gentoo/file.txt
```

3) unmount and reboot

```
umount /mnt/gentoo && reboot
```

4) after rebooting, the kernel will automatically be able to mount /dev/md1 correctly, if you have the neccessary support in the kernel when doing

```
mount /dev/md1 /mnt/gentoo
```

I hope this helps a little...

----------

## humbletech99

thanks, this is all the stuff I've done before, it doesn't seem many people know the details of the superblock etc. I'm gonna have to recompile my kernel to have the raid support internally, it's a module at the mo which is why the kernel doesn't actually do the superblock assembly for me at boot, so I've found that I rely on the conf file at the moment. I was hoping that there was a better way to re-assemble an array without the uuid and the conf...

----------

## tee

I am also trying to recover an array but when I try to recreate it I get the error:

```

$ mdadm --create /dev/md0 -c 8 --level=0 -n 2 /dev/sda1 /dev/sdc1

mdadm: Cannot open /dev/sda1: No such device or address

mdadm: Cannot open /dev/sdc1: No such device or address

mdadm: create aborted

```

Any help would be appreciated

----------

## R!tman

 *tee wrote:*   

> I am also trying to recover an array but when I try to recreate it I get the error:
> 
> ```
> 
> $ mdadm --create /dev/md0 -c 8 --level=0 -n 2 /dev/sda1 /dev/sdc1
> ...

 

Check if the neccessary devices are present. Maybe post the output of "ls -la /dev/md0 /dev/sda1 /dev/sdc1".

BTW, I am no pro in such things, but a chunk size of 8 seems awfully small. Are you sure you need that?

----------

## humbletech99

hmmm, my first impression was that this was correct but I think you're right, shouldn't that be 32k chunk size, with ext2/3 having 4k block size and a stride of 8 to tally up?

Anyway, you'll need your devices to be detected before you can do this. Hopefully when you can see all the sd* devices that should work for you...

But the real question is - Is there a better way to re-assemble an array other than overwriting the superblocks by creating a new array?

----------

## R!tman

 *humbletech99 wrote:*   

> But the real question is - Is there a better way to re-assemble an array other than overwriting the superblocks by creating a new array?

 

As far as I know 

```
mdadm --update --force --assemble /dev/md1 /dev/sd[a-d]3
```

should only recreate the superblock, without recreating the array. The array is assemble normally, sort of.

----------

## humbletech99

but this is basically the same as re-creating the array isn't it?

In my experience when you re-create the superblock you have to go through a lengthy array sync which takes hours...

It's better to not update and force, running just

```
mdadm --assemble /dev/md0 /dev/sd[a-d]3 
```

should suffice

ended up solving my own question, I think next time I'll be more careful not to recreate the superblock as it takes too long and also you then have to chagne your mdadm.conf (I keep it around for nostalgia  :Wink:  )...

I tested this and it does work...

----------

## tee

This worked for me as well. The problem with the device not found is specific to my fedora core installation.

Thanks for the quick replies

P.S My block size is actually 16K which is still pretty small but I'm a noob   :Smile: 

----------

## humbletech99

16K block size isn't small, I've got a 4K block size with a stride of 8 and a 32K chunk size.

If you meant a 16K chunk size then that is a little small I guess...

but then, it's not the size that matters, it's what you do with it that counts...  :Wink: 

----------

