From da824eac174c162a4fe64a27bad50d687e2b87ac Mon Sep 17 00:00:00 2001 From: BrainwreckedTech <3752022+BrainwreckedTech@users.noreply.github.com> Date: Fri, 23 Aug 2019 20:00:10 -0400 Subject: [PATCH] Added bdmap --- README.md | 3 +++ bdmap | 11 +++++++++++ 2 files changed, 14 insertions(+) create mode 100755 bdmap diff --git a/README.md b/README.md index 722cb5c..5837453 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,9 @@ Scripts for disks **PLEASE NOTE:** These scripts should be considered experimental. Test on non-production or backed-up data first. +bdmap +: Block Device Map: Maps /dev devices to sata/usb/etc. devices + ckalign : Check if a given sector number is aligned on a 4k boundary diff --git a/bdmap b/bdmap new file mode 100755 index 0000000..b6c0d6c --- /dev/null +++ b/bdmap @@ -0,0 +1,11 @@ +#!/bin/sh + +MKSED=false +OUTPUT="$(ls -l --color=never /sys/block | grep -v virtual | grep devices | cut -d\ -f9- | sed 's/\.\.\/devices\/pci//g;s/[0-9]\{4\}:[0-9]\{2\}[0-9:.a-f]*//g;s/\/\/\/*//g;s/->/=/g' | cut -d/ -f1)" + +case "${1}" in + --sed) sed "$(echo ""${OUTPUT}"" | sed 's/ = / (/g;s/\(sd.\)/s\/\1 \\{7\\}\/\1/g;s/ s\//)\/g;s\//g'))/g" /dev/stdin ;; + *) echo "${OUTPUT}" ;; +esac + +