0

I am creating an overview site of my hard drives (HDD) I have installed in a machine. That website requests the HDDs including the state through a lsblk command. I want to indicate the status (state) on the website by a traffic light system but the only status so far that I am aware of is "running". I did not have any failures yet hence why my question.

Can anybody tell me what other statuses there are for the state column?

Rui F Ribeiro
  • 56,709
  • 26
  • 150
  • 232

2 Answers2

4

Looking at the source code for lsblk, for the STATE column, the only states defined are running or suspended

fpmurphy
  • 4,636
  • adding a manpage as comment (yes, sorry realShadow, but it was a bit hidden): man dmsetup "suspend ... Suspends a device. Any I/O that has already been mapped by the device but has not yet completed will be flushed. Any further I/O to that device will be postponed for as long as the device is suspended. ..." . I verified it affects lsblk's output. So chances are it's meaningful in relation to stuff like LVM etc. I don't know why it's also displayed for physical devices. – A.B Feb 25 '19 at 18:34
  • Fantastic. I will head over and review the items there and see what other information I can draw out of the documentation for my website. – realShadow Feb 26 '19 at 19:44
0

You can specify output options -o for lsblk, in this case STATE is what you are looking for.

sudo lsblk -a -o NAME,MAJ:MIN,PARTTYPE,STATE
NAME   MAJ:MIN PARTTYPE                             STATE
sda      8:0                                        running
├─sda1   8:1   21686148-6449-6e6f-744e-656564454649 
├─sda2   8:2   0fc63daf-8483-4772-8e79-3d69d8477de4 
├─sda3   8:3   0fc63daf-8483-4772-8e79-3d69d8477de4 
└─sda4   8:4   0fc63daf-8483-4772-8e79-3d69d8477de4 

lsblk --help will give you more options to include if needed.

fugitive
  • 1,563
  • I downvoted because your answer does not answer the OP's question or even attempt to answer the OP's question. – fpmurphy Feb 25 '19 at 17:58