# sw raid refuses to mount from md0, only from md1

## Oo.et.oO

i created my first sw raid array (two drives, raid1) using the gentoo software raid install wiki page.

i created it as md1 since that's what it told me to do.  i then used mdadm scan to produce my mdadm.conf file:

```

ARRAY /dev/md1 metadata=0.90 UUID=736792af:2bbaec7b:0a43fd92:44f189ad

```

md is built into the kernel as is raid1.  i can mount that md1 device just fine.

BTW, those are no uuid's i've ever seen in /dev/drives/by-uuid

however when the machine boots and autodetects the raid arrays it creates md0

but i can't mount md0:

```

mount: /dev/md0: can't read superblock

```

i then have to add md1 by:

```
mdadm -v --auto-detect
```

  or: 

```
mdadm -A --auto=md /dev/md1
```

which i can then add.

i've tried changing the mdadm.conf file to read md0 instead of md1, but i still can't mount it as md0.

here is the raid array detail.  looks like it's using only one drive.  that's undoubtedly another problem...

```
# mdadm --detail /dev/md1

/dev/md1:

        Version : 0.90

  Creation Time : Tue Dec  7 12:38:50 2010

     Raid Level : raid1

     Array Size : 1953511936 (1863.01 GiB 2000.40 GB)

  Used Dev Size : 1953511936 (1863.01 GiB 2000.40 GB)

   Raid Devices : 2

  Total Devices : 1

Preferred Minor : 1

    Persistence : Superblock is persistent

    Update Time : Thu Dec 30 10:14:59 2010

          State : clean, degraded

 Active Devices : 1

Working Devices : 1

 Failed Devices : 0

  Spare Devices : 0

           UUID : 736792af:2bbaec7b:0a43fd92:44f189ad (local to host glazed)

         Events : 0.20790

    Number   Major   Minor   RaidDevice State

       0       0        0        0      removed

       1       8       97        1      active sync   /dev/sdg1

```

thanks all!

----------

## NeddySeagoon

Oo.et.oO,

Did you feed the drives, /dev/sda and /dev/sdb to mdadm or did you make partitions then donate /dev/sda1 and /dev/sdb1 to the raid1 set?

The kernel cannot autorun the former, as there is no partition table to hold the partition type fd

----------

## Oo.et.oO

the latter.  auto-detect works, but only after i've booted for creating md1.  when i boot it doesn't create md0 correctly

----------

## NeddySeagoon

Oo.et.oO,

Add the other half of the mirror in, allow it to resync, watch /proc/mdstat, then try again.

----------

## Oo.et.oO

how do i add in the other disk?  shouldn't it already be added via the mdadm.conf file?

using: 

```
mdadm --add /dev/md1 /dev/sdf1
```

since the raid array is currently on md1

```
Every 30.0s: cat /proc/mdstat                           Thu Dec 30 14:17:26 2010

Personalities : [raid1]

md1 : active raid1 sdf1[2] sdg1[1]

      1953511936 blocks [2/1] [_U]

      [>....................]  recovery =  0.2% (5466944/1953511936) finish=1589

.1min speed=20430K/sec

unused devices: <none>

```

holy crap 26 hours to sync??  i guess that's what i get for putting 2TB drives on usb...

will this help me get it back onto md0?  do i need to use scan to put a new entry into mdadm.conf?

thanks for your help!

----------

## NeddySeagoon

Oo.et.oO,

Looks OK.  Oh, I don't have a mdadm.conf file.  My raid sets are auto detected before it could be read.

The superblock says 

```
Preferred Minor : 1 
```

thats /dev/md1

The sync time is determined by the amount of bandwidth you allow.  Its designed to allow the raid to still be used while it syncs.

You can change that somehow but I've never needed to

----------

## Oo.et.oO

so i shouldn't need an mdadm.conf and it should auto detect and give me the first /dev/md* alias device, no?

i only have the one raid array and it's just for storage, not for / or /usr or anything like that...

was it not auto-detecting prior because the second device was not added?

thanks again

----------

## NeddySeagoon

Oo.et.oO,

It will auto detect as /dev/md1 because of the Preferred Minor : 1 in the Raid Superblock.

It was starting in degraded mode because the two halves of the raid were out of sync - you are fixing that now.

