3 # Print some common lsblk values
5 # Any (lowercased) name symlinked to the lsblk script will be passed to lsblk
6 # as one of its --output names. Here's a partial list of --output names
7 # from the lsblk binary:
9 # Available columns (for --output):
11 # KNAME internal kernel device name
12 # MAJ:MIN major:minor device number
13 # FSTYPE filesystem type
14 # MOUNTPOINT where the device is mounted
15 # LABEL filesystem LABEL
16 # UUID filesystem UUID
17 # RA read-ahead of the device
20 # MODEL device identifier
21 # SIZE size of the device
22 # STATE state of the device
25 # MODE device node permissions
26 # ALIGNMENT alignment offset
27 # MIN-IO minimum I/O size
28 # OPT-IO optimal I/O size
29 # PHY-SEC physical sector size
30 # LOG-SEC logical sector size
31 # ROTA rotational device
32 # SCHED I/O scheduler name
33 # RQ-SIZE request queue size
35 # DISC-ALN discard alignment offset
36 # DISC-GRAN discard granularity
37 # DISC-MAX discard max bytes
38 # DISC-ZERO discard zeroes data
40 # If the script is run as just 'lsblk' then print out disk size, vendor,
41 # model number and serial number.
45 label: Show filesystem label.
46 model: Show disk model number.
47 serial: Show disk serial number.
48 size: Show the disk capacity.
49 vendor: Show the disk vendor.
50 lsblk: Show the disk size, vendor, model number, and serial number."
52 script=$
(basename "$0")
54 if [ "$1" = "-h" ] ; then
55 echo "$helpstr" |
grep "$script:" |
tr -s '\t' | cut
-f 2-
59 if [ "$script" = "lsblk" ] ; then
60 list
="size vendor model serial"
62 list
=$
(echo "$script" |
tr '[:upper:]' '[:lower:]')
65 # Older versions of lsblk don't support all these values (like SERIAL).
68 # Special case: Looking up the size of a file-based vdev can't
70 if [ "$i" = "size" ] && [ -f "$VDEV_UPATH" ] ; then
71 size
="$(du -h --apparent-size $VDEV_UPATH | cut -f 1)"
78 if val
=$
(eval "lsblk -dl -n -o $i $VDEV_UPATH 2>/dev/null") ; then
79 # Remove leading/trailing whitespace from value
80 val
=$
(echo "$val" |
sed -e 's/^[[:space:]]*//' \
81 -e 's/[[:space:]]*$//')