About Me

- A little contribution to the linux newbies.

Monday, February 8, 2016

Converting .OVF to .OVA on linux

You will find lots of posts that talk about converting or extracting.OVA file to .OVF, which is simple to do.


$ tar -xvf file-name.ova


Converting the other way around is useful as well. ( make sure you have ovftool utility installed on your system )

$ ovftool file-name.ovf file-name.ova


And that's it.. The conversion process will take sometime and the files will be ready for deployment.



Monday, July 21, 2014

e1000e : The NVM Checksum Is Not Valid

[   19.934486] e1000e 0000:06:00.0: (unregistered net_device): The NVM Checksum Is Not Valid
[   20.042663] e1000e 0000:06:00.0: PCI INT A disabled
[   20.101079] e1000e: probe of 0000:06:00.0 failed with error -5



I ran into this issue and spent few hours looking for a solution.
the solution that I found ( the one that actually worked ) was through Intel's NIC tools.


1. download  Preboot.tar.gz
2. decpompress the file tar xvfz Preboot.tar.gz
3. cd APPS/BootUtil/
use appropriate bootutil binary "bootutil32" or "bootutil64e"
# cd Linux_x64/
# chmod 755  bootutil64e
# rmmod e1000e 
# ./bootutil64e -WOLD -ALL
# ./bootutil64e -WOLE -ALL
# modprobe e1000e

hope this might save some of your time looking for a working solution.

Thursday, August 11, 2011

Windows 7: format FAT32 Partition

1. run cmd.exe (in Administrative mode - use Ctrl+Shift+Enter)
2. format : /FS:FAT32

hope this little piece of information saves your time.

Monday, August 2, 2010

VMware ESXi 4.0 Headless (Unattended)Install

In order to achieve this you need to do some hacks and tricks with the vmware installer scripts

1. Modify the Installer-Steps

In order to achieve this you will need to modify the install.tgz file
--------------------------------------------------------------------------------------------------

- Extract ISO
- cd to the extracted directory

- mkdir tt
- cp install.tgz tt/
- cd tt/
- tar xvvf install.tgz

- $ ls
install.tgz sbin usr

- cd usr/lib/vmware/installer/
- chmod +w ThinESXInstall.py
- vi ThinESXInstall.py


modify following line (approx line 22 )

Steps = [ WelcomeStep, LicenseStep, TargetSelectionStep, ConfirmStep, \
WriteStep, PostConfigStep, CompleteStep, RebootStep ]
to

Steps = [ TargetSelectionStep, WriteStep, RebootStep ]

--------------------------------------------------------------------------------------------------

2. Automated the Disks Selection Step in the installer script

now go to ThinESX dircetory

- cd ThinESX/
- chmod +w ThinESXInstallSteps.py
- vi ThinESXInstallSteps.py


--- modify the target selection step (approx line 56)

copy paste the following lines in the Scripts :

--------------------------------------------------------------------------------------------------

def TargetSelectionStep(data):
"""TargetSelectionStep
This install step is responsible for presenting the user with the device
selection dialog and determining the target which is being installed to."""
targets = TargetEnumeration(NotPredicate(RACVirtualMediaFilter))

if len(targets) == 0:
raise NoValidDevicesException()

if len(targets) == 1 and targets[0].IsLocal():
data['Target'] = targets[0]
return data
else:
return LaunchDialog(DeviceSelectionDialog(targets, data))

--------------------------------------------------------------------------------------------------
- Save and Exit
- cd back to tt/ directory
- rm -rf install.tgz && tar -czvf install.tgz * && chmod 755 install.tgz

--------------------------------------------------------------------------------------------------
replace the existing install.tgz file to the modified one..

Your unattended installer is ready to go..

Wednesday, June 16, 2010

Script to display all duplicate line in a file once

this script will display all the duplicate lines only once

Example:

$cat file
I like oranges
I like apples
I like pears
I like apples
I like guavas
I like oranges
I like apples

$./test.pl file

I like apples
I like oranges




#!/usr/bin/perl
#
open(FILE,"$ARGV[0]");
my @contents = ;
my %dup;
foreach $line (@contents)
{
@keyz = keys %dup;
if(!(grep(/$line/, @keyz)) || $dup{$line})
{
$dup{$line}++;
if($dup{$line} > 1)
{
print $line;
$dup{$line} = 0;
}
}
}


Tuesday, June 15, 2010

Script to upload ssh key to skip password authentication



#!/bin/bash

## Script to auto upload ssh keys on the LINUX HOST

NO_ARGS=0
E_OPTERROR=65

if [ $# -eq "$NO_ARGS" ] # should check for no arguments
then
echo "Usage: `basename $0` -i "
exit $E_OPTERROR
fi

while getopts ":ih" Option

do
case $Option in

i)
remote_host_ipaddress="$2"
;;

h)
echo "Usage: `basename $0` -i "
exit $E_OPTERROR
;;
esac
done

shift $(($OPTIND - 1))

## This will generate ssh key on the remote host
echo "Generation ssh-keygen on remote linux host"
echo $remote_host_ipaddress

ssh root@$remote_host_ipaddress /usr/bin/ssh-keygen -t dsa

echo "uploading your ssh keys on remote linux host"
scp ~/.ssh/id_dsa.pub root@$remote_host_ipaddress:/root/.ssh/authorized_keys


Friday, October 9, 2009

Expect - Sample Scripts

Following scripts will "ssh" into the remote machine and will "execute the command" that you pass to be executed on the remote system.

#!/usr/bin/expect -f
# USAGE:
#----------------------------------------------------
# ./ssh-expect.exp 'command to be executed on remote machine'
#----------------------------------------------------
# set Variables
set password [lrange $argv 0 0]
set remote_ipaddr [lrange $argv 1 1]
set scriptname [lrange $argv 2 2]
set arg1 [lrange $argv 3 3]
set timeout -1
spawn ssh root@$remote_ipaddr $scriptname $arg1
match_max 100000
# Look for passwod prompt
expect "*?assword:*"
# Send password to the remote machine
send -- "$password\r"
send -- "\r"
#terminate the connection
expect eof

Perl - Sample Scripts (useful for interview)

Script - to remove leading and trailing spaces from the passed string
--------------------------------------------------------------------------------------------------
#/usr/bin/perl


my $string = <>;
@temp = split / / , $string;
$string =~ s/^\s+//; #remove leading spaces
$string =~ s/\s+$//; #remove trailing spaces

print @temp
--------------------------------------------------------------------------------------------------

Thursday, October 1, 2009

Linux Admin - command line Interview questions

following are some sample question that you can get during a Linux command line interview

Question : In this system there is following directory structure.
-> 1 x Dir (main directory) -> 10 x Sub-Dir -> 10 x files in each subdirectories
Find out which file in the directory was lastly modified.

Answer :
$ find -type f -mtime -1


Exp : this command will find the lastly modified(within last 24 hours) file in the directory structure

Question: How can you send email from command line ??

Answer:
$ "mail e-mail @domain.com"
Subject:
Type in the Body "the message " that you want to send

press a Dott (.) when you are done.

Cc: "Leave it blank "


you can also put some one on the Cc list too..


Question: How can you create exactly 1MB sized file from command line ?

Answer :

$ dd if=/dev/zero of=output.file bs=1024 count=1024


Question: How can you find the largest file in a directory structure ?

Answer :
$ find /home/ -printf "%s:%p\n"|sort -k1n|tail -1

This will get you the largest sized file from the directory structure.

Question: How can you check what shell are you currently using

Answer:
$ echo $SHELL

or

$ ps | grep `echo $$` | awk '{print $4}'

Booting Linux from Serial Console - Without VGA

Perform the following steps and reboot the machine :

STEP 1 :

$ vi /boot/grub/grub.conf

serial --unit=0 --speed=9600
terminal --timeout=10 serial console

console=tty0 console=ttyS0,9600


here is a sample how your file should look like -

--------------------------------------Sample-------------------------------------------
# grub.conf generated by anaconda
#
# Note that you do not have to rerun grub after making changes to this file
# NOTICE: You have a /boot partition. This means that
# all kernel and initrd paths are relative to /boot/, eg.
# root (hd0,0)
# kernel /vmlinuz-version ro root=/dev/VolGroup00/LogVol00
# initrd /initrd-version.img
#boot=/dev/sda
default=0
timeout=5
serial --unit=0 --speed=9600
terminal --timeout=5 serial console
title Fedora (2.6.25-14.fc9.i686)
root (hd0,0)
kernel /vmlinuz-2.6.25-14.fc9.i686 ro root=UUID=b1f4e87a-85cf-491d-9f96-a9409864680e console=tty0 console=ttyS0,9600
initrd /initrd-2.6.25-14.fc9.i686.img
-----------------------------------------------------------------------------------------------
STEP 2 :

$ vi /etc/inittab

s0:2345:respawn:/sbin/agetty ttyS0 115200,9600 linux


after rebooting the machine - it should come up on serial console and not on VGA

Note: make sure that your BIOS is set on the same settings..