Sharing
2014年2月9日 星期日
2013年11月6日 星期三
Simple IO Performance Testing
http://www.slashroot.in/linux-file-system-read-write-performance-test
| | Seq Read | Seq Write | Rand Read | Rand Write | Advanced |
| iozone | V | V | V | V | V |
| fio | V | V | V | V | V |
| dd | V | V | | | |
| hdparm | V | | | | |
| Bonnie | V | V | V | | |
| ioping | | V | | V | |
Bonnie
直接執行 Bonnie 就可以測試, 但不知道為什麼測試大小空間一定要 RAM * 2 的以上. 所以反而沒法很快的拿到測試結果
$ bonnie++
Writing a byte at a time...done
Writing intelligently...done
Rewriting...done
Reading a byte at a time...done
Reading intelligently...done
start 'em...done...done...done...done...done...
Create files in sequential order...done.
Stat files in sequential order...done.
Delete files in sequential order...done.
Create files in random order...done.
Stat files in random order...done.
Delete files in random order...done.
Version 1.96 ------Sequential Output------ --Sequential Input- --Random-
Concurrency 1 -Per Chr- --Block-- -Rewrite- -Per Chr- --Block-- --Seeks--
Machine Size K/sec %CP K/sec %CP K/sec %CP K/sec %CP K/sec %CP /sec %CP
pjack-VirtualBox 8G 575 96 36095 9 24925 7 3157 78 63170 13 101.3 9
Latency 31959us 2665ms 1823ms 127ms 583ms 1354ms
Version 1.96 ------Sequential Create------ --------Random Create--------
pjack-VirtualBox -Create-- --Read--- -Delete-- -Create-- --Read--- -Delete--
files /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP /sec %CP
16 13139 28 +++++ +++ 23059 36 21424 37 +++++ +++ 22344 36
Latency 63809us 1600us 528us 656us 660us 1080us
1.96,1.96,pjack-VirtualBox,1,1383799934,8G,,575,96,36095,9,24925,7,3157,78,63170,13,101.3,9,16,,,,,13139,28,+++++,+++,23059,36,21424,37,+++++,+++,22344,36,31959us,2665ms,18
23ms,127ms,583ms,1354ms,63809us,1600us,528us,656us,660us,1080us
iozone
Iozone 有預設 13 種 pattern , 所以算是測試很齊全又不會太麻煩的工具官網:
http://www.iozone.org/
使用方式介紹:
http://www.thegeekstuff.com/2011/05/iozone-examples/
fio
fio 則是擁有全功能, 可以自己設計 pattern, 又很多參數可以調整, 是很專業的工具, 但要寫 Script, 如果想要快速的拿到一些 performance report, 可能不是很好用, 之前也有介紹過http://pjack1981.blogspot.tw/2012/05/fio-disk-benchmark.html
ioping
https://code.google.com/p/ioping/很簡易的工具, 支援 seq/random write, 也可以指定 block size, 可以很快速的可以得到大概的狀況.
2013年9月27日 星期五
Generate hash value in /etc/shadow
在 /etc/shadow 內會紀錄每個人的 password hash value, 第一欄是名字, 第二欄就是 hash value
echen:$6$D3PHrOW9$tyD6jY830eKaz8ctBXZznSZ8MVdMq.f6VPmFdFSKfy6zNqJtDgNsNWYc42RyAS2VmRBekWN4S1gALcZM9wNbi1:15975:0:99999:7:::
hash value 的最前面的三碼代表演算法, $1$ 是 MD5, $5$ 是 SHA-256, $6$ 是 SHA-512
$ man crypt ID | Method ───────────────────────────────────────────────────────── 1 | MD5 2a | Blowfish (not in mainline glibc; added in some Linux distributions) 5 | SHA-256 (since glibc 2.7) 6 | SHA-512 (since glibc 2.7)
接下來8個 Character 代表 SALT 值, 我們會把 SALT 和 password 連結在一起去做 HASH, 而 SALT 是 random 產生的字串, 以這邊為例就是D3PHrOW9, 接下來的就是 hash 值
http://www.aychedee.com/2012/03/14/etc_shadow-password-hash-formats/
用以下的指令可以產生這個 hash 值, -m 接演算法, 再下來是要加密的 password, 最後是 Random 生出來的 SALT 值
mkpasswd -m sha-512 MyPAsSwOrD $(openssl rand -base64 16 | tr -d '+=' | head -c 16)
$ apg -Mcln -a1 -m16 r9yyTyMgAY5M9Lwv 0yo8zsFRL3TSnPzK ZwbnEPjmi3SBsa0e 6tiAxbCJWJPx2Z2X VAulxq6hevbirzTs jHCV7WBiA7CBVwrA $ openssl rand -base64 16 | tr -d '+=' L6VYvmgovdLScofodk7DPg $ </dev/urandom tr -dc '_A-Z-a-z-0-9!@#$%' | head -c16; echo "" LmzB!j4#ah_p8lm7
2013年9月2日 星期一
wa (Waiting for I/O) from top command is high
遇到有台機器動作很慢, 用 top 一看,loading 滿重的, 而且 wa 高達 96.9%, 看起來應該是 io 出了問題
$ top top - 03:08:30 up 34 days, 15:48, 1 user, load average: 41.70, 43.33, 43.77 Tasks: 323 total, 1 running, 322 sleeping, 0 stopped, 0 zombie Cpu(s): 1.4%us, 1.4%sy, 0.0%ni, 0.0%id, 96.9%wa, 0.0%hi, 0.3%si, 0.0%st Mem: 1019112k total, 953076k used, 66036k free, 1092k buffers Swap: 4111356k total, 2204620k used, 1906736k free, 22320k cached
http://serverfault.com/questions/155882/wa-waiting-for-i-o-from-top-command-is-big
$ iostat 1
avg-cpu: %user %nice %system %iowait %steal %idle
1.03 0.00 1.03 97.94 0.00 0.00
Device: tps kB_read/s kB_wrtn/s kB_read kB_wrtn
scd0 0.00 0.00 0.00 0 0
sda 493.81 7327.84 738.14 7108 716
sdb 0.00 0.00 0.00 0 0
2013年8月27日 星期二
NMON for Linux
最近又玩到一個新工具, 叫 NMON
http://nmon.sourceforge.net/pmwiki.php
只要輸入 nmon, 就可以進入互動式的介面, 即時看到系統大部份的狀況, 對於系統 administrator 是個超好用的工具. 除此之外, 他會定期把 data 紀錄到 /var/log/nmon, 如果當有問題發生時, 當場可能因為系統當機而不得不重開機的話, 事後還可以利用這些 data 來觀察當時到底發生什麼事
http://www.ibm.com/developerworks/aix/library/au-nmon_analyser/
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Power%20Systems/page/nmon_analyser
nmon analyser 是個利用 Excel 做出來的工具, 只要你把這些 .nmon 檔丟進這個工具, 他就可以替你進行分析, 讓你快速找出當時 CPU 的狀況, 那一個 process 吃掉最多 memory.. 等等, 非常方便
http://nmon.sourceforge.net/pmwiki.php
只要輸入 nmon, 就可以進入互動式的介面, 即時看到系統大部份的狀況, 對於系統 administrator 是個超好用的工具. 除此之外, 他會定期把 data 紀錄到 /var/log/nmon, 如果當有問題發生時, 當場可能因為系統當機而不得不重開機的話, 事後還可以利用這些 data 來觀察當時到底發生什麼事
http://www.ibm.com/developerworks/aix/library/au-nmon_analyser/
https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/Power%20Systems/page/nmon_analyser
nmon analyser 是個利用 Excel 做出來的工具, 只要你把這些 .nmon 檔丟進這個工具, 他就可以替你進行分析, 讓你快速找出當時 CPU 的狀況, 那一個 process 吃掉最多 memory.. 等等, 非常方便
2013年8月25日 星期日
How to know if running in virtual machine
有個好用的小工具可以
$ sudo apt-get install virt-what # 如果是在 virtualbox 內 $ sudo virt-what virtualbox # 如果是在 vmware 內 $ sudo virt-what vmware # 如果是 Physical Machine, 就沒有任何 output $ virt-what
2013年6月10日 星期一
Linux Process Introduction and Simple Monitoring
簡介
http://careers.directi.com/display/tu/Understanding+Processes+in+Linux
最需要馬上知道的應該是這個 Process State
the state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by its parent.
快速列出目前有那些 process 是 Dead 狀態, 也可以很簡易的改成別的
Load average in top
http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages
http://careers.directi.com/display/tu/Understanding+Processes+in+Linux
最需要馬上知道的應該是這個 Process State
the state of a process:
D uninterruptible sleep (usually IO)
R running or runnable (on run queue)
S interruptible sleep (waiting for an event to complete)
T stopped, either by a job control signal or because it is being traced.
W paging (not valid since the 2.6.xx kernel)
X dead (should never be seen)
Z defunct ("zombie") process, terminated but not reaped by its parent.
# list all tasks that is not in running state $ ps -eN r # list all tasks that is in running state $ ps -e r
快速列出目前有那些 process 是 Dead 狀態, 也可以很簡易的改成別的
$ top -b -n 1 | awk '{if (NR <=7) print; else if ($8 == "D") {print; count++} } END {print "Total status D: "count}'
top - 03:06:19 up 12 days, 22:30, 2 users, load average: 0.00, 0.04, 0.05
Tasks: 120 total, 1 running, 118 sleeping, 1 stopped, 0 zombie
Cpu(s): 0.2%us, 0.4%sy, 0.0%ni, 99.3%id, 0.0%wa, 0.0%hi, 0.0%si, 0.0%st
Mem: 1985624k total, 1682512k used, 303112k free, 211976k buffers
Swap: 407548k total, 2836k used, 404712k free, 708468k cached
PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND
Total status D:
Load average in top
http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages
Other
https://blogs.oracle.com/ksplice/entry/disown_zombie_children_and_the
https://idea.popcount.org/2012-12-11-linux-process-states/
http://www.jollen.org/blog/2008/07/process_state_wait_queue.html
2013年5月29日 星期三
Background Color of Shell Terminal
原本用 Ubuntu 內建的 Terminal, 顏色很正常, 看起來也很舒服
但在用 Gnome Connection Manager 時, vi 的藍色突然變成高亮度, 眼睛一整個看不清楚, 不知道要怎麼解決這個狀況, 於是就想說來調一下背景色
找了一下網路文章
http://www.hanselman.com/blog/VisualStudioProgrammerThemesGallery.aspx
http://www.codinghorror.com/blog/2006/09/is-your-ide-hot-or-not.html
最後試了半天, 決定採用 RGB(64/64/64) 這個背景色, 雖不十分滿意, 但還算可以接授
畢竟只是短暫的工作環境

