{"id":659,"date":"2020-09-18T18:14:53","date_gmt":"2020-09-18T12:14:53","guid":{"rendered":"https:\/\/mellowhost.com\/blog\/?p=659"},"modified":"2020-09-18T18:14:53","modified_gmt":"2020-09-18T12:14:53","slug":"how-to-get-disk-serial-number-in-megaraid","status":"publish","type":"post","link":"https:\/\/mellowhost.com\/blog\/how-to-get-disk-serial-number-in-megaraid.html","title":{"rendered":"How To Get Disk Serial Number in Megaraid"},"content":{"rendered":"\n<p><strong>Question:<\/strong><\/p>\n\n\n\n<p>We can use smartctl to get the disk serial ID in case of disk replacement or crashes, with the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">smartctl -a \/dev\/sdX<\/pre>\n\n\n\n<p>Where X is the device identifier like, for the first disk, this would be sda, second sdb etc. But in case the devices are behind the RAID, this command returns an error:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[root@tampa-lb ~]# smartctl -a \/dev\/sda\nsmartctl 7.0 2018-12-30 r4883 [x86_64-linux-3.10.0-1127.el7.x86_64] (local build)\nCopyright (C) 2002-18, Bruce Allen, Christian Franke, www.smartmontools.org\n\nSmartctl open device: \/dev\/sda failed: DELL or MegaRaid controller, please try adding '-d megaraid,N'<\/pre>\n\n\n\n<p>How to make this work?<\/p>\n\n\n\n<p><strong>Answer:<\/strong><\/p>\n\n\n\n<p>To get the serial numbers behind the LSI MegaRAID, you would first need to find out the device ID using LSI Megaraid tools. A quick way to install LSI Megaraid tool is available here:<\/p>\n\n\n\n<p><a href=\"https:\/\/www.mellowhost.com\/billing\/index.php?rp=\/knowledgebase\/69\/How-to-Install-LSI-Command-Line-Tool.html\">How to: Install LSI Command Line Tool<\/a><\/p>\n\n\n\n<p>One you have installed the LSI Megaraid command line tools, now you may use the following command to identify your device:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">\/opt\/MegaRAID\/MegaCli\/MegaCli64 -PDList -aAll | egrep 'Slot\\ Number|Device\\ Id|Inquiry\\ Data|Raw|Firmware\\ state' | sed 's\/Slot\/\\nSlot\/g'<\/pre>\n\n\n\n<p>This would output something like the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">Slot Number: 1\nDevice Id: 11\nRaw Size: 447.130 GB [0x37e436b0 Sectors]\nFirmware state: Online, Spun Up\nInquiry Data: 50026B72822A7D3A    KINGSTON SEDC500R480G                   SCEKJ2.3<\/pre>\n\n\n\n<p>In this server, it has one disk, but you may have multiple disk with different &#8216;Firemware state&#8217; and &#8216;Device Id&#8217;. To use smartmontools, you need to pick the &#8216;Device Id&#8217;, mentioned here, which is 11. Now you can run the following command to get the device details using smartctl:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">smartctl -d megaraid,N -a \/dev\/sdX<\/pre>\n\n\n\n<p>Here, N is the device ID, and X is the device name, you may get the device name using df -h command or fdisk -l. For our case, this command would be like the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">smartctl -d megaraid,11 -a \/dev\/sda<\/pre>\n\n\n\n<p>This would print a lot of information about your device, but if you are looking to identify the Serial Number only, you may run the following:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">~ smartctl -d megaraid,11 -a \/dev\/sda|grep Serial\nSerial Number:    50026B72822A7D3A\n<\/pre>\n\n\n\n<p>One thing to note, we can also get Serial number from the MegaCli tools Inquiry data, you may have already noticed:<\/p>\n\n\n\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"generic\" data-enlighter-theme=\"\" data-enlighter-highlight=\"\" data-enlighter-linenumbers=\"\" data-enlighter-lineoffset=\"\" data-enlighter-title=\"\" data-enlighter-group=\"\">[root@tampa-lb ~]# \/opt\/MegaRAID\/MegaCli\/MegaCli64 -PDList -aAll | grep 'Inquiry Data'\nInquiry Data: 50026B72822A7D3A    KINGSTON SEDC500R480G                   SCEKJ2.3\n<\/pre>\n\n\n\n<p>Here, the first parameter in the return is the same as smartctl returns as Serial number, it&#8217;s because it&#8217;s the serial number that megacli gets\/identifies as well.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Question: We can use smartctl to get the disk serial ID in case of disk replacement or crashes, with the following: Where X is the device identifier like, for the first disk, this would be sda, second sdb etc. But in case the devices are behind the RAID, this command returns an error: How to &hellip; <a href=\"https:\/\/mellowhost.com\/blog\/how-to-get-disk-serial-number-in-megaraid.html\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;How To Get Disk Serial Number in Megaraid&#8221;<\/span><\/a><\/p>\n","protected":false},"author":3,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[444,144,12,18],"tags":[494,492,493],"_links":{"self":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/659"}],"collection":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/comments?post=659"}],"version-history":[{"count":1,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/659\/revisions"}],"predecessor-version":[{"id":660,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/posts\/659\/revisions\/660"}],"wp:attachment":[{"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/media?parent=659"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/categories?post=659"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mellowhost.com\/blog\/wp-json\/wp\/v2\/tags?post=659"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}