Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RAID1 dissappears after reboot

Status
Not open for further replies.

allywilson

Technical User
Nov 27, 2002
157
0
0
GB
Hi all,
A little background is needed here I think...

I have my OS installed on /dev/sda.
I had a single drive for storage at /dev/sdb

I've bought another identical drive for storage and want to RAID1 them. It's located at /dev/sdc.

I used fdisk to create /dev/sdc1 with type fd (Linux RAID Autodetect).

I then ran
Code:
sudo mdadm --create --verbose /dev/md_d0 --level=1 --raid-devices=1 /dev/sdc1

I then formatted /dev/md_d0 to be ext4 and mounted it at /media/raid.

So, I now copied the contents of /dev/sdb1 to /dev/md_d0.

I unmounted /dev/sdb1.

I then ran:
Code:
mdadm --add /dev/md_d0 /dev/sdb1
mdadm --grow /dev/md_d0 --raid-devices=2

I then monitored /proc/mdstat until I seen it had successfully rebuilt the array.

I modified fstab to have the following:
Code:
/dev/md_d0	/media/raid	ext4	relatime,errors=remount-ro	0	1

and I could successfully mount /media/raid.

If I reboot, it doesn't automount. Worse than that, if I manually mount it I get a bad superblock error
Code:
mount: wrong fs type, bad option, bad superblock on /dev/md_d0,
       missing codepage or helper program, or other error
       (could this be the IDE device where you in fact use
       ide-scsi so that sr0 or sda or so is needed?)

I have to run the following:
Code:
sudo mdadm --run /dev/md_d0
Which allows me to mount /dev/raid but mdstat only shows /dev/sdc1 as being active.
I then have to run:
Code:
sudo mdadm --add /dev/md_d0 /dev/sdb1
and it will start rebuilding the array again.

How can I stop it from always needing to rebuild the array? As well as be active and automount?

Any help appreciated :)
 
What distro are you using?

Try assembling the array instead of adding, which will always force a rebuild.

After /proc/mdstat shows the array in good order do this as root
Code:
mdadm --scan --detail >> /etc/mdadm.conf
to make a basic configuration file. You can add an email address to send alerts, see [green][tt]man mdadm.conf[/tt][/green] for the proper syntax.

Make sure the kernel module [blue]dm_mod[/blue] and [blue]raid1[/blue] are loaded at boot and the mdadm service is set to run at boot, runlevel 3 & 5 should do.

FYI, I'm used to creating my arrays like so
Code:
mdadm -C /dev/md_d0 -ap -l1 -n2 <disk1> <disk2>
which mirrors the entire device, not a partition. I then [green][tt]fdisk /dev/md_d0[/tt][/green] to create my partitions atop the array which gives me device names like [tt]/dev/md_d0p1[/tt] for my newly created partition. From my experience most distros will not handle this type of naming and use md0, md1 and so on for each partition on the same physical drive.

 
Thanks for the help, appreciate it.

Sorry for not getting back sooner, but I was getting myself confused all the time.

When I booted up /proc/mdstat would show the array as inactive with 1 out of 2 mirrors available. If I did
Code:
sudo mdadm --run /dev/md_d0
it would be active but still with only 1 out of 2 devices.

In the end I did the following:
Code:
sudo mdadm --stop /dev/md_d0
sudo mdadm --auto-detect
sudo cp /etc/mdadm/mdadm.conf /etc/mdadm/mdadm.conf.old
sudo cp /etc/mdadm.conf /etc/mdadm.conf.old
sudo /usr/share/mdadm/mkconf force-generate /etc/mdadm/mdadm.conf

I think I was getting confused because I have /dev/md0/d0 and /dev/md_d0 as well as 2 mdadm.conf files as well.

So, now I have a RAID1 with both /dev/sdb1 and /dev/sdc1 as devices, it automounts at startup and no longer rebuilds all the time :)

Thanks!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top