striped.txt 1.8 KB

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