Skip to content

Instantly share code, notes, and snippets.

@ewindisch
Created October 8, 2009 22:00
Show Gist options
  • Save ewindisch/205454 to your computer and use it in GitHub Desktop.
Save ewindisch/205454 to your computer and use it in GitHub Desktop.
device mapper alias resolver
#!/bin/bash
for line in $(iostat $(dmsetup ls | sed -n '/swap/{ s/.*, //; s/)//; s/^/dm-/; p; }') | sed 's/\s\+/,/g'); do
if (echo $line | grep ^dm- >/dev/null 2>&1); then
dm=$(echo $line | cut -d, -f1 | cut -d- -f2);
dname=$(dmsetup info -c --noheadings -j 253 -m $dm | cut -d: -f1);
echo $line |
sed "s/^dm-$dm/$dname/; s/,/\t\t/g;";
else
echo "$line" | sed 's/,/\t\t/g;';
fi
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment