2005-04-17 02:20:36 +04:00
|
|
|
dm-stripe
|
|
|
|
=========
|
|
|
|
|
|
|
|
Device-Mapper's "striped" target is used to create a striped (i.e. RAID-0)
|
|
|
|
device across one or more underlying devices. Data is written in "chunks",
|
|
|
|
with consecutive chunks rotating among the underlying devices. This can
|
|
|
|
potentially provide improved I/O throughput by utilizing several physical
|
|
|
|
devices in parallel.
|
|
|
|
|
|
|
|
Parameters: <num devs> <chunk size> [<dev path> <offset>]+
|
|
|
|
<num devs>: Number of underlying devices.
|
2012-07-27 18:08:01 +04:00
|
|
|
<chunk size>: Size of each chunk of data. Must be at least as
|
|
|
|
large as the system's PAGE_SIZE.
|
2005-04-17 02:20:36 +04:00
|
|
|
<dev path>: Full pathname to the underlying block-device, or a
|
|
|
|
"major:minor" device-number.
|
|
|
|
<offset>: Starting sector within the device.
|
|
|
|
|
|
|
|
One or more underlying devices can be specified. The striped device size must
|
2012-07-27 18:08:00 +04:00
|
|
|
be a multiple of the chunk size multiplied by the number of underlying devices.
|
2005-04-17 02:20:36 +04:00
|
|
|
|
|
|
|
|
|
|
|
Example scripts
|
|
|
|
===============
|
|
|
|
|
|
|
|
[[
|
|
|
|
#!/usr/bin/perl -w
|
|
|
|
# Create a striped device across any number of underlying devices. The device
|
|
|
|
# will be called "stripe_dev" and have a chunk-size of 128k.
|
|
|
|
|
|
|
|
my $chunk_size = 128 * 2;
|
|
|
|
my $dev_name = "stripe_dev";
|
|
|
|
my $num_devs = @ARGV;
|
|
|
|
my @devs = @ARGV;
|
|
|
|
my ($min_dev_size, $stripe_dev_size, $i);
|
|
|
|
|
|
|
|
if (!$num_devs) {
|
|
|
|
die("Specify at least one device\n");
|
|
|
|
}
|
|
|
|
|
2016-09-01 22:38:30 +03:00
|
|
|
$min_dev_size = `blockdev --getsz $devs[0]`;
|
2005-04-17 02:20:36 +04:00
|
|
|
for ($i = 1; $i < $num_devs; $i++) {
|
2016-09-01 22:38:30 +03:00
|
|
|
my $this_size = `blockdev --getsz $devs[$i]`;
|
2005-04-17 02:20:36 +04:00
|
|
|
$min_dev_size = ($min_dev_size < $this_size) ?
|
|
|
|
$min_dev_size : $this_size;
|
|
|
|
}
|
|
|
|
|
|
|
|
$stripe_dev_size = $min_dev_size * $num_devs;
|
|
|
|
$stripe_dev_size -= $stripe_dev_size % ($chunk_size * $num_devs);
|
|
|
|
|
|
|
|
$table = "0 $stripe_dev_size striped $num_devs $chunk_size";
|
|
|
|
for ($i = 0; $i < $num_devs; $i++) {
|
|
|
|
$table .= " $devs[$i] 0";
|
|
|
|
}
|
|
|
|
|
|
|
|
`echo $table | dmsetup create $dev_name`;
|
|
|
|
]]
|
|
|
|
|