Skip to content

Instantly share code, notes, and snippets.

@bczhc
Last active April 8, 2022 13:44
Show Gist options
  • Save bczhc/87a01cd976fad1a5ee566c64d1e570a6 to your computer and use it in GitHub Desktop.
Save bczhc/87a01cd976fad1a5ee566c64d1e570a6 to your computer and use it in GitHub Desktop.
Linux线性拼接多设备文件
#!/bin/bash
if [ $# -lt 2 ]; then
echo "Usage: command <joined-name> <device-to-join>..."
exit
fi
joined_name=$1
shift
offset=0
for arg in "$@"; do
size=$(blockdev --getsz "$arg")
echo "$offset $size linear $arg 0"
offset=$((offset+size))
done | dmsetup create "$joined_name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment