- Unix Commands Reference
- Unix Commands - Home
dmraid Command in Linux
The Linux dmraid command manages RAID setups using the Linux device mapper feature. The Redundant Array of Independent Disks (RAID) is a technology that combines multiple physical disks into one logical disk to achieve data redundancy. It is a useful technology that protects data and improves disk performance.
The dmraid command identifies the software RAID using RAID metadata. After discovering the RAID devices, the dmraid command can activate the RAID sets, display their properties, and provide access through device mapper nodes.
Table of Contents
Here is a comprehensive guide to the options available with the dmraid command −
- Prerequisites for Using dmraid Command
- Syntax of dmraid Command
- dmraid Command Options
- Examples of dmraid Command in Linux
Prerequisites for Using dmraid Command
The dmraid command line utility may not be installed in Linux. To verify, check its version −
dmraid -V
If it is not installed then install it on Ubuntu, Debian, and Debian-based distributions using −
sudo apt install dmraid
To verify the installation, check the version again.
Syntax of dmraid Command
The general syntax of the Linux dmraid command is as follows −
dmraid [options] [raid_set | device_path]
The [options] field is used to specify the options for activating, deactivating and managing the RAID sets. The [raid_set | device_path] option is used to mention the RAID set or device path according to the required task.
dmraid Command Options
The options for the dmraid command are listed in the table below −
Options | Description |
---|---|
-a (--activate) y|n|yes|no | To activate and deactivate the RAID sets |
-b (--block_devices) | To display the block devices associated with the RAID sets |
-h (--help) | To display help related to the command |
-l (--list_formats) | To list the supported RAID formats |
-R (--rebuild) | To rebuild the RAID set |
-x (--remove) | To remove the RAID set |
-C (--create) | To create a new RAID set |
-S (--spare) | To create a spare RAID set |
-r (--raid_devices) | To display the RAID devices |
-D (--dump_metadata) | To display the metadata of RAID devices |
-E (--erase_metadata) | To erase the RAID metadata |
-s (--sets) | To display RAID sets |
-V (--version) | To display the command version |
The formatting options are listed below −
Flags | Options | Description |
---|---|---|
-d | --debug | To enable debug output |
-v | --verbose | To get verbose output |
-i | --ignorelocking | To ignore device locking |
-f format | --format format | To specify the RAID format |
-P char | --partchar char | To specify the character to denote the RAID partition |
-p | --no_partitions | To not handle the RAID partitions |
-Z | --rm_partitions | To remove the RAID partitions |
--separator | To specify the separator for output fields | |
-t | --test | To perform a test before making actual changes |
-c field | --column field | To display the specific column |
--type raidlevel | To specify the RAID level (raid0, raid1, raid2.) | |
--size= setsize | To specify the size of the RAID set | |
--strip size | To specify the strip size | |
--disk path | To specify the device path for the RAID set | |
-M path | --media path | To specify the spare disk device path |
Examples of dmraid Command in Linux
This section demonstrates the use of the dmraid command in Linux −
- Listing Supported RAID Formats
- Activating and Deactivating the RAID Sets
- Activating and Deactivating a Specific RAID Set
- Creating a RAID Set
- Rebuilding a RAID Set
- Removing a RAID Set
- Displaying RAID Associated Block Devices
- Displaying Help
Listing Supported RAID Formats
To list the supported RAID formats, use the -l or --list_formats options with the dmraid command −
dmraid -l
There are 12 different RAID format types as shown in the above output.
Activating and Deactivating the RAID Sets
To activate all the RAID sets, use the -a or --activate option with y or yes. The sudo privileges are needed for this operation −
sudo dmraid -ay
To deactivate all the RAID sets, use n or no −
sudo dmraid -an
To activate all the RAID sets of a specific format, use the -f or --format options. For example, to activate all the lsi format RAID sets, use −
sudo dmraid -ay -f lsi
Activating and Deactivating a Specific RAID Set
To activate and deactivate a specific RAID set first list the available RAID set, using the -r option −
dmraid -r
After identifying the RAID set name, use the name with -ay or -an options −
sudo dmraid -ay hpt45x_chidjhaiaa-1
In the above command, hpt45x_chidjhaiaa-1 is the RAID set name. To deactivate, replace y with n.
Creating a RAID Set
To create a RAID set, use the -C or --create option. For example, to create an Intel Software RAID of raid level 1, use the following command −
sudo dmraid -f isw isw_raid_set --type 1 --size=150000 --strip=256 --disk "/dev/sda /dev/sdb"
In the above command, the -f option is used to specify the RAID format, which is isw in this case. The isw_raid_set is the set name, and --type 1 indicates the raid level 1. The RAID size is set to 150000 blocks, and the --strip is 256 KB. The --disk option is used to specify the disk paths to include in the RAID set.
Rebuilding a RAID Set
To rebuild a RAID set, identify the RAID set name using the -r option. After identifying it, use the -R or --rebuild option to rebuild it.
sudo dmraid -R hpt45x_chidjhaiaa-1 /dev/sda
Here, the /dev/sda is the device path to use for rebuilding the RAID set.
Removing a RAID Set
To remove the RAID set, use the -x or --remove option with the RAID set name −
sudo dmraid -x hpt45x_chidjhaiaa-1
Here, hpt45x_chidjhaiaa-1 is the RAID set name, it can be different in your case.
Displaying RAID Associated Block Devices
To display the block devices associated with the RAID sets, use the -b or --block_devices option −
sudo dmraid -b
To get verbose output use the -v or --verbose options −
sudo dmraid -vb
Displaying Help
To display help related to the dmraid command, use the -h or >--help options −
dmraid -h
Conclusion
The dmraid command in Linux identifies, manages, and creates RAID sets. RAID sets are used to achieve data redundancy. Moreover, they secure data and maintain its integrity.
The dmraid is a powerful tool to create and manage RAID sets, which includes creating, rebuilding, or removing RAID sets. It can also be used to deactivate all or the specific RAID sets.
This tutorial explained the dmraid command, its syntax, options, and usage through various examples.