To ensure that autodetect works, all the raid support must be build into the kernel and you must use raid superblock version 0.9 (you are Version : 0.90)

lastly, your partition type must be 0xfd, not 0x82 or 0x83.  check that and fix it with fdisk if needed.

----------

## Oo.et.oO

both partitions are indeed 0xfd.    i can tell it's starting with a missing disk (i guess this is what you mean by "degraded mode"?), but why is there an md0 that i can't mount?  that's the first one the kernel tried to autodetect when i booted (i think).  i can autodetect and produce md1 after boot using the commands in first post, even with a missing disk.  i can then mount that as per usual.  i want this thing mounted by the time i get to log in, or even if i never log in locally...

----------

## christophe_y2k

Hello, i must say a big thank you for your help in this forum NeddySeagoon

Have a question

i try to re-install my gentoo server with raid mdadm since few day with no success

have: mdadm.conf with 4 hdd sata 1To

#ARRAY /dev/md1 metadata=0.90 UUID=3a7ff37a:477a12e9:cb201669:f728008a

#ARRAY /dev/md2 metadata=0.90 UUID=e921c98e:33dd5bdd:cb201669:f728008a

#ARRAY /dev/md3 metadata=0.90 UUID=cac59e32:21ccf179:cb201669:f728008a

ARRAY /dev/md4 metadata=1.2 name=livecd:zoneminder UUID=6ef11c11:5744f8ac:1037aac1:26588ba4

since i read your post i decide to comment the md (1 to 3) line (because autodetec with version 0.9)

md1 /boot ext4 raid1

md2 swap raid1

md3 / ext4 raid1

md4 /zoneminder ext4 raid5 with metadata 1.2 (an big  empty part for future software)

do my system boot with that config and mount properly all of my part ???

Big Thanks

----------

## NeddySeagoon

Oo.et.oO,

Look in dmesg ... you should see something like 

