Create RAID array of image files

8,331

Solution 1

To install the Linux software RAID you need to install the mdadm package.

sudo apt-get install mdadm

If you want to make a software RAID-0 from the three image files, you need to create loop devices for each image files:

sudo losetup /dev/loop1 image1.img
sudo losetup /dev/loop2 image2.img
sudo losetup /dev/loop3 image3.img

After you can create a RAID-0 array from them:

sudo mdadm --create /dev/md0 --level=0 --raid-devices=3 /dev/loop1 /dev/loop2 /dev/loop3

Solution 2

If your system matches the basic requirements you could use zfs (8 GB RAM, 64-bit system):

Add repo and update package list:

sudo add-apt-repository ppa:zfs-native/stable
sudo apt-get update

Install package:

sudo apt-get install ubuntu-zfs

Create a striped vdev (with no redundancy, but you asked for RAID0):

sudo zpool create vol0 ~/image[1-3].img

This creates the stripe and mounts it at /vol0.

sudo zfs create vol0/filesystem

This creates a zfs file system on the stripe and mounts it at /vol0/filesystem. Use

sudo zfs set mountpoint=/mnt/filesystem vol0/filesystem

if you want to change the mount point.

You can also add automatic compression:

sudo zfs create vol0/filesystem/compressed
sudo zfs set compression=on vol0/filesystem/compressed

Now everything you put into /mnt/filesystem/compressed will automatically be compressed.

Share:
8,331

Related videos on Youtube

Daniel
Author by

Daniel

Updated on September 18, 2022

Comments

  • Daniel
    Daniel over 1 year

    OK, so I've got three image files in /home/, and they each reside on different physical drives:

    image1.img
    
    image2.img
    
    image3.img
    

    Each image is the same size, and I want to put the images themselves into RAID0.

    How should I go about RAIDing them?

    EDIT: Using mdadm I get this error:

    enter image description here

    EDIT: Output of cat /proc/mdstat

    enter image description here

    EDIT: Output of sudo gparted /dev/md0

    enter image description here

    • lemonslice
      lemonslice over 8 years
      If I understand correctly, you want to have a RAID-0 drive which has thrice the size of the image files and is stripped between the three image files?
    • Daniel
      Daniel over 8 years
      Yes. The idea is to be able to create a RAID unit that can span multiple drives without actually placing the drives in RAID.
    • lemonslice
      lemonslice over 8 years
      What does cat /proc/mdstat say about this error?
    • Daniel
      Daniel over 8 years
      See edit to question
    • lemonslice
      lemonslice over 8 years
      What are the media below the image files? Based on the error message they do not support seek...
    • Daniel
      Daniel over 8 years
      They are blank. I'm trying to create a completely new and blank RAID disk
    • Daniel
      Daniel over 8 years
      I literally just did touch image#.img for each one. Is there something else I should do?
    • Daniel
      Daniel over 8 years
      And how should I do that?
    • lemonslice
      lemonslice over 8 years
  • Daniel
    Daniel over 8 years
    "E: Unable to locate package ubuntu-zfs"
  • Daniel
    Daniel over 8 years
    And this should also work with iso files, right?
  • Niclas Börlin
    Niclas Börlin over 8 years
    Forgot to add instructions on how to add the repo. Have edited now.
  • Niclas Börlin
    Niclas Börlin over 8 years
    I'm not sure what you mean with iso files... The instructions will create a blank file system striped over the 3 files in question. Do you have data in your iso files that you somehow wish to access on a striped partition?
  • Daniel
    Daniel over 8 years
    No, I was just curious as to whether or not it could be done with, say a DVD-RW for instance, or something like that.
  • Daniel
    Daniel over 8 years
    Still the same unable to find the package.
  • Niclas Börlin
    Niclas Börlin over 8 years
    I guess it could be done with a DVD-RW, but I fail to see the point.
  • Niclas Börlin
    Niclas Börlin over 8 years
    I forgot to add an update step. Have done so now.
  • Daniel
    Daniel over 8 years
    Aha! I'll try that.
  • Daniel
    Daniel over 8 years
    command mdadm not found
  • lemonslice
    lemonslice over 8 years
    You have to install the package mdadm.
  • Daniel
    Daniel over 8 years
    See edit to question
  • Daniel
    Daniel over 8 years
    That's with a fresh install of mdadm.