Wednesday, August 05, 2015

Linux Mint 17.2 hangs post hibernate - solution



Create a file in the /etc/pm/sleep.d/ directory called 20_custom-ehci_hcd

as super user add the following to the file:

===========Code begins============

#!/bin/sh
#inspired by http://art.ubuntuforums.org/showpost.php?p=9744970&postcount=19
#...and http://thecodecentral.com/2011/01/18/fix-ubuntu-10-10-suspendhibernate-not-working-bug   
# tidied by tqzzaa :)

VERSION=1.1
DEV_LIST=/tmp/usb-dev-list
DRIVERS_DIR=/sys/bus/pci/drivers
DRIVERS="ehci xhci" # ehci_hcd, xhci_hcd
HEX="[[:xdigit:]]"
MAX_BIND_ATTEMPTS=2
BIND_WAIT=0.1

unbindDev() {
  echo -n > $DEV_LIST 2>/dev/null
  for driver in $DRIVERS; do
    DDIR=$DRIVERS_DIR/${driver}_hcd
    for dev in `ls $DDIR 2>/dev/null | egrep "^$HEX+:$HEX+:$HEX"`; do
      echo -n "$dev" > $DDIR/unbind
      echo "$driver $dev" >> $DEV_LIST
    done
  done
}

bindDev() {
  if [ -s $DEV_LIST ]; then
    while read driver dev; do
      DDIR=$DRIVERS_DIR/${driver}_hcd
      while [ $((MAX_BIND_ATTEMPTS)) -gt 0 ]; do
          echo -n "$dev" > $DDIR/bind
          if [ ! -L "$DDIR/$dev" ]; then
            sleep $BIND_WAIT
          else
            break
          fi
          MAX_BIND_ATTEMPTS=$((MAX_BIND_ATTEMPTS-1))
      done 
    done < $DEV_LIST
  fi
  rm $DEV_LIST 2>/dev/null
}

case "$1" in
  hibernate|suspend) unbindDev;;
  resume|thaw)       bindDev;;
esac

=================Code End=========

Make the file excutable:
sudo chmod 755 /etc/pm/sleep.d/20_custom-ehci_hcd


Save the file. The hibernate issue would be solved.

Wednesday, September 03, 2014

For my Bangalore friends :-)

Dedicated to all our Bangalore friends (got as a forward on the email :-)

1. If you throw a stone randomly in Bangalore, chances are, it will hit a dog or a software engineer. While the dog may or may not have a strap (a.k.a. leash) around his neck, the software engineer will definitely have one.

2. In India we drive on the left of the road. In Bangalore, we drive on what is left of the road.

3. Q: What is the easiest way of causing traffic accidents in Bangalore?
A: Follow the traffic rules.

4. "A guy is house hunting in Bangalore. Meets old lady who is potential landlord. The conversation goes thus:Old lady: Where do you work for, son?
Guy (with an air of pompousness): I work in Infosys.
Old lady: Oh, that bus company! Sorry, we rent only to good IT people.
(It would appear that Infosys operates more buses than BMTC in Bangalore.)

5. Bangalore, where PG(Paying Guest) is the first business and IT, the second.

6. When someone says it is raining in Bangalore, be sure to ask them which area, which Main and which Cross.

7. If a Bangalorean stops at a traffic light, others behind him stop too because the others conclude that he has spotted a policeman that they themselves have not.

8. Bangalore is the only city where distance is measured in units of time.

9. Auto rickshaw driver, grocery seller and common shop keeper think that you earn at least 1 lakh per month if you are in IT sector.

10. Out of every 100 software engineers in Bangalore, 90 are utterly frustrated and rest have a girlfriend.

11. Bus drivers use the horn instead of the brakes.

12. I quote : "Bangalore: The City where more people know Language C than Kanada or Hindi".

13. Since it is easier to find an alcohol shop than a medicine shop in Bengaluru, the doctors have now started prescribing "dawa-daaru" for treatment.

Hard Disk Maintenance on Linux

How to check/repair ( fsck) filesystem after crash or power outage:

http://linuxpoison.blogspot.ca/2009/04/how-to-checkrepair-fsck-filesystem.html
http://linuxpoison.blogspot.tw/2008/01/howto-check-disk-drive-for-errors-and.html

The command 'fsck' when run with no options will check all devices in /etc/fstab.

With options, run
$ sudo fsck -t ext3 -l bad-blocks /dev/hda1

For better diagnosis, run fsck from single-user mode (You need to be "root" to use any command)
* Take system down to runlevel one: # init 1

Please note if any files are recovered then they are placed in /home/lost+found directory by fsck command.

I/O errors in /var/log/messages indicates that something is wrong with the hard disk and it may be failing.

You can check hard disk for errors using 'smartctl' command, which is control and monitor utility for SMART disks under Linux / UNIX like operating systems.
smartctl for servers
http://www.cyberciti.biz/tips/linux-find-out-if-harddisk-failing.html

smartctl -a shows a disk's SMART diagnostics.

You cn also do Linux Performance Monitoring with Vmstat and Iostat Commands:
http://www.tecmint.com/linux-performance-monitoring-with-vmstat-and-iostat-commands/

If vmstat and iostat commands are not available on your box, please install sysstat package. The vmstat, sar and iostat commands are the collection of package included in sysstat – the system monitoring tools. The iostat generates reports of CPU & all device statistics.

Download sysstat package ( Latest sysstat version is 11.0.0 (2014-06-17)) sysstat package is available as RPM, tar.gz and tar.bz2 files. This development version contains all the latest features included in sysstat:

http://sebastien.godard.pagesperso-orange.fr/download.html