striped.rst 1.8 KB

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