ESXI 6.0 monitoring SSD drive TBW

“Terabytes Written” is the total amount of data that can be written into an SSD before it is likely to fail.

There is a nicely written article on this blog explaining how to get the TBW for a SSD drive in ESXI host – open here.

However since I am a lazy kind of person I like to get stuff scripted and emailed to me.

In essence here is what I have done:

Install smartctl

  1. Download smartctl-6.6-4321.x86_64.vib
  2. Copy the VIB to the /tmp/ directory of an ESXi host
  3. SSH to the ESXi host
  4. Set the VIB acceptance level to CommunitySupported
    # esxcli software acceptance set --level=CommunitySupported
  5. Install the package (Maintenance Mode or Reboot is not required)
    #esxcli software vib install -v /tmp/smartctl-6.6-4321.x86_64.vib

The tool is located at /opt/smartmontools/smartctl and works just like the Linux version.
Locate physical disks with ls -l /dev/disks/

Create the script and automate
Save the below lines in a script somwehere:

#!/bin/sh
 var=`/opt/smartmontools/smartctl -d sat --all /dev/disks/t10.ATA_____Samsung_SSD_850_EVO_M.2_250GB___________S24BNXAH119741P_____ | grep Total_LBAs | cut -d"-" -f2`
 TBW=`awk "BEGIN {print $var*512/1099511627776}"`
 echo "Total TB Writen so far: " $TBW

var2=`/opt/smartmontools/smartctl -d sat --all /dev/disks/t10.ATA_____Samsung_SSD_850_EVO_M.2_250GB___________S24BNXAH119741P_____ | grep Power_On | cut -d"-" -f2`
 POWERON=`awk "BEGIN {print $var2/24}"`
 echo "Device in use since [days]: " $POWERON

echo "Device has 5 Years Limited Warranty or 75TBW Limited "
 REMAIN=`awk "BEGIN {print (75*$POWERON)/$TBW}"`
 echo "Device has approximately: " $REMAIN "days left"
 REMAINY=`awk "BEGIN {print $REMAIN/360}"`
 echo "that is approx. $REMAINY years left"

 

To see how much life my SSD drive has got left I added that script to /etc/profile.local file so whenever I login I get something like that:

Samsung SSD 850 Evo m.2 250GB Remaining Disk LifeTime
Tue May 24 16:30:12 UTC 2016

Total TB Written so far: 1.26013
Device in use since [days]: 97.9167
Device has 5 Years Limited Warranty or 75TBW Limited
Device has approximately: 5827.77 days left
that is approx. 16.1883 years left

As I don’t often login to my esxi host via ssh I created a cron job – /var/spool/cron/crontabs/root :

0    0   1,15 *  *    source /opt/smartmontools/report.sh > /opt/smartmontools/disklifetime.txt

and specified it to run every two weeks and save the results to a file. That file is then picked up (via scp) by my linux server and emailed to me.

Job done.

LINUX – Using Local YUM REPO on RedHat 7 using DVD ISO

Often I need to install packages that are on the RHEL install DVD and being able to use the install ISO without having a Red Hat subscription or license is extremely useful.

  • Mount the DVD to cdrom folder
mkdir /cdrom
 mount /dev/cdrom /cdrom
  • Create yum local repo file:
cd /etc/yum.repos.d
 vi local.repo

and past this content:

[LocalRepo]
 name=Local Repository
 baseurl=file:///cdrom
 enabled=1
 gpgcheck=1
 gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-redhat-release

save the file and clean yum repository cache:

yum clean all

Job done.

Intel NUC – Install USB Ethernet Adapter

The only letdown with Intel NUC is the only one Ethernet adapter. Luckily thanks to some great minds out there there is a way out of this.
All is needed is a Startech USB 3.0 to Gigabit Ethernet Adapter (Part Number: USB31000S) and the USB driver for ESXI downloadable from here: https://github.com/lamw/ax88179_178a-esxi

UPDATE (1/1/18) – Updated driver for ESXi 6.5, details here.

    • Download the driver – ESXI 6u2 driver – see above github link
    • Transfer the vib file to your ESXI host
scp vghetto-ax88179-esxi60u2.vib root@esxi:/
    • Ensure that your NUC has USB 3 adapter enabled
[root@esxi:~] lsusb
 Bus 002 Device 002: ID 0b95:1790 ASIX Electronics Corp. AX88179 Gigabit Ethernet
 Bus 001 Device 005: ID 8087:0a2b Intel Corp.
 Bus 001 Device 003: ID 0951:1665 Kingston Technology Digital DataTraveler SE9 64GB
 Bus 002 Device 001: ID 1d6b:0003 Linux Foundation 3.0 root hub
 Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
    • Install the vib driver:
[root@esxi:~] esxcli software vib install -v /vghetto-ax88179-esxi60u2.vib -f
 Installation Result
 Message: Operation finished successfully.
 Reboot Required: false
 VIBs Installed: virtuallyGhetto_bootbank_vghetto-ax88179-esxi60u2_6.0.0-1.0.0
 VIBs Removed:
 VIBs Skipped:
    • Verify that it was installed correctly:
[root@esxi:~] esxcli network nic list
 Name PCI Device Driver Admin Status Link Status Speed Duplex MAC Address MTU Description
 ------ ------------ ------------ ------------ ----------- ----- ------ ----------------- ---- --------------------------------------------
 vmnic0 0000:00:1f.6 e1000e Up Up 1000 Full b8:ae:ed:7d:e2:d5 1500 Intel Corporation Ethernet Connection I219-V
 vusb0 Pseudo ax88179_178a Up Up 1000 Full 00:24:9b:16:33:f8 1500 Unknown Unknown

esxi_nics

LINUX – Samba and Windows

I often find myself connecting to shares from  Windows to Linux and vice versa and I keep forgetting the commands – so here it is:

Connecting to a Windows share from Linux:

  • install winbind, cifs-utils and smbclient packages
  • change nsswitch.conf file (add/change this line: hosts: files wins dns ), then restart network
  • to see what shares are available on Windows box:
root@server1# smbclient -L //10.0.0.243 -U username
Enter username's password:
Domain=[contoso] OS=[Windows Server 2008 R2 Datacenter 7601 Service Pack 1] Server=[Windows Server 2008 R2 Datacenter 6.1]

Sharename Type Comment
--------- ---- -------
ADMIN$ Disk Remote Admin
C$ Disk Default share
IPC$ IPC Remote IPC
share Disk
  • Mount the Windows share from console
mount -t cifs //10.0.0.243/share test -o username=linuxacademy,password=123456,rw,nounix,file_mode=0777
  • Mount the Windows share via fstab

>pre># stuff to put in the /etc/fstab file
# remote windows file share
//10.0.0.251/share /mnt/test cifs credentials=/root/.smbcredentials,rw,nounix,file_mode=0777,dir_mode=0777 0 0

and create the .smbcredentials file under root:

username=windows_username
password=windows_password

Connecting to a Linux share from Windows (configuring samba):

  • Install samba and samba-common
  • Configure /etc/samba/smb.conf file – add or uncomment and modify this section:
[homes]
   comment = Home Directories
   browseable = no
   writable = yes

[share]
   comment = Defalt Share
   path = /share/
   force user = samba
   force group = samba
   read only = no
   hosts allow =

Restart samba: service smbd restart

  • create samba username that matches windows account password:
root@server1:/# smbpasswd -a windows_username
New SMB password:
Retype new SMB password:
Added user windows_username.