blob: 07ec492cceee961cc43221270eca228152615adb [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001dm-stripe
2=========
3
4Device-Mapper's "striped" target is used to create a striped (i.e. RAID-0)
5device across one or more underlying devices. Data is written in "chunks",
6with consecutive chunks rotating among the underlying devices. This can
7potentially provide improved I/O throughput by utilizing several physical
8devices in parallel.
9
10Parameters: <num devs> <chunk size> [<dev path> <offset>]+
11 <num devs>: Number of underlying devices.
Mike Snitzereb850de2012-07-27 15:08:01 +010012 <chunk size>: Size of each chunk of data. Must be at least as
13 large as the system's PAGE_SIZE.
Linus Torvalds1da177e2005-04-16 15:20:36 -070014 <dev path>: Full pathname to the underlying block-device, or a
15 "major:minor" device-number.
16 <offset>: Starting sector within the device.
17
18One or more underlying devices can be specified. The striped device size must
Mikulas Patockaf14fa692012-07-27 15:08:00 +010019be a multiple of the chunk size multiplied by the number of underlying devices.
Linus Torvalds1da177e2005-04-16 15:20:36 -070020
21
22Example scripts
23===============
24
25[[
26#!/usr/bin/perl -w
27# Create a striped device across any number of underlying devices. The device
28# will be called "stripe_dev" and have a chunk-size of 128k.
29
30my $chunk_size = 128 * 2;
31my $dev_name = "stripe_dev";
32my $num_devs = @ARGV;
33my @devs = @ARGV;
34my ($min_dev_size, $stripe_dev_size, $i);
35
36if (!$num_devs) {
37 die("Specify at least one device\n");
38}
39
Michael Witten95f21c52016-09-01 19:38:30 +000040$min_dev_size = `blockdev --getsz $devs[0]`;
Linus Torvalds1da177e2005-04-16 15:20:36 -070041for ($i = 1; $i < $num_devs; $i++) {
Michael Witten95f21c52016-09-01 19:38:30 +000042 my $this_size = `blockdev --getsz $devs[$i]`;
Linus Torvalds1da177e2005-04-16 15:20:36 -070043 $min_dev_size = ($min_dev_size < $this_size) ?
44 $min_dev_size : $this_size;
45}
46
47$stripe_dev_size = $min_dev_size * $num_devs;
48$stripe_dev_size -= $stripe_dev_size % ($chunk_size * $num_devs);
49
50$table = "0 $stripe_dev_size striped $num_devs $chunk_size";
51for ($i = 0; $i < $num_devs; $i++) {
52 $table .= " $devs[$i] 0";
53}
54
55`echo $table | dmsetup create $dev_name`;
56]]
57