--- /usr/bin/genfstab 2012-10-04 19:08:03.000000000 -0700 +++ genfstab 2012-11-11 13:25:27.306128006 -0800 @@ -71,6 +71,20 @@ printf '%s' "$out" } +normalize_dm() { + local raw="$1" mapped canon + if [[ $raw == /dev/dm-[0-9]* ]]; then + for mapped in /dev/mapper/*; do + canon=$(readlink -e "$mapped") + if [[ $raw == "$canon" ]]; then + echo "$mapped" + return + fi + done + fi + echo "$raw" +} + unmangle() { local i= chr= out= len=$(( ${#1} - 4 )) @@ -274,7 +288,7 @@ if [[ $type = file ]]; then printf '%-20s' "$device" else - write_source "$(unmangle "$device")" + write_source "$(normalize_dm $(unmangle "$device"))" fi printf '\t%-10s\t%-10s\t%-10s\t0 0\n\n' 'none' 'swap' "$options"