Blogg
webbhotell domännamn web design seo Support
I had two hard disk fail on two servers in two week!
They ask me for harddisk serial number.
How to check that in Linux shell?
To see which harddisk I am using:
[root@srv8 home2]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda6 57G 3.8G 50G 7% / /dev/sda2 251M 29M 210M 12% /boot /dev/sda3 50G 22G 26G 46% /var /dev/sda5 10G 155M 9.3G 2% /tmp /dev/sdc1 1.3T 44G 1.2T 4% /home /dev/sdc2 1.5T 351M 1.4T 1% /home2
So I am using sda and sdc
And how many harddisk do I have:
[root@srv8 ~]# fdisk -l
Disk /dev/sda: 128.0 GB, 128035676160 bytes 255 heads, 63 sectors/track, 15566 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sda1 1 262 2102562 82 Linux swap / Solaris /dev/sda2 263 295 265072+ 83 Linux /dev/sda3 296 6823 52436160 83 Linux /dev/sda4 6824 15566 70228147+ 85 Linux extended /dev/sda5 6824 8129 10490444+ 83 Linux /dev/sda6 8130 15566 59737702 83 Linux
Disk /dev/sdb: 1500.3 GB, 1500301910016 bytes 255 heads, 63 sectors/track, 182401 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System /dev/sdb1 1 182401 1465136001 83 Linux
WARNING: GPT (GUID Partition Table) detected on '/dev/sdc'! The util fdisk doesn't support GPT. Use GNU Parted.
WARNING: The size of this disk is 3.0 TB (2999978033152 bytes). DOS partition table format can not be used on drives for volumes larger than 2.2 TB (2199023255040 bytes). Use parted(1) and GUID partition table format (GPT).
Disk /dev/sdc: 2999.9 GB, 2999978033152 bytes 255 heads, 63 sectors/track, 364726 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes
OK I need the serial number for sdb
[root@srv8 home2]# smartctl -i /dev/sdb -bash: smartctl: command not found
Now I have to install
[root@srv8 home2]# yum install smartctl Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.plusline.de * extras: ftp.plusline.de * rpmforge: ftp-stud.fht-esslingen.de * updates: ftp.plusline.de Excluding Packages in global exclude list Finished Setting up Install Process No package smartctl available. Nothing to do
That did not work!
OK then
[root@srv8 home2]# whatprovides smartctl -bash: whatprovides: command not found [root@srv8 home2]# [root@srv8 home2]# yum whatprovides smartctl Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.plusline.de * extras: ftp.plusline.de * rpmforge: ftp-stud.fht-esslingen.de * updates: ftp.plusline.de Excluding Packages in global exclude list Finished Warning: 3.0.x versions of yum would erroneously match against filenames. You can use "*/smartctl" and/or "*bin/smartctl" to get that behaviour No Matches found
hmmm linux is about to never give up!
[root@srv8 home2]# yum whatprovides */smartctl Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.plusline.de * extras: ftp.plusline.de * rpmforge: ftp-stud.fht-esslingen.de * updates: ftp.plusline.de Excluding Packages in global exclude list Finished rpmforge/filelists | 4.4 MB 00:00 1:smartmontools-5.38-2.el5.x86_64 : Tools for monitoring SMART capable hard disks Repo : base Matched from: Filename : /usr/sbin/smartctl
YES!
[root@srv8 home2]# yum install smartmontools Loaded plugins: fastestmirror Loading mirror speeds from cached hostfile * base: ftp.plusline.de * extras: ftp.plusline.de * rpmforge: ftp-stud.fht-esslingen.de * updates: ftp.plusline.de Excluding Packages in global exclude list Finished Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package smartmontools.x86_64 1:5.38-2.el5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ============================================================================================================================================================================================ Package Arch Version Repository Size ============================================================================================================================================================================================ Installing: smartmontools x86_64 1:5.38-2.el5 base 348 k Transaction Summary ============================================================================================================================================================================================ Install 1 Package(s) Upgrade 0 Package(s) Total download size: 348 k Is this ok [y/N]: y Downloading Packages: smartmontools-5.38-2.el5.x86_64.rpm | 348 kB 00:00 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : smartmontools 1/1 Installed: smartmontools.x86_64 1:5.38-2.el5 Complete!
And now the magic is working!
[root@srv8 home2]# smartctl -i /dev/sdb smartctl version 5.38 [x86_64-redhat-linux-gnu] Copyright (C) 2002-8 Bruce Allen Home page is http://smartmontools.sourceforge.net/ === START OF INFORMATION SECTION === Device Model: SAMSUNG HD154UI Serial Number: S1XWJ9AB600590 Firmware Version: 1AG01118 User Capacity: 1,500,301,910,016 bytes Device is: In smartctl database [for details use: -P show] ATA Version is: 8 ATA Standard is: ATA-8-ACS revision 3b Local Time is: Mon Sep 5 13:29:55 2011 CEST ==> WARNING: May need -F samsung or -F samsung2 enabled; see manual for details. SMART support is: Available - device has SMART capability. SMART support is: Enabled

This article was written by: Pera