2

I have been looking around for a suitable tutorial to help me set up a RAID0 across two (or more) drives, but not moving the actual installation of Linux Mint onto that RAID setup.

A coworker had pointed me to this tutorial, and I could not make heads, nor tails of it.

4
  • 1
    The tutorial looks pretty clear (you actually only need steps 1 and 2). Which parts are you having trouble understanding or doing?
    – jordanm
    Commented Mar 21, 2013 at 3:11
  • @jordanm I think my biggest thing is that the author uses hard values for his devices instead of references. I'm not sure how I would modify the given commands to point to my specific drives instead of his example drives, and change it to raid0 instead of raid1.
    – Phill.Zitt
    Commented Mar 21, 2013 at 3:22
  • 1
    The /dev/sdb1 and /dev/sdb2 are the partitions, replace those. --level=1 is what specifies the level. Note that he is creating two RAID1 volumes. See man mdadm for the full documentation.
    – jordanm
    Commented Mar 21, 2013 at 3:30
  • @jordanm nevermind. that was exactly what I needed to give it a spin. Thank you very much for your help.
    – Phill.Zitt
    Commented Mar 23, 2013 at 16:21

1 Answer 1

3

In this answer, let it be clear that all your data will be destroyed on both of the array members (drives), so back it up first!

Open terminal and become root (su); if you have sudo enabled, you may also do for example sudo -i; see man sudo for all options):

sudo -i

Install necessary and optional software needed.

Prerequisites, these are necessary:

Optional software to fully correspond with this answer, you may do without them:

I recommend installing all of it:

apt-get install mdadm gdisk pv util-linux iotop gparted

First, we should erase the drives, if there was any data and filesystems before, that is. Suppose we have 2 members: sda and sdb.

pv < /dev/zero > /dev/sda
pv < /dev/zero > /dev/sdb

Alternately, if you are running each command with sudo, this part would look like this:

sudo bash -c 'pv < /dev/zero > /dev/sda'
sudo bash -c 'pv < /dev/zero > /dev/sdb'

To double-check if there is nothing left behind, you may peek with GParted on both of the drives, and if there is any filesystem other than unknown, wipe it:

wipefs -a /dev/sda
wipefs -a /dev/sdb

You should partition the drives, depending on, whether you want MBR or GPT:

fdisk /dev/sdX

or

gdisk /dev/sdX

Supposing you would use the new standard, GPT that is.

We initialize both of the drives with GUID partition table (GPT):

gdisk /dev/sda
gdisk /dev/sdb

In both cases use the following:

o Enter for new empty GUID partition table (GPT)
y Enter to confirm your decision
w Enter to write changes
y Enter to confirm your decision

Don't do this with GParted, because it would create a filesystem in the process, which we don't want, use gdisk again:

gdisk /dev/sda
gdisk /dev/sdb

In both cases use the following:
n Enter for new partition
Enter for first partition
Enter for default of the first sector
Enter for default of the last sector
fd00 Enter for Linux RAID type
w Enter to write changes
y Enter to confirm your decision

To triple-check if there is nothing left behind, you may peek with GParted on both of the newly created partitions, and if they contain any filesystem other than unknown, wipe it:

wipefs -a /dev/sda1
wipefs -a /dev/sdb1

You can examine the drives now:

mdadm --examine /dev/sda /dev/sdb

It should say in parentheses (type ee) now.

If it does, we now examine the partitions:

mdadm --examine /dev/sda1 /dev/sdb1

It should say No md superblock detected now.

If it does, we can create the RAID0 array:

mdadm --create /dev/md0 --level=0 --raid-devices=2 /dev/sda1 /dev/sdb1

We shall wait until the array is fully created, this process we may watch with:

watch -n 1 cat /proc/mdstat

After creation of the array, we should look at its detail:

mdadm --detail /dev/md0

It should say Active devices: 2, Working devices: 2 and that State: clean.

Now we create filesystem on the array, if you use ext4, this is better to be avoided, because of ext4lazyinit would take noticeable amount of time, hence the name, "lazyinit":

mkfs.ext4 /dev/md0

Instead, you should force a full instant initialization with:

mkfs.ext4 -E lazy_itable_init=0,lazy_journal_init=0 /dev/md0

By specifying these options, the inodes and the journal will be initialized immediately during creation.

If you chose to take a shortcut and created the ext4 filesystem with the "better avoided command", note that ext4lazyinit will take noticeable amount of time to initialize all of the inodes, you may watch it until it is done, e.g. with:

iotop

Either way you choose to make the file system initialization, you should mount it after it has done its initialization:

We now create some directory for this RAID0 array:

mkdir -p /mnt/raid0

And simply mount it:

mount /dev/md0 /mnt/raid0

Since we are essentially done, we may use GParted again to quickly check if it shows linux-raid filesystem, together with the raid flag on both of the drives.

If it does, we properly created the RAID0 array with GPT partitions and can now copy files on it.

Now we need to edit fstab, with your favorite text editor:

nano /etc/fstab

And add add an entry to it:

/dev/md0                /mnt/raid0              ext4    defaults        0 0

You may check if it is correct, after you save the changes:

mount -av | grep raid0

It should say already mounted.

If it does, we save the array configuration:

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

Check if you did everything according to plan, and if so, you may restart:

reboot
1
  • you could add commands for gparted if you're mentioning them. Otherwise works perfectly fine.
    – Airstriker
    Commented Mar 15, 2023 at 19:21

Not the answer you're looking for? Browse other questions tagged .