2019-04-22 07:12:13 +00:00
|
|
|
#!/bin/sh
|
2019-03-19 22:13:24 +00:00
|
|
|
|
2019-04-19 07:44:29 +00:00
|
|
|
uname_s="$(uname -s)"
|
2019-04-12 18:41:05 +00:00
|
|
|
|
2019-04-19 07:44:29 +00:00
|
|
|
case "${uname_s}" in
|
|
|
|
FreeBSD)
|
2019-04-12 18:41:05 +00:00
|
|
|
sysctl -n kern.disks
|
|
|
|
;;
|
2019-04-19 07:44:29 +00:00
|
|
|
OpenBSD|NetBSD)
|
|
|
|
sysctl -n hw.disknames | grep -Eo '[lsw]d[0-9]+' | xargs
|
2019-04-12 18:41:05 +00:00
|
|
|
;;
|
2019-04-19 07:44:29 +00:00
|
|
|
Linux)
|
2019-04-12 18:41:05 +00:00
|
|
|
if command -v lsblk > /dev/null
|
|
|
|
then
|
2019-04-17 18:50:39 +00:00
|
|
|
# exclude ram disks, floppies and cdroms
|
2019-04-12 18:41:05 +00:00
|
|
|
# https://www.kernel.org/doc/Documentation/admin-guide/devices.txt
|
|
|
|
lsblk -e 1,2,11 -dno name | xargs
|
|
|
|
else
|
2019-04-22 07:12:13 +00:00
|
|
|
printf "Don't know how to list disks for %s operating system without lsblk, if you can please submit a patch\n" "${uname_s}" >&2
|
2019-04-12 18:41:05 +00:00
|
|
|
fi
|
2019-03-19 22:13:24 +00:00
|
|
|
;;
|
2019-04-19 07:44:29 +00:00
|
|
|
*)
|
2019-04-22 07:12:13 +00:00
|
|
|
printf "Don't know how to list disks for %s operating system, if you can please submit a patch\n" "${uname_s}" >&2
|
2019-04-19 07:44:29 +00:00
|
|
|
;;
|
2019-03-19 22:13:24 +00:00
|
|
|
esac
|
2019-04-22 07:12:13 +00:00
|
|
|
|
|
|
|
exit 0
|