Find the answer to your Linux question:
Results 1 to 3 of 3
I am trying to setup a new RAID 1 array with two 500GB disks. I read up on everything, and I know I setup the array properly, but I have ...
  1. #1
    Just Joined!
    Join Date
    Nov 2004
    Posts
    48

    mdadm array disappears

    I am trying to setup a new RAID 1 array with two 500GB disks. I read up on everything, and I know I setup the array properly, but I have several problems.

    1) When I go to issue the following commands:

    echo "DEVICE partitions" > mdadm.conf
    mdadm --detail --scan >> mdadm.conf

    I get a "permission denied" error. I have issued them using sudo, but I still get the same results.

    2) The biggest problem is that when I restart my array does not automatically reappear. This is a problem since the data will be shared VIA Samba across a network.

    In order to get the array back I have to do the following:

    sudo mdadm -A /dev/md0 /dev/sda1 /dev/sdb1
    sudo cat /proc/mdstat (I do this to make sure the array is now showing, and it is)
    sudo /etc/init.d/samba restart

    This will get me where I need to be, however I may not be around to do this if there is a power failure. Does anyone know how to get an mdadm array to mount automatically at boot time?

    I have also added the following to my /etc/fstab file, but no dice:

    /dev/md0 /var/shared ext3 defaultS 0 0

  2. #2
    Just Joined!
    Join Date
    Nov 2004
    Posts
    48
    I have created a shell script that will reactivate and remount the array at boot time (I installed it using update-rc.d). I have included the code below, which some people may find handy.

    Please note that you will have to edit this script, since I have tailored it for my needs. If you understand how to do everything by hand, editing the script should be cake. E-mail me if you have any questions about the script

    Code:
    #!/bin/bash
    #
    # Author: Chris Burwell (cburwell@comcast.net)
    # Created: April 03, 2007
    # Updated: April 04, 2007
    # Function: Used to mount a mdadm raid array to
    #               a Debian system.
    #
    #
    # Start functiomn
    #
    start() {
            # Check if md0 device is active
            ARRAYTEST=$(echo $(awk '/md0/' /proc/mdstat))
            if [ -z "$ARRAYTEST" ] ; then
                    echo "Re-adding array: /dev/md0" &
                    mdadm -A /dev/md0 /dev/sda1 /dev/sdb1
            else
                    echo "RAID array exsists!" &
            fi
    
            # Check if array is mounted
            MOUNTTEST=$(echo $(mount|awk '/md0/'))
            if [ -z "$MOUNTTEST" ] ; then
                    # Mount array
                    echo "Mounting /dev/md0 to /var/shared" &
                    mount /dev/md0 /var/shared
            else
                    echo "Array has already been mounted!" &
                    echo "Exiting!" &
            fi
    
            # Restart Samba
            echo "Restarting samba with: /etc/init.d/samba" &
            /etc/init.d/samba restart
    }
    
    #
    # Stop function
    #
    stop() {
            # Unmount array
            echo "Unmounting: /var/shared" &
            umount /var/shared
    }
    
    #
    # Status function
    #
    status() {
            # Print array information
            echo "ARRAY INFORMATION" &
            echo "------------------" &
    
            # Print mount information
            echo "ARRAY MOUNT INFORMATION" &
            echo "------------------" &
    }
    case "$1" in
            start)
                    start
                    ;;
            stop)
                    stop
                    ;;
            restart)
                    stop
                    start
                    ;;
            status)
                    status
                    ;;
            *)
                    echo "Usage: {start|stop|restart|status}"
                    exit 1
                    ;;
    esac
    exit

  3. #3
    Just Joined!
    Join Date
    Sep 2008
    Posts
    1
    OK, I know this is an old thread, but in case anyone else finds it while scratching their head

    Note that this I was using Red Hat Enterprise 3 (RHEL3) but I suspect it applies to others as well. However, your milege may vary...

    I fixed this problem by doing mkinitrd with the md device running. It appears initrd needs to know you're using md for the autodetect to work.

    cd /boot
    mkinitrd <initrdname> <kernel-ver>

    FFI see man mkinitrd

    Chris

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •