# shutdown problem with / on raid device

## bendy

Hi,

I have gentoo installed with /boot on a regular disk partition and everything else on raid partitions.  My /etc/fstab:

```
/dev/sda2               /boot           ext2            noauto,noatime  1 2

/dev/md1                /               ext3            noatime         0 1

/dev/sda3               none            swap            sw              0 0

/dev/md2                /home           ext3            noatime         0 0

/dev/md3                /var            reiserfs        noatime,notail  0 0

tmpfs                   /tmp            tmpfs           defaults,nosuid,size=1024M,mode=1777 0 0

/dev/md5                /work           xfs             noatime         0 0

/dev/cdroms/cdrom0      /mnt/cdrom      iso9660         noauto,ro       0 0

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

and my /etc/mdadm.conf:

```
ARRAY /dev/md1 level=raid0 num-devices=2 UUID=bc3bbaf3:6628c7ba:2b02e604:8457fd23

ARRAY /dev/md2 level=raid0 num-devices=2 UUID=b1cea3ab:38398ed5:e0899131:e0e10697

ARRAY /dev/md3 level=raid0 num-devices=2 UUID=54c94f7c:ef16bbe1:19e5e8a0:2413d932

ARRAY /dev/md4 level=raid0 num-devices=2 UUID=d6dbfe2b:fb028dde:2238324a:d30b674d

ARRAY /dev/md5 level=raid0 num-devices=2 UUID=a9989cd6:2d88afe3:fad10696:9af35823
```

This has been working fine for quite some time.  However I recently decided to run my system ~arch as I had so many packages added to package.keywords file.  This included an upgrade to gentoo-sources-2.6.28-r2, which I compiled with raid auto-detection.

The problem is that my system will no longer shut-down cleanly.  I get:

```
* mdraid uses addon code which is deprecated

* and may not be available in the future.

* shutting down RAID devices (mdadm)...

mdadm : stopped /dev/md2

mdadm : stopped /dev/md3

mdadm : stopped /dev/md4

mdadm : stopped /dev/md5

mdadm: fail to stop array /dev/md1: Device or resource busy

Perhaps a running process, mounted filesystem or active volume group?

* ERROR: mdraid failed to stop

.

.

.

* Remounting remaining filesystems read-only...

* Remounting / read only...

INIT: no more processes left in this runlevel.
```

Then it freezes, although I can force it with alt-sysreq-u and alt-sysreq-b.

Anyone got any ideas what changed recently to stop my machine shutting down properly?

Thanks!

----------

## richard.scott

Hi,

This is just a warning that / can't be unmounted as its currently in use... I get this too, its nothing to worry about.

To get your system to power off you need to compile your APM or ACPI options as static rather than modules.

Hope this helps,

Rich

----------

## JanSteen

Hi,

Same problem here, started occurring very recently, since my last update I presume. Before, already for some months, I seem to remember that warning you also get,

```
* mdraid uses addon code which is deprecated

* and may not be available in the future. 
```

It could be that that warning started appearing since I switched to OpenRC? Not sure.

Anyhow, lately my machine also refuses to power off, even though I do have (and already had) all ACPI options compiled into the kernel instead of as modules.

I'll post a reply if I find a solution; anybody else with the same trouble?

CS

----------

## snailhead

 *bendy wrote:*   

> Hi,
> 
> I have gentoo installed with /boot on a regular disk partition and everything else on raid partitions.  My /etc/fstab:
> 
> ```
> ...

 

If I were guess, the script /lib/rcscripts/addons/raid-stop.sh changed, with the key line using mdadm -Ss (scan the config file and shutdown the listed raid devices).  I would presume that using mdadm is the "new school"

```
[ -f /proc/mdstat ] || exit 0

# Stop software raid with mdadm (new school)

mdadm_conf="/etc/mdadm/mdadm.conf"

[ -e /etc/mdadm.conf ] && mdadm_conf="/etc/mdadm.conf"

if [ -x /sbin/mdadm -a -f "${mdadm_conf}" ] ; then

   ebegin "Shutting down RAID devices (mdadm)"

   output=$(mdadm -Ss 2>&1)

   ret=$?

   [ ${ret} -ne 0 ] && echo "${output}"

   eend ${ret}

fi

```

This is a pretty simple script called by halt.sh.  I propose the following script instead, but it isn't simpler   :Confused: 

```
[ -f /proc/mdstat ] || exit 0

# Stop software raid with mdadm, but check for md on root

mdadm_conf="/etc/mdadm/mdadm.conf"

[ -e /etc/mdadm.conf ] && mdadm_conf="/etc/mdadm.conf"

if [ -x /sbin/mdadm -a -f "${mdadm_conf}" ] ; then

   ebegin "Shutting down RAID devices (mdadm)"

   for i in `ls -t /dev/md` ; do

      mounted=`mount | egrep "md${i} on / "`

      if [ -n "${mounted}" ] ; then

         echo /dev/md${i} is mounted on root and should *not* be stopped

         ret=0

      fi

      if [ -z "${mounted}" ] ; then

         active=`cat /proc/mdstat | egrep active | egrep md${i}`

         ret=0

         if [ -n "${active}" ] ; then

            output=$(mdadm -S /dev/md${i})

            ret=$?

         fi

      fi

      [ ${ret} -ne 0 ] && echo "${output}" && return=$?

   done

   eend ${return}

fi
```

----------

## richard.scott

Hi snailhead,

That new script would make more sense. 

I don't list any md devices in my /etc/mdadm.conf file... come to think of it, I've never edited that file on any raid system I manage.

Perhaps you could submit a bug request for the relevant package and see if we can get this changed?

Rich.

----------

## ClientAlive

Me too but my system is a little more complex in how it's set up. I'm having difficulty finding related info.

----------