```
[    2.213930] md: Waiting for all devices to be available before autodetect

[    2.215504] md: If you don't use raid, use raid=noautodetect

[    2.217885] md: Autodetecting RAID arrays.

[    2.353116] md: Scanned 12 and added 12 devices.

[    2.354685] md: autorun ...

[    2.356672] md: considering sda6 ...

[    2.358241] md:  adding sda6 ...

[    2.360193] md: sda5 has different UUID to sda6

[    2.360655] md: sda1 has different UUID to sda6

[    2.361012] md:  adding sdd6 ...

[    2.361362] md: sdd5 has different UUID to sda6

[    2.361710] md: sdd1 has different UUID to sda6

[    2.362051] md:  adding sdb6 ...

[    2.362391] md: sdb5 has different UUID to sda6

[    2.362729] md: sdb1 has different UUID to sda6

[    2.363058] md:  adding sdc6 ...

[    2.363380] md: sdc5 has different UUID to sda6

[    2.364153] md: sdc1 has different UUID to sda6

[    2.364740] md: created md6

[    2.365109] md: bind<sdc6>

[    2.365470] md: bind<sdb6>

[    2.365821] md: bind<sdd6>

[    2.366163] md: bind<sda6>

[    2.366501] md: running: <sda6><sdd6><sdb6><sdc6>

[    2.367321] md/raid:md6: device sda6 operational as raid disk 0

[    2.367687] md/raid:md6: device sdd6 operational as raid disk 3

[    2.368112] md/raid:md6: device sdb6 operational as raid disk 1

[    2.368464] md/raid:md6: device sdc6 operational as raid disk 2

[    2.369125] md/raid:md6: allocated 4272kB

[    2.369509] md/raid:md6: raid level 5 active with 4 out of 4 devices, algorithm 2

[    2.369765] RAID conf printout:

[    2.369766]  --- level:5 rd:4 wd:4

[    2.369767]  disk 0, o:1, dev:sda6

[    2.369768]  disk 1, o:1, dev:sdb6

[    2.369769]  disk 2, o:1, dev:sdc6

[    2.369770]  disk 3, o:1, dev:sdd6

[    2.369788] md6: detected capacity change from 0 to 2982741147648

[    2.370237] md: considering sda5 ...

[    2.370492] md:  adding sda5 ...

[    2.370742] md: sda1 has different UUID to sda5

[    2.370993] md:  adding sdd5 ...

[    2.371240] md: sdd1 has different UUID to sda5

[    2.371490] md:  adding sdb5 ...

[    2.371732] md: sdb1 has different UUID to sda5

[    2.372222] md:  adding sdc5 ...

[    2.372477] md: sdc1 has different UUID to sda5

[    2.372977] md: created md5

[    2.373205] md: bind<sdc5>

[    2.373429] md: bind<sdb5>

[    2.373648] md: bind<sdd5>

[    2.373861] md: bind<sda5>

[    2.374066] md: running: <sda5><sdd5><sdb5><sdc5>

[    2.374643] md/raid:md5: device sda5 operational as raid disk 0

[    2.374866] md/raid:md5: device sdd5 operational as raid disk 3

[    2.375076] md/raid:md5: device sdb5 operational as raid disk 1

[    2.375275] md/raid:md5: device sdc5 operational as raid disk 2

[    2.375615] md/raid:md5: allocated 4272kB

[    2.376066] md/raid:md5: raid level 5 active with 4 out of 4 devices, algorithm 2

[    2.376290] RAID conf printout:

[    2.376291]  --- level:5 rd:4 wd:4

[    2.376292]  disk 0, o:1, dev:sda5

[    2.376294]  disk 1, o:1, dev:sdb5

[    2.376295]  disk 2, o:1, dev:sdc5

[    2.376296]  disk 3, o:1, dev:sdd5

[    2.376308] md5: detected capacity change from 0 to 16137584640

[    2.376706] md: considering sda1 ...

[    2.376917] md:  adding sda1 ...

[    2.377127] md:  adding sdd1 ...

[    2.377333] md:  adding sdb1 ...

[    2.377539] md:  adding sdc1 ...

[    2.378070] md: created md1

[    2.378269] md: bind<sdc1>

[    2.378470] md: bind<sdb1>

[    2.378668] md: bind<sdd1>

[    2.378865] md: bind<sda1>

[    2.379062] md: running: <sda1><sdd1><sdb1><sdc1>

[    2.379686] md/raid1:md1: active with 4 out of 4 mirrors

[    2.379922] md1: detected capacity change from 0 to 41025536

[    2.380345] md: ... autorun DONE.

[    2.380593] md5: detected capacity change from 0 to 16137584640

[    2.380987]  md5: unknown partition table
```

which tells you what the autodetect is doing.

If you see only 

```
[    2.215504] md: If you don't use raid, use raid=noautodetect

[    2.217885] md: Autodetecting RAID arrays.

[    2.380345] md: ... autorun DONE.
```

then nothing was autodetected, so you have a kernel problem.

Pastebin your /usr/src/linux/.config    wgetpaste is a big help there.

----------

## NeddySeagoon

christophe_y2k,

It depends on your kernel ... check your dmesg.

Raid autodetect happens before root is mouted so /etc/mdadm.conf cannot be read.

----------

## christophe_y2k

Re-Hello

Ok that boot but ...

md2 (my swap) is reassigned to md127.... with error for the swap

i remplace in fstab md2 by md127 for the swap and that reboot with no error .

----------

## NeddySeagoon

christophe_y2k,

What does 

```
mdadm --detail /dev/md... 
```

say for Preferred Minor ?

Thats the md number the raid set will appear at when its auto assembled.

----------

## christophe_y2k

Thanks for your reply

# mdadm --detail /dev/md127

/dev/md127:

        Version : 0.90

  Creation Time : Thu Dec 30 22:40:03 2010

     Raid Level : raid1

     Array Size : 8393856 (8.01 GiB 8.60 GB)

  Used Dev Size : 8393856 (8.01 GiB 8.60 GB)

   Raid Devices : 4

  Total Devices : 4

Preferred Minor : 127

    Persistence : Superblock is persistent

  Intent Bitmap : Internal

    Update Time : Fri Dec 31 00:19:35 2010

          State : active

 Active Devices : 4

Working Devices : 4

 Failed Devices : 0

  Spare Devices : 0

           UUID : e921c98e:33dd5bdd:cb201669:f728008a

         Events : 0.36

    Number   Major   Minor   RaidDevice State

       0       8        2        0      active sync   /dev/sda2

       1       8       18        1      active sync   /dev/sdb2

       2       8       34        2      active sync   /dev/sdc2

       3       8       50        3      active sync   /dev/sdd2

but i create it with md2 with :

# mknod /dev/md1 b 9 1

# mknod /dev/md2 b 9 2

# mknod /dev/md3 b 9 3

# mknod /dev/md4 b 9 4

# mdadm --create --verbose /dev/md2 --metadata=0.90 --level=1 --raid-devices=4 /dev/sda2 /dev/sdb2 /dev/sdc2 /dev/sdd2

# watch -n1 'cat /proc/mdstat'

and now after change in fstab md2 --> md127

# cat /proc/mdstat

# cat /proc/mdstat

Personalities : [raid1] [raid6] [raid5] [raid4] [faulty] 

md127 : active (auto-read-only) raid1 sda2[0] sdb2[1] sdd2[3] sdc2[2]

      8393856 blocks [4/4] [UUUU]

      bitmap: 0/1 pages [0KB], 65536KB chunk

md4 : active raid5 sdd4[4] sda4[0] sdb4[1] sdc4[2]

      2872803840 blocks super 1.2 level 5, 128k chunk, algorithm 2 [4/3] [UUU_]

      [==>..................]  recovery = 14.1% (135747200/957601280) finish=173.3min speed=79001K/sec

md1 : active raid1 sda1[0] sdd1[3] sdc1[2] sdb1[1]

      272960 blocks [4/4] [UUUU]

      bitmap: 0/1 pages [0KB], 65536KB chunk

md3 : active raid1 sda3[0] sdd3[3] sdc3[2] sdb3[1]

      10490368 blocks [4/4] [UUUU]

      bitmap: 0/1 pages [0KB], 65536KB chunk

unused devices: <none>

no mather with rsync md4 i cretae with missing for install fast and after i add the part for rebuild

but md127 say (auto-read-only)

have you a method for change md127 to md2 and that stay in this state ?

----------

## NeddySeagoon

christophe_y2kP,

You need to change the Preferred Minor : 127 to Preferred Minor : 2 in the raid superblock.

I don't know how you edit that, or indeed if you can.

----------

## christophe_y2k

for my swap probleme ...

i stop swap

```
# swapoff /dev/md127
```

i modifie /etc/fstab to point swap to /dev/md2 

# <fs>                  <mountpoint>    <type>          <opts>          <dump/pass>

# NOTE: If your BOOT partition is ReiserFS, add the notail option to opts.

/dev/md1                /boot           ext4            noauto,noatime  1 2

/dev/md3                /               ext4            noatime         0 1

/dev/md2                none            swap            sw              0 0

/dev/md4                /zoneminder     ext4            noatime         0 0

/dev/cdrom              /mnt/cdrom      auto            noauto,ro       0 0

#/dev/fd0               /mnt/floppy     auto            noauto          0 0

# glibc 2.2 and above expects tmpfs to be mounted at /dev/shm for

# POSIX shared memory (shm_open, shm_unlink).

# (tmpfs is a dynamically expandable/shrinkable ramdisk, and will

#  use almost no memory if not populated with files)

shm                     /dev/shm        tmpfs           nodev,nosuid,noexec     0 0

end a modify and uncomment in /etc/mdadm.conf my dev/md2 array

#ARRAY /dev/md1 metadata=0.90 UUID=3a7ff37a:477a12e9:cb201669:f728008a

ARRAY /dev/md2 metadata=0.90 UUID=e921c98e:33dd5bdd:cb201669:f728008a

#ARRAY /dev/md3 metadata=0.90 UUID=cac59e32:21ccf179:cb201669:f728008a

ARRAY /dev/md4 metadata=1.2 name=livecd:zoneminder UUID=6ef11c11:5744f8ac:1037aac1:26588ba4

and i reboot with succes

only warning message at shutdown /dev/md3 say in use but that ok at reboot

Many Thanks for your help And ..."Bonne fêtes de fin d'année"

----------

## christophe_y2k

Happy New Year 2K11   :Wink: 

Bonne Année @ tous et toutes  :Wink: 

----------

