
It will probably not work if your disk is a logical device emulated by hardware (like a RAID controller).
通过判断cat /sys/block/*/queue/rotational的返回值(其中*为你的硬盘设备名称,例如sda等等),如果返回1则表示磁盘可旋转,那么就是HDD了;反之,如果返回0,则表示磁盘不可以旋转,那么就有可能是SSD了。
使用lsblk命令进行判断,参数-d表示显示设备名称,参数-o表示仅显示特定的列。
How to know if a disk is an SSD or an HDD
https://unix.stackexchange.com/questions/65595/how-to-know-if-a-disk-is-an-ssd-or-an-hdd
Linux下判断磁盘是SSD还是HDD的几种方法
https://blog.csdn.net/sch0120/article/details/77725658
Linux下如何查看硬盘是固态硬盘SSD还是机械硬盘HDD
https://blog.csdn.net/qq_40586364/article/details/103908967
Which linux filesystem works best with SSD
https://superuser.com/questions/228657/which-linux-filesystem-works-best-with-ssd
linux 里有很多文档可以帮助学习!比如
GNU bash, version 3.2.33(1)-release (i386-redhat-linux-gnu)
These shell commands are defined internally. Type `help' to see this list.
Type `help name' to find out more about the function `name'.
Use `info bash' to find out more about the shell in general.
Use `man -k' or `info' to find out more about commands not in this list.
A star (*) next to a name means that the command is disabled.
JOB_SPEC [&] (( expression ))
. filename [arguments] :
[ arg... ] [[ expression ]]
alias [-p] [name[=value] ... ] bg [job_spec ...]
bind [-lpvsPVS] [-m keymap] [-f fi break [n]
builtin [shell-builtin [arg ...]] caller [EXPR]
case WORD in [PATTERN [| PATTERN]. cd [-L|-P] [dir]
command [-pVv] command [arg ...] compgen [-abcdefgjksuv] [-o option
complete [-abcdefgjksuv] [-pr] [-o continue [n]
declare [-afFirtx] [-p] [name[=val dirs [-clpv] [+N] [-N]
disown [-h] [-ar] [jobspec ...]echo [-neE] [arg ...]
enable [-pnds] [-a] [-f filename] eval [arg ...]
exec [-cl] [-a name] file [redirec exit [n]
export [-nf] [name[=value] ...] or false
fc [-e ename] [-nlr] [first] [last fg [job_spec]
for NAME [in WORDS ... ] do COMMA for (( exp1exp2exp3 ))do COM
function NAME { COMMANDS } or NA getopts optstring name [arg]
hash [-lr] [-p pathname] [-dt] [na help [-s] [pattern ...]
history [-c] [-d offset] [n] or hi if COMMANDSthen COMMANDS[ elif
jobs [-lnprs] [jobspec ...] or job kill [-s sigspec | -n signum | -si
let arg [arg ...] local name[=value] ...
logout popd [+N | -N] [-n]
printf [-v var] format [arguments] pushd [dir | +N | -N] [-n]
pwd [-LP] read [-ers] [-u fd] [-t timeout] [
readonly [-af] [name[=value] ...] return [n]
select NAME [in WORDS ... ] do CO set [--abefhkmnptuvxBCHP] [-o opti
shift [n] shopt [-pqsu] [-o long-option] opt
source filename [arguments]suspend [-f]
test [expr]time [-p] PIPELINE
times trap [-lp] [arg signal_spec ...]
true type [-afptP] name [name ...]
typeset [-afFirtx] [-p] name[=valu ulimit [-SHacdfilmnpqstuvx] [limit
umask [-p] [-S] [mode] unalias [-a] name [name ...]
unset [-f] [-v] [name ...] until COMMANDSdo COMMANDSdone
variables - Some variable names an wait [n]
while COMMANDSdo COMMANDSdone { COMMANDS }
good luck
write 函数的第一个参数是 open 函数返回的文件描述符,和windows里一般文件的句柄是对应的,这段代码中之所以这么用,是因为该程序是从控制台shell启动的,是shell的子进程,他继承了shell默认打开了文件描述符0 1 2 。
0 1 2 分别对应 标准输入 标准输出 标准出错,(在没有重定向、管道的情况下 对应了键盘 显示器 显示器)。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)