USB Device Linear RAID

Jarret B

Well-Known Member
Staff member
Joined
May 22, 2017
Messages
339
Reaction score
369
Credits
11,689
Redundant Array of Inexpensive Disks (RAID) is an implementation to either improve performance of a set of disks and/or allow for data redundancy. Reading and writing performance issues can be helped with RAID. RAID is made up of various levels. This article covers Linear RAID and how to implement it on a Linux system.

Linear RAID Overview

Linear RAID is similar RAID 0 or Disk Striping without the Striping. Data is written to each disk until it is full and then the data is written to the next disk and so on until the whole Linear RAID Array is full.

Linear RAID allows the combination of disks into one large disk. No redundancy is provided to allow to keep data safe in the case of a disk failure.

HARDWARE

For Linear RAID two or more disks are required to create one large RAID Array Disk drive. Other RAID implementations require all disks to be the same size, or partitioned the same size, Linear RAID does not.

The RAID Array does not provide any enhancements in the Read/Write speed and without redundancy, there is no data protection. The only benefit is that a disk of specified size is needed and one must be set up on short notice. Using Linear RAID on a day-to-day basis is not wise or recommended.

To create a Linear RAID Array, I will use two USB drives called BLUE and LEXAR. BLUE is a Sandisk Cruzer Switch which is USB 2.0 compliant and has a storage of 4 GB (3.7GB). The LEXAR is a PNY Attache that is also USB 2.0 compliant and has a storage capacity of 8 GB (7.4 GB).

To set up the RAID Array you use the command 'mdadm'. If you do not have the file on your system you will receive an error in a terminal when you enter the command 'mdadm'.

To get the file on your system use Synaptic, or the like, for your Linux distro.

Once installed, you are ready to make a Linear RAID Array.

Creating the RAID Array

Open a terminal and type 'lsblk' to get a list of your available drives. Make a note of the drives you are using so you do not type in the wrong drive and add it to the Array.

NOTE: Entering the wrong drive can cause a loss of data.

From the listing of the command from above, I am using sdc1 and sde1. The command is as follows:

sudo mdadm --create /dev/md0 --level=linear --raid-devices=2 /dev/sdc1 /dev/sde1 --verbose

The command creates (--create) a RAID Array called md0. The RAID Level is Linear and two devices are being used to create the RAID Array – sdc1 and sde1.

The following should occur:

jarret@Symple-PC ~ $ sudo mdadm --create /dev/md0 --level=linear --raid-devices=2 /dev/sdc1 /dev/sde1 --verbose
mdadm: /dev/sdc1 appears to be part of a raid array: level=raid0 devices=0 ctime=Wed Dec 31 19:00:00 1969
mdadm: partition table exists on /dev/sdc1 but will be lost or meaningless after creating array
mdadm: /dev/sde1 appears to be part of a raid array: level=raid0 devices=0 ctime=Wed Dec 31 19:00:00 1969
mdadm: partition table exists on /dev/sde1 but will be lost or meaningless after creating array
Continue creating array?

NOTE: If you get an error that the device is busy, then remove 'dmraid'. In a Debian system use the command 'sudo apt-get remove dmraid' and when completed, reboot the system. After the system restarts try the 'mdadm' command again. You also have to use 'umount' to unmount the drives.

Answer 'y' to the question to 'Continue creating array?' and the following should appear:

mdadm: Defaulting to version 1.2 metadata
mdadm: array /dev/md0 started.

The RAID Array is created and running, but not yet ready for use.

Prepare md0 for use

You may look around, but the drive md0 is not to be found. Open the GParted application and you will see it there ready to be prepared for use.

By selecting /dev/md0 you will get an error that no Partition Table exists on the RAID Array. Select Device from the top menu and then 'Create Partition Table…'. Specify your partition type and click APPLY.

Now, create the Partition and select your file format to be used. It is suggested to use either EXT3 or EXT4 for formatting the Array. You may also want to select the RAID Flag. Add the Partition scheme. I gave a Label of “LINEAR” and then clicked APPLY to make all the selected changes. The drives should be formatted as selected and the RAID Array is ready to be mounted for use.

NOTE: The size of the RAID Array is equal to the combined disks. In my case, it is 11.21 GB.

Mount RAID Array

Before closing GParted look at the Partition name as shown in Figure 1. My Partition name is '/dev/md0p1'. The partition name is important for mounting.

Figure 01.jpg

FIGURE 01

You may be able to simply mount 'LINEAR' as I was able to do.

If the mount does not work, then try the following: Go to your '/media' folder and as ROOT create a folder, such as RAID, to be used as a mount point. In a terminal use the command 'sudo mount /dev/md0p1 /media/RAID' to mount the RAID Array as the media device named RAID.

Now you must take ownership of the RAID Array with the command:

sudo chown -R jarret:jarret /media/RAID

The command uses my username (jarret) and group name (jarret) to take ownership of the mounted RAID Array. Use your own username and mount point.

Auto Mount the RAID Array

To have the RAID Array auto mount after each reboot is a simple task. Run the command 'blkid' to get the needed information from the RAID Array. For example, to run it after I mounted my RAID mount point, I would get the following:

/dev/sda2: UUID="73d91c92-9a38-4bc6-a913-048971d2cedd" TYPE="ext4"
/dev/sda3: UUID="9a621be5-750b-4ccd-a5c7-c0f38e60fed6" TYPE="ext4"
/dev/sda4: UUID="78f175aa-e777-4d22-b7b0-430272423c4c" TYPE="ext4"
/dev/sda5: UUID="d5991d2f-225a-4790-bbb9-b9a48e691061" TYPE="swap"
/dev/sdb1: LABEL="My Book" UUID="54D8D96AD8D94ABE" TYPE="ntfs"
/dev/sdc1: LABEL="LEXAR" UUID="467E-EF08" TYPE="vfat"
/dev/sde1: LABEL="BLUE" UUID="4B82-E771" TYPE="vfat"
/dev/md0p1: LABEL="LINEAR" UUID="0bf01af6-1ad5-4752-9f8b-7b37204d605b" TYPE="ext4"

The needed information is the line with the partition '/dev/md0p1'. The Label is LINEAR and the UUID is '0bf01af6-1ad5-4752-9f8b-7b37204d605b' and the type is EXT4.

Edit the file '/etc/fstab' as ROOT using an editor you prefer and add a line similar to 'UUID= 0bf01af6-1ad5-4752-9f8b-7b37204d605b /media/RAID ext4 defaults 0 0'. Here the UUID is used from the blkid command. The mount point of '/media/RAID' shows where the mount point is located. The drive format of ext4 is used. Use the word 'defaults' and then '0 0'. Be sure to use a TAB between each set of commands.

Your Linear RAID drive Array should now be completely operational for use.

Removing the RAID Array

To stop the RAID Array, you need to unmount the RAID mount point then stop the device 'md0p1' as follows:

sudo umount -l /media/RAID
sudo mdadm --stop /dev/md0p1

Once done you need to reformat the drives and also remove the line from /etc/fstab which

enabled it to be be automounted.

Hope this helps you understand Linear RAID. Enjoy your RAID Array!
 
Last edited:

Members online


Top