.vimrc
後來同事建議我修改 .vimrc 比較快 XD
syntax on set bg=dark set nocompatible set number set shiftwidth=4 set softtabstop=4 set linebreak set nowrap
Bash Keyboard Shortcuts
Keyboard Shortcuts
比較完整的在這篇裡面http://halotis.com/2010/07/06/bash-keyboard-shortcuts/
列一些比較常用的
Moving the cursor
Ctrl + a Go to the beginning of the line (Home)
Ctrl + e Go to the End of the line (End)
Ctrl + p Previous command (Up arrow)
Ctrl + n Next command (Down arrow)
Alt + b Back (left) one word
Alt + f Forward (right) one word
Editing
Ctrl + L Clear the Screen, similar to the clear command
Ctrl + u Cut/delete the line before the cursor position.
Ctrl + k Cut the Line after the cursor to the clipboard.
Alt + backspace Delete the Word before the cursor.
Alt + d Delete the Word after the cursor.
Ctrl + w Cut the Word before the cursor to the clipboard.
Ctrl + y Paste the last thing to be cut
Ctrl + t Swap the last two characters before the cursor (typo).
Alt + t Swap current word with previous
Alt + u UPPER capitalize every character to the end of the current word.
Alt + l Lower the case of every character to the end of the current word.
Alt + / Attempt to complete filename
History
Ctrl + r Search the history backwards.
Ctrl + g Escape from history searching mode
!! Execute last command in history
!abc Execute last command in history beginning with abc
!n Execute n-th command in history
Other
Ctrl + x @ Show possible hostname completions.
Terminal Alt Shortcut Key Problem
Alt activate the menu item
Gnome Terminal 預設按 alt 會切換到 menu item. 但這會造成 Alt+f/Alt+b 無法使用, 如果想要取消這個功能可以在選單 Edit->Keyboard Shortcut 內把"Enable menu access keys"
"Enable the menu shortcut key"
都移除勾選
Alt+left / Alt+right key no use
在 Window/Putty 時,沒有這個問題,但在 Gnome Terminal 就出現了這個問題
檢查了一下 Alt+left key 的值, 發現在兩個環境內收到的不一樣!?
在 putty 環境內
# press Alt+left key $ read ^[^[[D # press Alt + right key $ read ^[^[[C
在 gnome terminal 內
# press Alt+left key $ read ^[[1;3D # press Alt + right key $ read ^[[1;3C
http://blog.simplicitymedialtd.co.uk/457/making-alt-leftalt-right-work-in-gnome-terminal-like-putty
目前還是不清楚為什麼會有這樣的狀況,但快速解法是修改 /etc/inputrc or ~/.inputrc
以滿足兩個狀況下的 Alt+array key 都能發揮作用
cat .inputrc # mapping for alt+left-arrow and alt+right-arrow for word moving "\e[1;3D": backward-word "\e[1;3C": forward-word "\e\e[C": forward-word "\e\e[D": backward-word
2013年5月27日 星期一
Multiple Connection Manager
在 Window 上
2013/05/29 Update:
Alt+f 無法使用的問題, 暫時無解
http://askubuntu.com/questions/37313/how-do-i-deactivate-f1-and-f10-keybindings-in-gnome-terminal
https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1113420?comments=all.
2013/05/31 Update:
寫信給 kuthulu.com , 想不到很快的就得到回答
editing the file /usr/share/gnome-connection-manager/gnome-connection-manager.glade
look for the following items:
menuitem1, menuitem7, menuitem5, menuitem6, menuitem4
and change
<property name="use_underline">True</property>
to
<property name="use_underline">False</property>
下方是我改過的檔案內容,改過之後 alt+f, alt+b 就可以使用了!
在 Linux 上, 我找到有兩個可以使用
- Gnome Connection Manager
http://kuthulu.com/gcm/
- PAC Manager
https://sites.google.com/site/davidtv/
我自己選擇使用 Gnome Connection Manager, PAC 的功能太多, 一時間覺得有點眼光瞭亂, 不如就先用陽春的 GCM, 另一個選擇他的理由是它是用 Python 寫的, PAC 是用Perl 寫的, 對 Perl 實在沒什麼好感。
2013/05/29 Update:
Alt+f 無法使用的問題, 暫時無解
http://askubuntu.com/questions/37313/how-do-i-deactivate-f1-and-f10-keybindings-in-gnome-terminal
https://bugs.launchpad.net/ubuntu/+source/nautilus/+bug/1113420?comments=all.
2013/05/31 Update:
寫信給 kuthulu.com , 想不到很快的就得到回答
editing the file /usr/share/gnome-connection-manager/gnome-connection-manager.glade
look for the following items:
menuitem1, menuitem7, menuitem5, menuitem6, menuitem4
and change
<property name="use_underline">True</property>
to
<property name="use_underline">False</property>
下方是我改過的檔案內容,改過之後 alt+f, alt+b 就可以使用了!
$ grep -P 'id=\"menuitem\d\"' /usr/share/gnome-connection-manager/gnome-connection-manager.glade -A 3
<widget class="GtkMenuItem" id="menuitem1">
<property name="visible">True</property>
<property name="label" translatable="yes">_Archivo</property>
<property name="use_underline">False</property>
--
<widget class="GtkMenuItem" id="menuitem7">
<property name="visible">True</property>
<property name="label" translatable="yes">_Editar</property>
<property name="use_underline">False</property>
--
<widget class="GtkMenuItem" id="menuitem9">
<property name="visible">True
<property name="label" translatable="yes">Comandos personalizados</property>
--
<widget class="GtkMenuItem" id="menuitem5">
<property name="visible">True</property>
<property name="label" translatable="yes">_Ver</property>
<property name="use_underline">False</property>
--
<widget class="GtkMenuItem" id="menuitem6">
<property name="visible">True</property>
<property name="label" translatable="yes">_Servidores</property>
<property name="use_underline">False
--
<widget class="GtkMenuItem" id="menuitem4">
<property name="visible">True</property>
<property name="label" translatable="yes">Ay_uda</property>
<property name="use_underline">False</property>
2013年4月30日 星期二
I/O status of Process
http://kmaiti.blogspot.tw/2011/09/what-is-wchan-attribute-at-ps-alwww-on.html
http://askubuntu.com/questions/19442/what-is-the-waiting-channel-of-a-process
root@pjack-VirtualBox:~$ ps -alwww F S UID PID PPID C PRI NI ADDR SZ WCHAN TTY TIME CMD 0 S 1000 707 706 0 80 0 - 7014 wait pts/7 00:00:00 bash 0 S 1000 2271 707 0 80 0 - 11950 poll_s pts/7 00:00:00 ssh 0 S 1000 25352 25248 0 80 0 - 4449 poll_s pts/6 00:00:00 tmux 0 S 1000 27179 27178 0 80 0 - 7012 wait pts/4 00:00:00 bash 0 S 1000 27376 27179 0 80 0 - 10397 poll_s pts/4 00:00:00 ssh 4 R 0 27934 29703 0 80 0 - 3484 - pts/5 00:00:00 ps 0 S 1000 29430 29429 0 80 0 - 7010 wait pts/5 00:00:00 bash 4 S 0 29692 29430 0 80 0 - 15074 poll_s pts/5 00:00:00 sudo 4 S 0 29703 29692 0 80 0 - 6991 wait pts/5 00:00:00 bash 0 S 1000 32224 32220 0 80 0 - 7056 n_tty_ pts/3 00:00:00 bash
root@pjack-VirtualBox:~$ cat /proc/707/wchan do_wait root@pjack-VirtualBox:~$ cat /proc/29692/wchan poll_schedule_timeout
poll_schedule_timeout <= 等 I/O
2013年2月6日 星期三
2012年4月29日 星期日
Get Hard Disk Information on Linux
General Hard Disk Information
Drive Group Information, Disk behind RAID card
http://www.lsi.com/channel/products/storagecomponents/Pages/6GBSATA_SASRAIDCards.aspx
http://store.lsi.com/store.cfm/MegaRAID_Controllers/9260_Controllers/LSI00201/
http://www.lsi.com/channel/products/storagecomponents/Pages/MegaRAIDSAS9260-4i.aspx
根據 smartctl 的說明, 應該用 3ware or megaraid 這兩個參數就可以看到後面的硬碟才對.. 不過還沒試成功
最後用了 LSI 官網的工具 MegaCli
http://lzj0470.iteye.com/blog/1399221
http://www.osslab.com.tw/index.php?title=Storage/Enterprise/SAS%E8%88%87RAID/LSI
http://www.osslab.com.tw/Storage/Enterprise/SAS%E8%88%87RAID/LSI/MegaRAID_CLI%E7%B0%A1%E4%BB%8B
http://www.weithenn.org/cgi-bin/wiki.pl?MegaCLI-%E6%9F%A5%E7%9C%8B_PERC_5i_RAID_Controller_%E7%8B%80%E6%85%8B#Heading10
不過要注意的是這個工具不支援 3.0 以後的 Kernel, 但我在 Ubuntu 官網找到暫解
http://askubuntu.com/questions/112455/megaraid-sas-raid-controller
指令集
http://kb.lsi.com/KnowledgebaseArticle16516.aspx
Reference:
http://www.cyberciti.biz/faq/find-hard-disk-hardware-specs-on-linux/
http://www.cyberciti.biz/tips/sdparm-linux-scsi-device-attribute.html
http://unix.stackexchange.com/questions/5085/how-to-see-disk-details-like-manufacturer-in-linux
http://freejabber.com/2012/01/30/monitoring-your-raid-array-drives-and-standalone-drives-in-ubuntu-linux-using-smartmontools/
http://www.cyberciti.biz/faq/unix-linux-freebsd-3w-9xxx-smartctl-check-hard-disk-command/
- lshw
root@ubuntu:~$ lshw | less | grep *-
*-core
*-firmware
*-cpu:0
*-cache:0
*-cache:1
*-cache:2
*-memory:0
*-bank:0
*-bank:1
*-bank:2
*-bank:3
*-bank:4
*-bank:5
*-pci:0
*-pci:0
*-network:0
*-network:1 DISABLED
*-pci:1
*-network:0 DISABLED
*-network:1 DISABLED
*-pci:2
*-pci:3
*-storage
*-enclosure UNCLAIMED
*-disk:0
*-disk:1
*-disk:2
*-disk:3
*-disk:4
*-disk:5
*-disk:6
*-disk:7
root@ubuntu:~$ lshw -class disk
*-disk
description: ATA Disk
product: ST9250610NS
vendor: Seagate
physical id: 0.0.0
bus info: scsi@0:0.0.0
logical name: /dev/sda
version: SN01
serial: 9XE00BTT
size: 232GiB (250GB)
capabilities: partitioned partitioned:dos
configuration: ansiversion=5 signature=0003cad9
root@ubuntu:~$ lshw -short -C disk
H/W path Device Class Description
========================================================
/0/100/5/0/2.0.0 /dev/sdb disk 999GB MR9260-4i
/0/100/5/0/2.1.0 /dev/sdc disk 1999GB MR9260-4i
/0/100/5/0/2.2.0 /dev/sdd disk 999GB MR9260-4i
/0/100/5/0/2.3.0 /dev/sde disk 1999GB MR9260-4i
/0/100/5/0/2.4.0 /dev/sdf disk 299GB MR9260-4i
/0/100/5/0/2.5.0 /dev/sdg disk 239GB MR9260-4i
/0/100/5/0/2.6.0 /dev/sdh disk 299GB MR9260-4i
/0/100/5/0/2.7.0 /dev/sdi disk 119GB MR9260-4i
/0/100/1f.2/0.0.0 /dev/sda disk 250GB ST9250610NS
- hdparm
root@ubuntu:~$ hdparm -I /dev/sda
/dev/sda:
ATA device, with non-removable media
Model Number: ST9250610NS
Serial Number: 9XE00BTT
Firmware Revision: SN01
Transport: Serial, SATA Rev 3.0
Standards:
Used: unknown (minor revision code 0x0029)
Supported: 8 7 6 5
Likely used: 8
Configuration:
Logical max current
cylinders 16383 16383
heads 16 16
sectors/track 63 63
--
CHS current addressable sectors: 16514064
LBA user addressable sectors: 268435455
LBA48 user addressable sectors: 488397168
Logical/Physical Sector size: 512 bytes
device size with M = 1024*1024: 238475 MBytes
device size with M = 1000*1000: 250059 MBytes (250 GB)
cache/buffer size = unknown
Nominal Media Rotation Rate: 7200
Capabilities:
LBA, IORDY(can be disabled)
Queue depth: 32
Standby timer values: spec'd by Standard, no device specific minimum
R/W multiple sector transfer: Max = 16 Current = ?
Recommended acoustic management value: 254, current value: 0
DMA: mdma0 mdma1 mdma2 udma0 udma1 udma2 udma3 udma4 udma5 *udma6
Cycle time: min=120ns recommended=120ns
PIO: pio0 pio1 pio2 pio3 pio4
Cycle time: no flow control=120ns IORDY flow control=120ns
Commands/features:
Enabled Supported:
* SMART feature set
Security Mode feature set
* Power Management feature set
* Write cache
* Look-ahead
* Host Protected Area feature set
* WRITE_BUFFER command
* READ_BUFFER command
* DOWNLOAD_MICROCODE
SET_MAX security extension
* 48-bit Address feature set
* Device Configuration Overlay feature set
* Mandatory FLUSH_CACHE
* FLUSH_CACHE_EXT
* SMART error logging
* SMART self-test
* General Purpose Logging feature set
* WRITE_{DMA|MULTIPLE}_FUA_EXT
* 64-bit World wide name
Write-Read-Verify feature set
* WRITE_UNCORRECTABLE_EXT command
* {READ,WRITE}_DMA_EXT_GPL commands
* Segmented DOWNLOAD_MICROCODE
* unknown 119[7]
* Gen1 signaling speed (1.5Gb/s)
* Gen2 signaling speed (3.0Gb/s)
* Gen3 signaling speed (6.0Gb/s)
* Native Command Queueing (NCQ)
* Phy event counters
* unknown 76[15]
Device-initiated interface power management
* Software settings preservation
* SMART Command Transport (SCT) feature set
* SCT LBA Segment Access (AC2)
* SCT Error Recovery Control (AC3)
* SCT Features Control (AC4)
* SCT Data Tables (AC5)
unknown 206[7]
unknown 206[12] (vendor specific)
Security:
Master password revision code = 65534
supported
not enabled
not locked
not frozen
not expired: security count
supported: enhanced erase
48min for SECURITY ERASE UNIT. 48min for ENHANCED SECURITY ERASE UNIT.
Logical Unit WWN Device Identifier: 5000c50035319eee
NAA : 5
IEEE OUI : 000c50
Unique ID : 035319eee
Checksum: correct
- dmesg
root@ubuntu:~$ dmesg | grep scsi [ 3.735457] scsi0 : ahci [ 3.735609] scsi1 : ahci [ 3.735747] scsi2 : ahci [ 3.735885] scsi3 : ahci [ 3.736024] scsi4 : ahci [ 3.736164] scsi5 : ahci [ 4.178643] scsi 0:0:0:0: Direct-Access ATA ST9250610NS SN01 PQ: 0 ANSI: 5 [ 4.178960] sd 0:0:0:0: Attached scsi generic sg0 type 0 [ 5.950530] scsi6 : LSI SAS based MegaRAID driver [ 5.953670] scsi 6:0:4:0: Direct-Access ATA INTEL SSDSA2BW30 0362 PQ: 0 ANSI: 5 [ 5.965343] scsi 6:0:5:0: Direct-Access ATA SAMSUNG HE103SJ 0001 PQ: 0 ANSI: 5 [ 5.977082] scsi 6:0:6:0: Direct-Access ATA SAMSUNG HE103SJ 0001 PQ: 0 ANSI: 5 [ 5.988839] scsi 6:0:7:0: Direct-Access ATA SAMSUNG HE103SJ 0001 PQ: 0 ANSI: 5 [ 6.000583] scsi 6:0:8:0: Direct-Access ATA SAMSUNG HE103SJ 0001 PQ: 0 ANSI: 5 [ 6.012259] scsi 6:0:9:0: Direct-Access ATA SAMSUNG HE103SJ 0001 PQ: 0 ANSI: 5 [ 6.013360] scsi 6:0:10:0: Direct-Access ATA INTEL SSDSA2BZ30 0362 PQ: 0 ANSI: 5 [ 6.034102] scsi 6:0:11:0: Direct-Access ATA INTEL SSDSC2BW24 400i PQ: 0 ANSI: 5 [ 6.034771] scsi 6:0:12:0: Enclosure Wistron LSI2x20 0900 PQ: 0 ANSI: 5 [ 6.046667] scsi 6:0:13:0: Direct-Access ATA SAMSUNG HE103SJ 0001 PQ: 0 ANSI: 5 [ 6.058300] scsi 6:0:14:0: Direct-Access ATA SAMSUNG HE103SJ 0001 PQ: 0 ANSI: 5 [ 6.070055] scsi 6:0:15:0: Direct-Access ATA SAMSUNG HE103SJ 0001 PQ: 0 ANSI: 5 [ 6.091376] scsi 6:0:16:0: Direct-Access ATA D2CSTK251M11-012 2.15 PQ: 0 ANSI: 5 [ 6.107324] scsi 6:2:0:0: Direct-Access LSI MR9260-4i 2.70 PQ: 0 ANSI: 5 [ 6.107554] scsi 6:2:1:0: Direct-Access LSI MR9260-4i 2.70 PQ: 0 ANSI: 5 [ 6.107775] scsi 6:2:2:0: Direct-Access LSI MR9260-4i 2.70 PQ: 0 ANSI: 5 [ 6.107981] scsi 6:2:3:0: Direct-Access LSI MR9260-4i 2.70 PQ: 0 ANSI: 5 [ 6.108194] scsi 6:2:4:0: Direct-Access LSI MR9260-4i 2.70 PQ: 0 ANSI: 5 [ 6.108406] scsi 6:2:5:0: Direct-Access LSI MR9260-4i 2.70 PQ: 0 ANSI: 5 [ 6.108635] scsi 6:2:6:0: Direct-Access LSI MR9260-4i 2.70 PQ: 0 ANSI: 5 [ 6.108864] scsi 6:2:7:0: Direct-Access LSI MR9260-4i 2.70 PQ: 0 ANSI: 5 [ 6.124449] scsi 6:0:12:0: Attached scsi generic sg1 type 13 [ 6.124992] sd 6:2:0:0: Attached scsi generic sg2 type 0 [ 6.125425] sd 6:2:1:0: Attached scsi generic sg3 type 0 [ 6.125765] sd 6:2:2:0: Attached scsi generic sg4 type 0 [ 6.126186] sd 6:2:3:0: Attached scsi generic sg5 type 0 [ 6.126550] sd 6:2:4:0: Attached scsi generic sg6 type 0 [ 6.126999] sd 6:2:5:0: Attached scsi generic sg7 type 0 [ 6.127455] sd 6:2:6:0: Attached scsi generic sg8 type 0 [ 6.127962] sd 6:2:7:0: Attached scsi generic sg9 type 0
- smartctl
root@ubuntu:~$ smartctl -d ata -a -i /dev/sda
smartctl 5.41 2011-06-09 r3365 [x86_64-linux-3.2.0-23-generic] (local build)
Copyright (C) 2002-11 by Bruce Allen, http://smartmontools.sourceforge.net
=== START OF INFORMATION SECTION ===
Device Model: ST9250610NS
Serial Number: 9XE00BTT
LU WWN Device Id: 5 000c50 035319eee
Firmware Version: SN01
User Capacity: 250,059,350,016 bytes [250 GB]
Sector Size: 512 bytes logical/physical
Device is: Not in smartctl database [for details use: -P showall]
ATA Version is: 8
ATA Standard is: ATA-8-ACS revision 4
Local Time is: Mon Apr 30 11:38:24 2012 CST
SMART support is: Available - device has SMART capability.
SMART support is: Enabled
=== START OF READ SMART DATA SECTION ===
SMART overall-health self-assessment test result: PASSED
See vendor-specific Attribute list for marginal Attributes.
General SMART Values:
Offline data collection status: (0x82) Offline data collection activity
was completed without error.
Auto Offline Data Collection: Enabled.
Self-test execution status: ( 0) The previous self-test routine completed
without error or no self-test has ever
been run.
Total time to complete Offline
data collection: ( 634) seconds.
Offline data collection
capabilities: (0x7b) SMART execute Offline immediate.
Auto Offline data collection on/off support.
Suspend Offline collection upon new
command.
Offline surface scan supported.
Self-test supported.
Conveyance Self-test supported.
Selective Self-test supported.
SMART capabilities: (0x0003) Saves SMART data before entering
power-saving mode.
Supports SMART auto save timer.
Error logging capability: (0x01) Error logging supported.
General Purpose Logging supported.
Short self-test routine
recommended polling time: ( 1) minutes.
Extended self-test routine
recommended polling time: ( 49) minutes.
Conveyance self-test routine
recommended polling time: ( 2) minutes.
SCT capabilities: (0x10bd) SCT Status supported.
SCT Error Recovery Control supported.
SCT Feature Control supported.
SCT Data Table supported.
SMART Attributes Data Structure revision number: 10
Vendor Specific SMART Attributes with Thresholds:
ID# ATTRIBUTE_NAME FLAG VALUE WORST THRESH TYPE UPDATED WHEN_FAILED RAW_VALUE
1 Raw_Read_Error_Rate 0x000f 081 066 044 Pre-fail Always - 120497634
3 Spin_Up_Time 0x0003 097 096 000 Pre-fail Always - 0
4 Start_Stop_Count 0x0032 100 100 020 Old_age Always - 134
5 Reallocated_Sector_Ct 0x0033 100 100 036 Pre-fail Always - 0
7 Seek_Error_Rate 0x000f 060 059 030 Pre-fail Always - 12888092699
9 Power_On_Hours 0x0032 098 098 000 Old_age Always - 1924
10 Spin_Retry_Count 0x0013 100 100 097 Pre-fail Always - 0
12 Power_Cycle_Count 0x0032 100 100 020 Old_age Always - 133
184 End-to-End_Error 0x0032 100 100 099 Old_age Always - 0
187 Reported_Uncorrect 0x0032 100 100 000 Old_age Always - 0
188 Command_Timeout 0x0032 100 095 000 Old_age Always - 73015558161
189 High_Fly_Writes 0x003a 100 100 000 Old_age Always - 0
190 Airflow_Temperature_Cel 0x0022 071 041 045 Old_age Always In_the_past 29 (0 117 29 23)
191 G-Sense_Error_Rate 0x0032 100 100 000 Old_age Always - 0
192 Power-Off_Retract_Count 0x0032 100 100 000 Old_age Always - 117
193 Load_Cycle_Count 0x0032 099 099 000 Old_age Always - 2509
194 Temperature_Celsius 0x0022 029 059 000 Old_age Always - 29 (0 19 0 0)
195 Hardware_ECC_Recovered 0x001a 117 100 000 Old_age Always - 120497634
197 Current_Pending_Sector 0x0012 100 100 000 Old_age Always - 0
198 Offline_Uncorrectable 0x0010 100 100 000 Old_age Offline - 0
199 UDMA_CRC_Error_Count 0x003e 200 200 000 Old_age Always - 0
SMART Error Log Version: 1
No Errors Logged
SMART Self-test log structure revision number 1
No self-tests have been logged. [To run self-tests, use: smartctl -t]
SMART Selective self-test log data structure revision number 1
SPAN MIN_LBA MAX_LBA CURRENT_TEST_STATUS
1 0 0 Not_testing
2 0 0 Not_testing
3 0 0 Not_testing
4 0 0 Not_testing
5 0 0 Not_testing
Selective self-test flags (0x0):
After scanning selected spans, do NOT read-scan remainder of disk.
If Selective self-test is pending on power-up, resume after 0 minute delay.
- sdparm
root@ubuntu:~$ sdparm /dev/sda /dev/sda: ATA ST9250610NS SN01 Read write error recovery mode page: AWRE 1 ARRE 0 PER 0 Caching (SBC) mode page: WCE 1 RCD 0 Control mode page: SWP 0
- sfdisk
root@ubuntu:~$ sfdisk -s /dev/sda: 244198584 /dev/sdc: 1952448512 /dev/sdd: 976224256 /dev/sde: 1952448512 /dev/sdb: 976224256 /dev/sdg: 233897984 /dev/sdf: 292487168 /dev/sdh: 292487168 /dev/sdi: 116686848 total: 7037103288 blocks
- hwinfo
root@ubuntu:~$ hwinfo --disk > hal.1: read hal dataprocess 2975: arguments to dbus_move_error() were incorrect, assertion "(dest) == NULL || !dbus_error_is_set ((dest))" failed in file ../../dbus/dbus-errors.c line 282. This is normally a bug in some application using the D-Bus library. libhal.c 3483 : Error unsubscribing to signals, error=The name org.freedesktop.Hal was not provided by any .service files 88: IDE 00.0: 10600 Disk [Created at block.243] Unique ID: 3OOL.cxF1BuTlEDD Parent ID: w7Y8.mL+OcbU+PEA SysFS ID: /class/block/sda SysFS BusID: 0:0:0:0 SysFS Device Link: /devices/pci0000:00/0000:00:1f.2/host0/target0:0:0/0:0:0:0 Hardware Class: disk Model: "ST9250610NS" Device: "ST9250610NS" Revision: "SN01" Serial ID: "9XE00BTT" Driver: "ahci", "sd" Driver Modules: "ahci" Device File: /dev/sda Device Files: /dev/sda, /dev/disk/by-id/ata-ST9250610NS_9XE00BTT, /dev/disk/by-id/scsi-SATA_ST9250610NS_9XE00BTT, /dev/disk/by-id/wwn-0x5000c50035319eee, /dev/disk/by-path/pci-0000:00:1f.2-scsi-0:0:0:0 Device Number: block 8:0-8:15 Geometry (Logical): CHS 30401/255/63 Size: 488397168 sectors a 512 bytes Config Status: cfg=new, avail=yes, need=no, active=unknown Attached to: #32 (SATA controller)
Drive Group Information, Disk behind RAID card
- sg3_utils
root@ubuntu:~$ sudo apt-get install sg3-utils root@ubuntu:~$ sg_map /dev/sg0 /dev/sda /dev/sg1 /dev/sg2 /dev/sdb /dev/sg3 /dev/sdc /dev/sg4 /dev/sdd /dev/sg5 /dev/sde /dev/sg6 /dev/sdf /dev/sg7 /dev/sdg /dev/sg8 /dev/sdh /dev/sg9 /dev/sdi root@ubuntu:~$ sginfo /dev/sg0 INQUIRY response (cmd: 0x12) ---------------------------- Device Type 0 Vendor: ATA Product: ST9250610NS Revision level: SN01
- MegaRAID 資訊
http://www.lsi.com/channel/products/storagecomponents/Pages/6GBSATA_SASRAIDCards.aspx
http://store.lsi.com/store.cfm/MegaRAID_Controllers/9260_Controllers/LSI00201/
http://www.lsi.com/channel/products/storagecomponents/Pages/MegaRAIDSAS9260-4i.aspx
root@ubuntu:~$ modinfo megaraid_sas filename: /lib/modules/3.2.0-23-generic/kernel/drivers/scsi/megaraid/megaraid_sas.ko description: LSI MegaRAID SAS Driver author: megaraidlinux@lsi.com version: 00.00.06.12-rc1 license: GPL srcversion: B0EE8D562F66C8547CAF07E alias: pci:v00001000d0000005Dsv*sd*bc*sc*i* alias: pci:v00001000d0000005Bsv*sd*bc*sc*i* alias: pci:v00001028d00000015sv*sd*bc*sc*i* alias: pci:v00001000d00000413sv*sd*bc*sc*i* alias: pci:v00001000d00000071sv*sd*bc*sc*i* alias: pci:v00001000d00000073sv*sd*bc*sc*i* alias: pci:v00001000d00000079sv*sd*bc*sc*i* alias: pci:v00001000d00000078sv*sd*bc*sc*i* alias: pci:v00001000d0000007Csv*sd*bc*sc*i* alias: pci:v00001000d00000060sv*sd*bc*sc*i* alias: pci:v00001000d00000411sv*sd*bc*sc*i* depends: intree: Y vermagic: 3.2.0-23-generic SMP mod_unload modversions parm: poll_mode_io:Complete cmds from IO path, (default=0) (int) parm: max_sectors:Maximum number of sectors per IO command (int) parm: msix_disable:Disable MSI-X interrupt handling. Default: 0 (int)
根據 smartctl 的說明, 應該用 3ware or megaraid 這兩個參數就可以看到後面的硬碟才對.. 不過還沒試成功
root@ubuntu:~$ smartctl -a -d 3ware,0 /dev/sd1 root@ubuntu:~$ smartctl -a -d megaraid,0 /dev/sd1
最後用了 LSI 官網的工具 MegaCli
http://lzj0470.iteye.com/blog/1399221
http://www.osslab.com.tw/index.php?title=Storage/Enterprise/SAS%E8%88%87RAID/LSI
http://www.osslab.com.tw/Storage/Enterprise/SAS%E8%88%87RAID/LSI/MegaRAID_CLI%E7%B0%A1%E4%BB%8B
http://www.weithenn.org/cgi-bin/wiki.pl?MegaCLI-%E6%9F%A5%E7%9C%8B_PERC_5i_RAID_Controller_%E7%8B%80%E6%85%8B#Heading10
不過要注意的是這個工具不支援 3.0 以後的 Kernel, 但我在 Ubuntu 官網找到暫解
http://askubuntu.com/questions/112455/megaraid-sas-raid-controller
指令集
http://kb.lsi.com/KnowledgebaseArticle16516.aspx
root@ubuntu:~$ unzip 8.02.21_MegaCLI.zip
root@ubuntu:~$ cd 8.02.21_Linux_MegaCLI
root@ubuntu:~8.02.21_Linux_MegaCLI$ unzip MegaCliLin.zip
root@ubuntu:~8.02.21_Linux_MegaCLI$ sudo apt-get install alien
root@ubuntu:~8.02.21_Linux_MegaCLI$ alien -k Lib_Utils-1.00-09.noarch.rpm
lib-utils_1.00-09_all.deb generated
root@ubuntu:~8.02.21_Linux_MegaCLI$ alien -k MegaCli-8.02.21-1.noarch.rpm
megacli_8.02.21-1_all.deb generated
root@ubuntu:~8.02.21_Linux_MegaCLI$ dpkg -i *.deb
root@ubuntu:~8.02.21_Linux_MegaCLI$ cd /opt/MegaRAID/MegaCli/
root@ubuntu:/opt/MegaRAID/MegaCli$ sudo setarch x86_64 --uname-2.6 /opt/MegaRAID/MegaCli/MegaCli64 -v
MegaCLI SAS RAID Management Tool Ver 8.02.21 Oct 21, 2011
(c)Copyright 2011, LSI Corporation, All Rights Reserved.
Exit Code: 0x00
root@ubuntu:/opt/MegaRAID/MegaCli$ sudo setarch x86_64 --uname-2.6 /opt/MegaRAID/MegaCli/MegaCli64 -adpCount
Controller Count: 1.
Exit Code: 0x01
root@ubuntu:/opt/MegaRAID/MegaCli$ sudo setarch x86_64 --uname-2.6 /opt/MegaRAID/MegaCli/MegaCli64 -PDList -aALL
Enclosure Device ID: 12
Slot Number: 8
Drive's postion: DiskGroup: 3, Span: 0, Arm: 2
Enclosure position: 0
Device Id: 15
WWN: 50024E920543493B
Sequence Number: 2
Media Error Count: 0
Other Error Count: 0
Predictive Failure Count: 0
Last Predictive Failure Event Seq Number: 0
PD Type: SATA
Raw Size: 931.512 GB [0x74706db0 Sectors]
Non Coerced Size: 931.012 GB [0x74606db0 Sectors]
Coerced Size: 931.0 GB [0x74600000 Sectors]
Firmware state: Online, Spun Up
Device Firmware Level: 0001
Shield Counter: 0
Successful diagnostics completion on : N/A
SAS Address(0): 0x5000ae40000168ae
Connected Port Number: 0(path0)
Inquiry Data: S2JBJ9BB500090 SAMSUNG HE103SJ 1AJ10001
FDE Enable: Disable
Secured: Unsecured
Locked: Unlocked
Needs EKM Attention: No
Foreign State: None
Device Speed: 3.0Gb/s
Link Speed: 3.0Gb/s
Media Type: Hard Disk Device
Drive Temperature : N/A
PI Eligibility: No
Drive is formatted for PI information: No
PI: No PI
Drive's write cache : Disabled
Drive's NCQ setting : Disabled
Port-0 :
Port status: Active
Port's Linkspeed: 3.0Gb/s
Drive has flagged a S.M.A.R.T alert : No
root@ubuntu:/opt/MegaRAID/MegaCli$ sudo setarch x86_64 --uname-2.6 /opt/MegaRAID/MegaCli/MegaCli64 -LDInfo -LALL -aAll
Virtual Drive: 3 (Target Id: 3)
Name :
RAID Level : Primary-5, Secondary-0, RAID Level Qualifier-3
Size : 1.818 TB
Parity Size : 931.0 GB
State : Optimal
Strip Size : 64 KB
Number Of Drives : 3
Span Depth : 1
Default Cache Policy: WriteThrough, ReadAdaptive, Direct, No Write Cache if Bad BBU
Current Cache Policy: WriteThrough, ReadAdaptive, Direct, No Write Cache if Bad BBU
Default Access Policy: Read/Write
Current Access Policy: Read/Write
Disk Cache Policy : Disk's Default
Encryption Type : None
Is VD Cached: No
root@ubuntu:/opt/MegaRAID/MegaCli$ sudo setarch x86_64 --uname-2.6 /opt/MegaRAID/MegaCli/MegaCli64 -h
MegaCLI SAS RAID Management Tool Ver 8.02.21 Oct 21, 2011
(c)Copyright 2011, LSI Corporation, All Rights Reserved.
NOTE: The following options may be given at the end of any command below:
[-Silent] [-AppLogFile filename] [-NoLog] [-page[N]]
[-] is optional.
N - Number of lines per page.
MegaCli -v
MegaCli -help|-h|?
MegaCli -adpCount
MegaCli -AdpSetProp {CacheFlushInterval -val} | { RebuildRate -val}
| {PatrolReadRate -val} | {BgiRate -val} | {CCRate -val} | {ForceSGPIO -val}
| {ReconRate -val} | {SpinupDriveCount -val} | {SpinupDelay -val}
| {CoercionMode -val} | {ClusterEnable -val} | {PredFailPollInterval -val}
| {BatWarnDsbl -val} | {EccBucketSize -val} | {EccBucketLeakRate -val}
| {AbortCCOnError -val} | AlarmEnbl | AlarmDsbl | AlarmSilence
| {SMARTCpyBkEnbl -val} | {SSDSMARTCpyBkEnbl -val} | NCQEnbl | NCQDsbl
| {MaintainPdFailHistoryEnbl -val} | {RstrHotSpareOnInsert -val}
| {DisableOCR -val} | {BootWithPinnedCache -val} | {enblPI -val} |{PreventPIImport -val}
| AutoEnhancedImportEnbl | AutoEnhancedImportDsbl
| {EnblSpinDownUnConfigDrvs -val}|{UseDiskActivityforLocate -val} -aN|-a0,1,2|-aALL
| {ExposeEnclDevicesEnbl -val} | {SpinDownTime -val}
| {SpinUpEncDrvCnt -val} | {SpinUpEncDelay -val} | {Perfmode -val} -aN|-a0,1,2|-aALL
MegaCli -AdpSetProp -AutoDetectBackPlaneDsbl -val -aN|-a0,1,2|-aALL
val - 0=Enable Auto Detect of SGPIO and i2c SEP.
1=Disable Auto Detect of SGPIO.
2=Disable Auto Detect of i2c SEP.
3=Disable Auto Detect of SGPIO and i2c SEP.
MegaCli -AdpSetProp -CopyBackDsbl -val -aN|-a0,1,2|-aALL
val - 0=Enable Copyback.
1=Disable Copyback.
MegaCli -AdpSetProp -EnableJBOD -val -aN|-a0,1,2|-aALL
val - 0=Disable JBOD mode.
1=Enable JBOD mode.
MegaCli -AdpSetProp -DsblCacheBypass -val -aN|-a0,1,2|-aALL
val - 0=Enable Cache Bypass.
1=Disable Cache Bypass.
MegaCli -AdpSetProp -LoadBalanceMode -val -aN|-a0,1,2|-aALL
val - 0=Auto Load balance mode.
1=Disable Load balance mode.
MegaCli -AdpSetProp -UseFDEOnlyEncrypt -val -aN|-a0,1,2|-aALL
val - 0=FDE and controller encryption (if HW supports) is allowed.
1=Only support FDE encryption, disallow controller encryption.
MegaCli -AdpSetProp -PrCorrectUncfgdAreas -val -aN|-a0,1,2|-aALL
val - 0= Correcting Media error during PR is disabled.
1=Correcting Media error during PR is allowed.
MegaCli -AdpSetProp -DsblSpinDownHSP -val -aN|-a0,1,2|-aALL
val - 0= Spinning down the Hot Spare is enabled.
1=Spinning down the Hot Spare is disabled.
MegaCli -AdpSetProp -DefaultLdPSPolicy -Automatic| -None | -Maximum| -MaximumWithoutCaching -aN|-a0,1,2|-aALL
MegaCli -AdpSetProp -DisableLdPS -interval n1 -time n2 -aN|-a0,1,2|-aALL
where n1 is the number of hours beginning at time n2
where n2 is the number of minutes from 12:00am
MegaCli -AdpSetProp -ENABLEEGHSP -val -aN|-a0,1,2|-aALL
val - 0= Disabled Emergency GHSP.
1= Enabled Emergency GHSP.
MegaCli -AdpSetProp -ENABLEEUG -val -aN|-a0,1,2|-aALL
val - 0= Disabled Emergency UG as Spare.
1= Enabled Emergency UG as Spare.
MegaCli -AdpSetProp -ENABLEESMARTER -val -aN|-a0,1,2|-aALL
val - 0= Disabled Emergancy Spare as Smarter.
1= Enabled Emergancy Spare as Smarter.
MegaCli -AdpSetProp -DPMenable -val -aN|-a0,1,2|-aALL
val - 0=Disable Drive Performance Monitoring .
1=Enable Drive Performance Monitoring.
MegaCli -AdpSetProp -SupportSSDPatrolRead -val -aN|-a0,1,2|-aALL
val - 0=Disable Patrol read for SSD drives .
1=Enable Patrol read for SSD drives.
MegaCli -AdpGetProp CacheFlushInterval | RebuildRate | PatrolReadRate | ForceSGPIO
| BgiRate | CCRate | ReconRate | SpinupDriveCount | SpinupDelay
| CoercionMode | ClusterEnable | PredFailPollInterval | BatWarnDsbl
| EccBucketSize | EccBucketLeakRate | EccBucketCount | AbortCCOnError
| AlarmDsply | SMARTCpyBkEnbl | SSDSMARTCpyBkEnbl | NCQDsply
| MaintainPdFailHistoryEnbl | RstrHotSpareOnInsert
| EnblSpinDownUnConfigDrvs | DisableOCR
| BootWithPinnedCache | enblPI |PeventPIImport | AutoEnhancedImportDsply | AutoDetectBackPlaneDsbl
| CopyBackDsbl | LoadBalanceMode | UseFDEOnlyEncrypt | WBSupport | EnableJBOD
| DsblCacheBypass | ExposeEnclDevicesEnbl | SpinDownTime | PrCorrectUncfgdAreas
| UseDiskActivityforLocate | ENABLEEGHSP | ENABLEEUG | ENABLEESMARTER | Perfmode | -DPMenable -aN|-a0,1,2|-aALL
| DefaultLdPSPolicy | DisableLdPsInterval | DisableLdPsTime | SpinUpEncDrvCnt
| SpinUpEncDelay | PrCorrectUncfgdAreas
| DsblSpinDownHSP | SupportSSDPatrolRead -aN|-a0,1,2|-aALL
MegaCli -AdpAllInfo -aN|-a0,1,2|-aALL
MegaCli -AdpGetTime -aN|-a0,1,2|-aALL
MegaCli -AdpSetTime yyyymmdd hh:mm:ss -aN
MegaCli -AdpSetVerify -f fileName -aN|-a0,1,2|-aALL
MegaCli -AdpBIOS -Enbl |-Dsbl | -SOE | -BE | EnblAutoSelectBootLd | DsblAutoSelectBootLd | -Dsply -aN|-a0,1,2|-aALL
MegaCli -AdpBootDrive {-Set {-Lx | -physdrv[E0:S0]}} | {-Unset {-Lx | -physdrv[E0:S0]}} |-Get -aN|-a0,1,2|-aALL
MegaCli -AdpAutoRbld -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-aALL
MegaCli -AdpCacheFlush -aN|-a0,1,2|-aALL
MegaCli -AdpPR -Dsbl|EnblAuto|EnblMan|Start|Suspend|Resume|Stop|Info|SSDPatrolReadEnbl |SSDPatrolReadDsbl
|{SetDelay Val}|{-SetStartTime yyyymmdd hh}|{maxConcurrentPD Val} -aN|-a0,1,2|-aALL
MegaCli -AdpCcSched -Dsbl|-Info|{-ModeConc | -ModeSeq [-ExcludeLD -LN|-L0,1,2]
[-SetStartTime yyyymmdd hh ] [-SetDelay val ] } -aN|-a0,1,2|-aALL
MegaCli -AdpCcSched -SetStartTime yyyymmdd hh -aN|-a0,1,2|-aALL
MegaCli -AdpCcSched -SetDelay val -aN|-a0,1,2|-aALL
MegaCli -FwTermLog -BBUoff|BBUoffTemp|BBUon|BBUGet|Dsply|Clear -aN|-a0,1,2|-aALL
MegaCli -AdpAlILog -aN|-a0,1,2|-aALL
MegaCli -AdpDiag [val] -aN|-a0,1,2|-aALL
val - Time in second.
MegaCli -AdpGetPciInfo -aN|-a0,1,2|-aALL
MegaCli -AdpShutDown -aN|-a0,1,2|-aALL
MegaCli -PDList -aN|-a0,1,2|-aALL
MegaCli -PDGetNum -aN|-a0,1,2|-aALL
MegaCli -pdInfo -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PDOnline -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PDOffline -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PDMakeGood -PhysDrv[E0:S0,E1:S1,...] | [-Force] -aN|-a0,1,2|-aALL
MegaCli -PDMakeJBOD -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PDHSP {-Set [-Dedicated [-ArrayN|-Array0,1,2...]] [-EnclAffinity] [-nonRevertible]}
|-Rmv -PhysDrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PDRbld -Start|-Stop|-Suspend|-Resume|-ShowProg |-ProgDsply
-PhysDrv [E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PDClear -Start|-Stop|-ShowProg |-ProgDsply
-PhysDrv [E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PdLocate {[-start] | -stop} -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PdMarkMissing -physdrv[E0:S0,E1:S1,...] -aN|-a0,1,2|-aALL
MegaCli -PdGetMissing -aN|-a0,1,2|-aALL
MegaCli -PdReplaceMissing -physdrv[E0:S0] -arrayA, -rowB -aN
MegaCli -PdPrpRmv [-UnDo] -physdrv[E0:S0] -aN|-a0,1,2|-aALL
MegaCli -EncInfo -aN|-a0,1,2|-aALL
MegaCli -EncStatus -aN|-a0,1,2|-aALL
MegaCli -PhyInfo -phyM -aN|-a0,1,2|-aALL
MegaCli -PhySetLinkSpeed -phyM -speed -aN|-a0,1,2|-aALL
MegaCli -PdFwDownload [offline][ForceActivate] {[-SataBridge] -PhysDrv[0:1] }|{-EncdevId[devId1]} -f <filename> -aN|-a0,
1,2|-aALL
MegaCli -LDInfo -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
MegaCli -LDSetProp {-Name LdNamestring} | -RW|RO|Blocked|RemoveBlocked | WT|WB|ForcedWB [-Immediate] |RA|NORA|ADRA
| Cached|Direct | -EnDskCache|DisDskCache | CachedBadBBU|NoCachedBadBBU
-Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
MegaCli -LDSetPowerPolicy -Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching
-Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
MegaCli -LDGetProp -Cache | -Access | -Name | -DskCache | -PSPolicy | Consistency -Lx|-L0,1,2|-LALL
-aN|-a0,1,2|-aALL
MegaCli -LDInit {-Start [-full]}|-Abort|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL
MegaCli -LDCC {-Start [-force]}|-Abort|-Suspend|-Resume|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL
MegaCli -LDBI -Enbl|-Dsbl|-getSetting|-Abort|-Suspend|-Resume|-ShowProg|-ProgDsply -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL
MegaCli -LDRecon {-Start -rX [{-Add | -Rmv} -Physdrv[E0:S0,...]]}|-ShowProg|-ProgDsply
-Lx -aN
MegaCli -LdPdInfo -aN|-a0,1,2|-aALL
MegaCli -LDGetNum -aN|-a0,1,2|-aALL
MegaCli -LDBBMClr -Lx|-L0,1,2,...|-Lall -aN|-a0,1,2|-aALL
MegaCli -getLdExpansionInfo -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
MegaCli -LdExpansion -pN -dontExpandArray -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
MegaCli -GetBbtEntries -Lx|-L0,1,2|-Lall -aN|-a0,1,2|-aALL
MegaCli -Cachecade -assign|-remove -Lx|-L0,1,2|-LALL -aN|-a0,1,2|-aALL
MegaCli -CfgLdAdd -rX[E0:S0,E1:S1,...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached]
[CachedBadBBU|NoCachedBadBBU] [-szXXX [-szYYY ...]]
[-strpszM] [-Hsp[E0:S0,...]] [-AfterLdX] [-Force]|[FDE|CtrlBased]
[-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI]-aN
MegaCli -CfgCacheCadeAdd [-rX] -Physdrv[E0:S0,...] {-Name LdNamestring} [WT|WB|ForcedWB] [-assign -LX|L0,2,5..|LALL] -aN|-a0,1,2|-aALL
MegaCli -CfgEachDskRaid0 [WT|WB] [NORA|RA|ADRA] [Direct|Cached]
[CachedBadBBU|NoCachedBadBBU] [-strpszM]|[FDE|CtrlBased] [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] -aN|-a0,1,2|-aALL
MegaCli -CfgClr [-Force] -aN|-a0,1,2|-aALL
MegaCli -CfgDsply -aN|-a0,1,2|-aALL
MegaCli -CfgCacheCadeDsply -aN|-a0,1,2|-aALL
MegaCli -CfgLdDel -LX|-L0,2,5...|-LALL [-Force] -aN|-a0,1,2|-aALL
MegaCli -CfgCacheCadeDel -LX|-L0,2,5...|-LALL -aN|-a0,1,2|-aALL
MegaCli -CfgFreeSpaceinfo -aN|-a0,1,2|-aALL
MegaCli -CfgSpanAdd -r10 -Array0[E0:S0,E1:S1] -Array1[E0:S0,E1:S1] [-ArrayX[E0:S0,E1:S1] ...]
[WT|WB] [NORA|RA|ADRA] [Direct|Cached] [CachedBadBBU|NoCachedBadBBU]
[-szXXX[-szYYY ...]][-strpszM][-AfterLdX][-Force]|[FDE|CtrlBased]
[-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] -aN
MegaCli -CfgSpanAdd -r50 -Array0[E0:S0,E1:S1,E2:S2,...] -Array1[E0:S0,E1:S1,E2:S2,...]
[-ArrayX[E0:S0,E1:S1,E2:S2,...] ...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached]
[CachedBadBBU|NoCachedBadBBU][-szXXX[-szYYY ...]][-strpszM][-AfterLdX][-Force]|
[FDE|CtrlBased] [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] -aNMegaCli -CfgSpanAdd -r60 -Array0[E0:S0,E1:S1,E2:S2,E3,S3...] -Array1[E0:S0,E1:S1,E2:S2,E3,S3...]
[-ArrayX[E0:S0,E1:S1,E2:S2,E3,S3...] ...] [WT|WB] [NORA|RA|ADRA] [Direct|Cached]
[CachedBadBBU|NoCachedBadBBU][-szXXX[-szYYY ...]][-strpszM][-AfterLdX][-Force]|
[FDE|CtrlBased] [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] -aNMegaCli -CfgAllFreeDrv -rX [-SATAOnly] [-SpanCount XXX] [WT|WB] [NORA|RA|ADRA]
[Direct|Cached] [CachedBadBBU|NoCachedBadBBU] [-strpszM]
[-HspCount XX [-HspType -Dedicated|-EnclAffinity|-nonRevertible]]|
[FDE|CtrlBased] [-Default| -Automatic| -None| -Maximum| -MaximumWithoutCaching] [-Cache] [-enblPI] -aN
MegaCli -CfgSave -f filename -aN
MegaCli -CfgRestore -f filename -aN
MegaCli -CfgForeign -Scan | [-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL
MegaCli -CfgForeign -Dsply [x] | [-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL
MegaCli -CfgForeign -Preview [x] | [-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL
MegaCli -CfgForeign -Import [x] | [-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL
MegaCli -CfgForeign -Clear [x]|[-SecurityKey sssssssssss] -aN|-a0,1,2|-aALL
x - index of foreign configurations. Optional. All by default.
MegaCli -AdpEventLog -GetEventLogInfo -aN|-a0,1,2|-aALL
MegaCli -AdpEventLog -GetEvents {-info -warning -critical -fatal} {-f <filename>} -aN|-a0,1,2|-aALL
MegaCli -AdpEventLog -GetSinceShutdown {-info -warning -critical -fatal} {-f <filename>} -aN|-a0,1,2|-aALL
MegaCli -AdpEventLog -GetSinceReboot {-info -warning -critical -fatal} {-f <filename>} -aN|-a0,1,2|-aALL
MegaCli -AdpEventLog -IncludeDeleted {-info -warning -critical -fatal} {-f <filename>} -aN|-a0,1,2|-aALL
MegaCli -AdpEventLog -GetLatest n {-info -warning -critical -fatal} {-f <filename>} -aN|-a0,1,2|-aALL
MegaCli -AdpEventLog -GetCCIncon -f <filename> -LX|-L0,2,5...|-LALL -aN|-a0,1,2|-aALL
MegaCli -AdpEventLog -Clear -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuStatus -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuCapacityInfo -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuDesignInfo -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetBbuProperties -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -BbuLearn -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -BbuMfgSleep -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -BbuMfgSeal -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -getBbumodes -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -SetBbuProperties -f <filename> -aN|-a0,1,2|-aALL
MegaCli -AdpBbuCmd -GetGGEEPData offset [Hexaddress] NumBytes n -aN|-a0,1,2|-aALL
MegaCli -AdpFacDefSet -aN
MegaCli -AdpFwFlash -f filename [-NoSigChk] [-NoVerChk] [-FWTYPE n] -aN|-a0,1,2|-aALL
MegaCli -AdpGetConnectorMode -ConnectorN|-Connector0,1|-ConnectorAll -aN|-a0,1,2|-aALL
MegaCli -AdpSetConnectorMode -Internal|-External|-Auto -ConnectorN|-Connector0,1|-ConnectorAll -aN|-a0,1,2|-aALL
MegaCli -PhyErrorCounters -aN|-a0,1,2|-aALL
MegaCli -DirectPdMapping -Enbl|-Dsbl|-Dsply -aN|-a0,1,2|-aALL
MegaCli -PDCpyBk -Start -PhysDrv[E0:S0,E1:S1] -aN|-a0,1,2|-aALL
MegaCli -PDCpyBk -Stop|-Suspend|-Resume|-ShowProg|-ProgDsply -PhysDrv[E0:S0] -aN|-a0,1,2|-aALL
MegaCli -PDInstantSecureErase -PhysDrv[E0:S0,E1:S1,...] | [-Force] -aN|-a0,1,2|-aALL
MegaCli -CfgSpanAdd -rX -array0[E0:S1,E1:S1.....] array1[E0:S1,E1:S1.....] -szxxx -enblPI -aN|-a0,1,2|-aALL
MegaCli -AdpSetVerify -f verify.txt -aN|-a0,1,2|-aALL
MegaCli -LDMakeSecure -Lx|-L0,1,2,...|-Lall -aN|-a0,1,2|-aALL
MegaCli -DestroySecurityKey | [-Force] -aN
MegaCli -CreateSecurityKey -SecurityKey sssssssssss | [-Passphrase sssssssssss] |[-KeyID kkkkkkkkkkk] -aN
MegaCli -CreateSecurityKey useEKMS -aN
MegaCli -ChangeSecurityKey -OldSecurityKey sssssssssss | -SecurityKey sssssssssss|
[-Passphrase sssssssssss] | [-KeyID kkkkkkkkkkk] -aN
MegaCli -ChangeSecurityKey -SecurityKey sssssssssss|
[-Passphrase sssssssssss] | [-KeyID kkkkkkkkkkk] -aN
MegaCli -ChangeSecurityKey useEKMS -OldSecurityKey sssssssssss -aN
MegaCli -GetKeyID [-PhysDrv[E0:S0]] -aN
MegaCli -SetKeyID -KeyID kkkkkkkkkkk -aN
MegaCli -VerifySecurityKey -SecurityKey sssssssssss -aN
MegaCli -GetPreservedCacheList -aN|-a0,1,2|-aALL
MegaCli -DiscardPreservedCache -Lx|-L0,1,2|-Lall -force -aN|-a0,1,2|-aALL
sssssssssss - It must be between eight and thirty-two
characters and contain at least one number,
one lowercase letter, one uppercase
letter and one non-alphanumeric character.
kkkkkkkkkkk - Must be less than 256 characters.
MegaCli -ShowSummary [-f filename] -aN
MegaCli -ELF -GetSafeId -aN|-a0,1,2|-aALL
MegaCli -ELF -ControllerFeatures -aN|-a0,1,2|-aALL
MegaCli -ELF -Applykey key <-val> [Preview] -aN|-a0,1,2|-aALL
MegaCli -ELF -TransferToVault -aN|-a0,1,2|-aALL
MegaCli -ELF -DeactivateTrialKey -aN|-a0,1,2|-aALL
MegaCli -ELF -ReHostInfo -aN|-a0,1,2|-aALL
MegaCli -ELF -ReHostComplete -aN|-a0,1,2|-aALL
MegaCli -LDViewMirror -Lx|-L0,1,2,...|-Lall -aN|-a0,1,2|-aALL
MegaCli -LDJoinMirror -DataSrc <val> [-force] -Lx|-L0,1,2,...|-Lall -aN|-a0,1,2|-aALL
MegaCli -SecureErase
Start[
Simple|
[Normal [ |ErasePattern ErasePatternA|ErasePattern ErasePatternA ErasePattern ErasePatternB]]|
[Thorough [ |ErasePattern ErasePatternA|ErasePattern ErasePatternA ErasePattern ErasePatternB]]]
| Stop
| ShowProg
| ProgDsply
[-PhysDrv [E0:S0,E1:S1,...] | -Lx|-L0,1,2|-LALL] -aN|-a0,1,2|-aALL
MegaCli -Version -Cli|-Ctrl|-Driver|-Pd -aN|-a0,1,2|-aALL
MegaCli -Perfmon {-start -interval <val>} | {stop} | {-getresults -f <filename>} -aN
MegaCli -DpmStat -Dsply {lct | hist | ra | ext } [-physdrv[E0:S0]] -aN|-a0,1,2|-aALL
MegaCli -DpmStat -Clear {lct | hist | ra | ext } -aN|-a0,1,2|-aALL
Note: The directly connected drives can be specified as [:S]
Wildcard '?' can be used to specify the enclosure ID for the drive in the
only enclosure without direct connected device or the direct connected
drives with no enclosure in the system.
Note:[-aALL] option assumes that the parameters specified are valid
for all the Adapters.
The following options may be given at the end of any command above:
[-Silent] [-AppLogFile filename] [-NoLog] [-page[N]]
[-] is optional.
N - Number of lines per page.
Reference:
http://www.cyberciti.biz/faq/find-hard-disk-hardware-specs-on-linux/
http://www.cyberciti.biz/tips/sdparm-linux-scsi-device-attribute.html
http://unix.stackexchange.com/questions/5085/how-to-see-disk-details-like-manufacturer-in-linux
http://freejabber.com/2012/01/30/monitoring-your-raid-array-drives-and-standalone-drives-in-ubuntu-linux-using-smartmontools/
http://www.cyberciti.biz/faq/unix-linux-freebsd-3w-9xxx-smartctl-check-hard-disk-command/
2012年4月26日 星期四
Linux udev 筆記
http://zh.wikipedia.org/wiki/Udev
- udev 是Linux kernel 2.6系列的設備管理器, 用來接替devfs及hotplug的功能, 依賴於升級後的Linux kernel 2.6.13的uevent介面的最新版本
- udev支持設備的固定命名,而並不依賴於設備插入系統的順序。默認的udev設置提供了存儲設備的固定命名。任何硬碟都根據其唯一的文件系統id、磁碟名稱及硬體連接的物理位置來進行識別。
- udev完全在用戶空間執行,而不是像devfs在核心空間一樣執行
- udev系統可以分為三個部分
- libudev函數庫,可以用來獲取設備的信息。
- udevd守護進程,處於用戶空間,用於管理虛擬/dev
- 管理命令udevadm,用來診斷出錯情況。
最常被拿來配對(match)的 udev 的基本 Rules 有下面幾種.
- KERNEL - kernel 對於裝置會有一個預設名稱如第一顆 IDE 硬碟名稱就是 hda,第一個乙太網路就是 eth0 .
- SUBSYSTEM - 通常會指出這是什麼裝置硬碟就是 block,乙太網路就是 net.
- DRIVER - driver 當然就是這個裝置是靠哪一個 driver(module) 在運作的.
udev 要在命名裝置時有兩種方式 NAME 和 SYMLINK.
- NAME - 會產生唯一裝置名稱出來.
- SYMLINK - 是一個連結到真實裝置的 symbolic links.
比對(Matching) sysfs 屬性(attributes), SYSFS 是存在 /sys 的一個檔案值,如 SYSFS{dev} 就是儲存在 /sys///dev ex: /sys/block/hdc/dev
也可以用 udevinfo -ap /sys/block/sda 來看所有的資訊
udevadm info -a -p /sys/block/sda
udevinfo –a –p $(udevinfo –q path –n /dev/whatever)
udevadm info -a -p /sys/block/sda
udevinfo –a –p $(udevinfo –q path –n /dev/whatever)
裝置名稱參數
%k 代表是用 kernel 名稱來命名裝置
%n 代表是用 number 來命名裝置
http://linux.die.net/man/8/udev
http://manpages.ubuntu.com/manpages/karmic/man7/udev.7.html
注意事項
在玩 udev rules 的時候, 發現了幾個重要的事情
PROGRAM 是一個 Global variable, 任何新的 PROGRAM 都會改變他的值, 所以如果在 RUN 當中會使用到 %c, 就要特別注恴
同樣的, 在某一個 udev event 進來時會先觸發 a.rule, 再觸發 b.rule a.rule 的內容如下 (echo.sh 是一個直接回傳第一個參數的 script) 如果希望執行到目前的 rule 就停止, 不再往下執行, 可以加上 last_rule 這個 OPTION
%k 代表是用 kernel 名稱來命名裝置
%n 代表是用 number 來命名裝置
http://linux.die.net/man/8/udev
http://manpages.ubuntu.com/manpages/karmic/man7/udev.7.html
BUS | Match the bus type of the device |
KERNEL | Match the kernel device name |
ID | Match the device number on the bus |
SYSFS{filename} | Match sysfs device attribute like label, vendor, USB serial number, SCSI UUID |
PROGRAM | Call external program |
RESULT | Match the returned string of the last PROGRAM call |
NAME | The name of the node to be created |
If given with the attribute NAME{all_partitions} it will create all 15 partitions of a blockdevice | |
SYMLINK | The name of a symlink targeting the node. |
DEVPATH | Match the devpath of the event devices (Ubuntu) |
SUBSYSTEM | Match the subsystem of the event device (Ubuntu) |
ATTR{filename} | Match sysfs attributes of the event device (Ubuntu) |
TAG{key} | Search the devpath upwarrds for a devices with matching tag (Ubuntu) |
RUN | Add a problem to the list of programs (Ubuntu) |
LABEL | A name label to which a GOTO may jump |
GOTO | Jumps to the next LABEL with a matching name |
IMPORT{type} | Import a set of variables as device properties, depends on type (Ubuntu) |
program: execute an external program | |
file: import a text file specified as the assigned value | |
Cmdline: Import a single property from the kernel command line | |
Parent: import the stored keys from the parent device |
%n | Kernel number |
%k | Kernel name |
%M | Kernel major name |
%m | Kernel minor name |
%b | Bus id |
%c | The string returned from execution of PROGRAM |
%c{N} | A single part of the string, separated by a space character |
%s{filename} | Content of a sysfs attribute |
%3s{filename} | Only insert the first three characters of sysfs attribute |
%p | The devpath of the device (Ubuntu) |
%E{key} | A device property value |
%P | The node name of the parent device |
%N | The name of a temporary device node created to provide access to the device from a external program before the real node is created |
注意事項
在玩 udev rules 的時候, 發現了幾個重要的事情
- PROGRAM 是立即執行
- RUN 是先加到一串執行序列中, 等到所有的 rules 都 parse 完後, 才會執行 比方說我寫了兩個 rule, 在某一個 udev event 進來時會先觸發 a.rule, 再觸發 b.rule a.rule 的內容為
PROGRAM=="print.sh a.program" RUN+="print.sh a.run"b.rule 的內容為
PROGRAM=="print.sh b.program" RUN+="print.sh b.run"那執行的結果應該會是
a.program b.program a.run b.run
PROGRAM=="echo.sh a.program" RUN+="print.sh %c"b.rule 的內容為
PROGRAM=="echo.sh b.program"那結果會是 b.program, 而不是 a.program, 原因是我們在 b.rules 裡面我們把 PROGRAM 的值改掉了, 所以當執行 RUN 裡面的指令時, 他使用到的是 PROGRAM 最終的值
OPTIONS="last_rule"
訂閱:
文章 (Atom)





