Documentation/admin-guide/device-mapper/unstriped.rst

Source file repositories/reference/linux-study-clean/Documentation/admin-guide/device-mapper/unstriped.rst

File Facts

System
Linux kernel
Corpus path
Documentation/admin-guide/device-mapper/unstriped.rst
Extension
.rst
Size
4314 bytes
Lines
136
Domain
Support Tooling And Documentation
Bucket
Documentation
Inferred role
Support Tooling And Documentation: documentation
Status
atlas-only

Why This File Exists

Repository support layer: documentation, build tooling, samples, user-space helper tools, generated initramfs support, licenses, and validation utilities.

Dependency Surface

Detected Declarations

Annotated Snippet

================================
Device-mapper "unstriped" target
================================

Introduction
============

The device-mapper "unstriped" target provides a transparent mechanism to
unstripe a device-mapper "striped" target to access the underlying disks
without having to touch the true backing block-device.  It can also be
used to unstripe a hardware RAID-0 to access backing disks.

Parameters:
<number of stripes> <chunk size> <stripe #> <dev_path> <offset>

<number of stripes>
        The number of stripes in the RAID 0.

<chunk size>
	The amount of 512B sectors in the chunk striping.

<dev_path>
	The block device you wish to unstripe.

<stripe #>
        The stripe number within the device that corresponds to physical
        drive you wish to unstripe.  This must be 0 indexed.


Why use this module?
====================

An example of undoing an existing dm-stripe
-------------------------------------------

This small bash script will setup 4 loop devices and use the existing
striped target to combine the 4 devices into one.  It then will use
the unstriped target on top of the striped device to access the
individual backing loop devices.  We write data to the newly exposed
unstriped devices and verify the data written matches the correct
underlying device on the striped array::

  #!/bin/bash

  MEMBER_SIZE=$((128 * 1024 * 1024))
  NUM=4
  SEQ_END=$((${NUM}-1))
  CHUNK=256
  BS=4096

  RAID_SIZE=$((${MEMBER_SIZE}*${NUM}/512))
  DM_PARMS="0 ${RAID_SIZE} striped ${NUM} ${CHUNK}"
  COUNT=$((${MEMBER_SIZE} / ${BS}))

  for i in $(seq 0 ${SEQ_END}); do
    dd if=/dev/zero of=member-${i} bs=${MEMBER_SIZE} count=1 oflag=direct
    losetup /dev/loop${i} member-${i}
    DM_PARMS+=" /dev/loop${i} 0"
  done

  echo $DM_PARMS | dmsetup create raid0
  for i in $(seq 0 ${SEQ_END}); do
    echo "0 1 unstriped ${NUM} ${CHUNK} ${i} /dev/mapper/raid0 0" | dmsetup create set-${i}
  done;

  for i in $(seq 0 ${SEQ_END}); do
    dd if=/dev/urandom of=/dev/mapper/set-${i} bs=${BS} count=${COUNT} oflag=direct
    diff /dev/mapper/set-${i} member-${i}
  done;

Annotation

Implementation Notes