Saturday, August 18, 2012

Testing a Hard Disk

SKILLS -> Knowing your command line.

http://www.cyberciti.biz/tips/linux-find-out-if-harddisk-failing.html

This is the source article that I got the information from.  They do a great job of detailing the operation.  If the link is broken, here's the basic outline.

Install the software

apt-get install smartmontools -y

This basic command installs the smartmontools. You figured that didn't you :)

(sdx refers to one of the hard disks on your sytem.  sda,sdb,sdc,sdd)  If you don't know how to tell I would suggest using sda since that's the first in line.  If you have a second hard disk generally that's sdb.  That's generally of course.



(therefore smartctl -s on -d ata /dev/sda tests the first hard disk)





IS my harddisk smartcapable.  Usually it is but if you want to check:


smartctl -i /dev/hdx

[NOTE: If its not throw it out.  It's a junk hard disk ] 


This enables the function.


smartctl -s on -d ata /dev/sdx


Now we can read the error logs

smartctl -l error /dev/hdx

Send data to your email to yourself if you want.

/dev/sdx -m fred@myemail.com


The tests are more and more detailed but here are the basic command line structures.

 smartctl -d ata -H /dev/sdx
smartctl --attributes --log=selftest /dev/sdx
smartctl -d ata -a /dev/sdx

Short and Long tests for the hard disk

smartctl -d ata -t short /dev/sdx
smartctl -d ata -t long /dev/sdx

(output)
smartctl -a /dev/sdx

What's this?  Well if you want it all combined into a graphic interface, they use gsmartcontrol which is the graphic frontend.  
 
apt-get install gsmartcontrol

Have fun!
 






Wednesday, August 15, 2012

Remove old Kernels

Thanks to this website:

http://askubuntu.com/questions/138026/how-do-i-delete-kernels-from-a-server

At the bottom of the page is the actual script to do the job.

Ever had a problem of endless kernels on your system without the storage to manage it?

No prob.  You can remove old kernels with this script.

IMPORTANT:

If using GRUB legacy, be sure the menu.1st file contains an actual kernel you can use.  Its easy to check the current kernel running with this command:

uname -R

NOTE this will reference the running kernel and is tied to the menu.1st.  If you deleted the running kernel, just make sure you have an alternate.  ALL kernels are stored in:

/boot.

Just ls to get a list of kernels. 


DELETE all kernels.  Note this is actually one line of text.  The '\' is used to separate lines.  Save it as a file.

#!/bin/sh
dpkg -l linux-*  | \
awk '/^ii/{ print $2}' | \
grep -v -e `uname -r | cut -f1,2 -d"-"` | \
grep  -e '[0-9]' | xargs sudo apt-get -y purge