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 at least as
  11. 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 multiplied by the number of underlying devices.
  17. Example scripts
  18. ===============
  19. [[
  20. #!/usr/bin/perl -w
  21. # Create a striped device across any number of underlying devices. The device
  22. # will be called "stripe_dev" and have a chunk-size of 128k.
  23. my $chunk_size = 128 * 2;
  24. my $dev_name = "stripe_dev";
  25. my $num_devs = @ARGV;
  26. my @devs = @ARGV;
  27. my ($min_dev_size, $stripe_dev_size, $i);
  28. if (!$num_devs) {
  29. die("Specify at least one device\n");
  30. }
  31. $min_dev_size = `blockdev --getsize $devs[0]`;
  32. for ($i = 1; $i < $num_devs; $i++) {
  33. my $this_size = `blockdev --getsize $devs[$i]`;
  34. $min_dev_size = ($min_dev_size < $this_size) ?
  35. $min_dev_size : $this_size;
  36. }
  37. $stripe_dev_size = $min_dev_size * $num_devs;
  38. $stripe_dev_size -= $stripe_dev_size % ($chunk_size * $num_devs);
  39. $table = "0 $stripe_dev_size striped $num_devs $chunk_size";
  40. for ($i = 0; $i < $num_devs; $i++) {
  41. $table .= " $devs[$i] 0";
  42. }
  43. `echo $table | dmsetup create $dev_name`;
  44. ]]