3

I have multiple external storage-spaces which can be mounted with samba/cifs.
Over these spaces I want to create a raid device.

My idea was the creation of data files with

dd if=/dev/zero of=/extStorages/storage[0..x]/data

Now I created loop devices with

losetup /dev/loop[0..x] /extStorages/storage[0..x]/data

And create the raid device on top of the loop devices

mdadm --create /dev/md/md0 --level=<level> --raid-devices=x /dev/loop0 .. /dev/loopx
mkfs.ext4 /dev/md/md0
mount /dev/md/md0 /Storage

This is working until the next reboot as the loop devices are not persistent.
Therefore mounting the raid on fstab isn't possible.

How can I solve this?

2

For persistency you have to write things to the mdamd config file:

mdadm --verbose --detail --scan >> /etc/mdadm.conf

To setup the loop devices explicitly I normally add some code in the /etc/rc.local. If you need to that, you can mount the raid from there as well.

1

I wrote a init.d script which start and stop the volume:

#! /bin/sh
### BEGIN INIT INFO
# Provides:          networkRaid
# Required-Start:    $network $named $remote_fs $syslog
# Required-Stop:
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: handles the 'network raid'
### END INIT INFO


PATH=/sbin:/usr/sbin:/bin:/usr/bin

. /lib/init/vars.sh
. /lib/lsb/init-functions

do_start() {
  losetup /dev/loop0 /extDrives/drive0/data
  losetup /dev/loop1 /extDrives/drive1/data
  losetup /dev/loop2 /extDrives/drive2/data

  mdadm --assemble /dev/md0 /dev/loop0 /dev/loop1 /dev/loop2

  mount /dev/md0 /Storage
}

do_stop() {
  umount /Storage

  mdadm --stop /dev/md0

  losetup -d /dev/loop0
  losetup -d /dev/loop1
  losetup -d /dev/loop2
}

case "$1" in
    start)
    do_start
        exit 0
        ;;
    restart|reload|force-reload)
        echo "Error: argument '$1' not supported" >&2
        exit 3
        ;;
    stop|status)
        do_stop
        exit 0
        ;;
    *)
        echo "Usage: $0 start|stop" >&2
        exit 3
        ;;
esac

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.