-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathhdinfo
More file actions
executable file
·44 lines (32 loc) · 715 Bytes
/
hdinfo
File metadata and controls
executable file
·44 lines (32 loc) · 715 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
#!/bin/bash
myname=${0##*/}
usage() {
echo "$myname: prints info about a Hard Disk" >&2
echo "Usage: $myname DEVICE" >&2
echo "Example: $myname /dev/sda" >&2
exit "${1:-0}"
}
if [[ -z "${1:-}" ]] || (( $# > 1 )); then
usage
fi
case "$1" in
-h|--help) usage;;
*) device=$1;;
esac
if ! [[ -b "$device" ]]; then
echo "$myname: error: '$device' is not a block device" >&2
usage 1
fi
# --------------
printcmd() {
echo "-----------------------------------------------------------------"
echo "\$ $@"
echo
}
echo "hdinfo $device"
printcmd fdisk p,x,p,d
printf 'p\nx\np\nd\nq\n' | sudo fdisk "$device"
printcmd hdparm -iI
sudo hdparm -iI "$device"
printcmd parted print
sudo parted "$device" print