Popular Posts

Tuesday, May 27, 2014

Create File of a Given Size

I was testing uuencode command and my plan was to create a 10M file and send it as a attachment.

below is the coolest way to do that :)


On Linux, you can use the dd command:

$ dd if=/dev/zero of=output.dat  bs=1024  count=10240
10240+0 records in
10240+0 records out
10485760 bytes (10 MB) copied, 0.218581 seconds, 48.0 MB/s
$ ls -hl output.dat
-rw-r--r-- 1 peter peter 10M 2008-02-09 16:21 output.dat



The above dd command creates a zero-filled file named output.dat consisting of a count of 10240 blocks, each of block size 1024.

You can also do the same thing using :

$ dd if=/dev/zero of=output.dat  bs=1M  count=10


Suggestions are welcome!

Saturday, May 17, 2014

Monday, May 12, 2014

Best android apps 2014

  • android device mgr
  • cal
  • pixlr express
  • startup mgr
  • flesky
  • feedly
  • cleaner master
  • mx player
  • big oven
  • sketch book mobile
  • assistance
  • duolingo
  • toucher pro
  • trubackup
  • themer
  • applock
  • 500 firepapers
  • the android cop
  • cpu-z

And my host got up :)

This is not any knowledge sharing post but one amazing experience that I should never forget and would like to share with you so that in future if you stuck like me this can help you :)

Sunday Afternoon (16 Feb 2014 ). Yes I work on weekends too :( I was working on some database maintenance activity and wanted to install one of the package on XYZ linux server. I typed rpm -qa command to check something and suddenly got an error “Connection refused” ! Nagios started shouting that server is down !!  Then I logged into our vm stack and found that kernel crashed because of corrupt/missing C libraries..now no option, tried maintenance mode but no luck :(  Only one option was left – boot that vm using live centos image, find existing file system and see if you can correct it.. from where to get live centos DVD ? I searched in entire storage volume and got one :) Booted VM using DVD in rescue mode and found corrupt file. Now how to correct it? I knew that server ABC is centos 5.5 tried copied file from it, matched md5sum and voila!! Server got up! J

MegaCli Commands

Adapter parameter -aN
The parameter -aN (where N is a number starting with zero or the string ALL) specifies the PERC5/i adapter ID. If you have only one controller it’s safe to use ALL instead of a specific ID, but you’re encouraged to use the ID for everything that makes changes to your RAID configuration.

Physical drive parameter -PhysDrv [E:S]
For commands that operate on one or more pysical drives, the -PhysDrv [E:S] parameter is used, where E is the enclosure device ID in which the drive resides and S the slot number (starting with zero). You can get the enclosure device ID using "MegaCli -EncInfo -aALL". The E:S syntax is also used for specifying the physical drives when creating a new RAID virtual drive.

Virtual drive parameter -Lx
The parameter -Lx is used for specifying the virtual drive (where x is a number starting with zero or the string all).

Controller information
MegaCli -AdpAllInfo -aALL
MegaCli -CfgDsply -aALL
MegaCli -AdpEventLog -GetEvents -f events.log -aALL && cat events.log
Enclosure information
MegaCli -EncInfo -aALL
Virtual drive information
MegaCli -LDInfo -Lall -aALL
Physical drive information
MegaCli -PDList -aALL
MegaCli -PDInfo -PhysDrv [E:S] -aALL
Battery backup information
MegaCli -AdpBbuCmd -aALL
Controller management

Silence active alarm
MegaCli -AdpSetProp AlarmSilence -aALL
Disable alarm
MegaCli -AdpSetProp AlarmDsbl -aALL
Enable alarm

MegaCli -AdpSetProp AlarmEnbl -aALL
Physical drive management


Set state to offline
MegaCli -PDOffline -PhysDrv [E:S] -aN
Set state to online
MegaCli -PDOnline -PhysDrv [E:S] -aN
Mark as missing

MegaCli -PDMarkMissing -PhysDrv [E:S] -aN
Prepare for removal
MegaCli -PdPrpRmv -PhysDrv [E:S] -aN
Replace missing drive

MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN
The number N of the array parameter is the Span Reference you get using "MegaCli -CfgDsply -aALL" and the number N of the row parameter is the Physical Disk in that span or array starting with zero (it’s not the physical disk’s slot!).

Rebuild drive
MegaCli -PDRbld -Start -PhysDrv [E:S] -aN
MegaCli -PDRbld -Stop -PhysDrv [E:S] -aN
MegaCli -PDRbld -ShowProg -PhysDrv [E:S] -aN
Clear drive
MegaCli -PDClear -Start -PhysDrv [E:S] -aN
MegaCli -PDClear -Stop -PhysDrv [E:S] -aN
MegaCli -PDClear -ShowProg -PhysDrv [E:S] -aN
Bad to good (or back to good as I like to call it)
MegaCli -PDMakeGood -PhysDrv[E:S] -aN
This changes drive in state Unconfigured-Bad to Unconfigured-Good.

Walkthrough: Change/replace a drive

Set the drive offline, if it is not already offline due to an error
MegaCli -PDOffline -PhysDrv [E:S] -aN
Mark the drive as missing
MegaCli -PDMarkMissing -PhysDrv [E:S] -aN
Prepare drive for removal
MegaCli -PDPrpRmv -PhysDrv [E:S] -aN
Change/replace the drive

If you’re using hot spares then the replaced drive should become your new hot spare drive:
MegaCli -PDHSP -Set -PhysDrv [E:S] -aN
In case you’re not working with hot spares, you must re-add the new drive to your RAID virtual drive and start the rebuilding

MegaCli -PdReplaceMissing -PhysDrv [E:S] -ArrayN -rowN -aN
MegaCli -PDRbld -Start -PhysDrv [E:S] -aN

How to setup passwordless ssh - linux

Tired of typing passwords every time ? then you might want to check below method :)
  
In this tutorial I will guide you regarding how to setup passwordless ssh (key based ssh) between two linux hosts.

I have 2 VMs and I would like to setup key based ssh from ansible-ground (first VM) to qabox (second VM) as root user.

Steps :

1. Generate ssh key pair on host A i.e. ansible-ground in my case.


ssh-keygen -t rsa


2. Copy public key generated in above step to host B i.e. qabox in my case.

ssh-copy-id -i ~/.ssh/id_rsa.pub root@qabox

Note : root is the username for which you need password less ssh and qabox is host B


3. On host B - set the correct permissions for copied public key.

chmod 0600 ~/.ssh/authorized_keys


4. We are done!  now try to login from A-->B with root user.


Please let me know in case of issues.