Showing posts with label ESX. Show all posts
Showing posts with label ESX. Show all posts

Find System Specs in Terminal

I was presented with the job of "specing" out our ESX servers and documenting my findings. I figured the easiest way to do that would be to SSH into the box and get the specs that way. I stumbled up a site that gave a lot of useful commands. Here are the commands I used:

Graphics Card
lspci | grep VGA - dislpays graphic card model

Ethernet
lspci | grep Ethernet - displays the ethernet card model / controllers
ifconfig [interface] - displays IP address, MAC, and various other information

Kernel and System Info

cat /etc/issue - current distrobution and kernel version
uname -a - kernel information

Processor
cat /proc/cpuinfo - displays processors, speed, flags, and various other information
top (then press C) - realtime processes information by CPU usage

Memory
cat /proc/meminfo - displays RAM, swap, and amount being used
free -m - displays RAM and swap information in an easier to read format
top (then press M) - displays realtime processes by RAM usage

Hard Drive
df -h - displays total space, mount points, free space, percentages, and various other information
fdisk -l - displays all attached drives and their ID's along with block information

Various
uptime - displays the system uptime
w - displays current logged in users and activity

New commands that I have used frequently the past month...

On my never ending Linux/Unix/Windows knowledge quest, I have learned a few basic commands that have just been really helpful and that I have used very often in the past month while troubleshooting random problems.

Linux
smbmount - mount smb shares
Been in a few tight squeezes with some data I needed off a machine, but my only available storage option is a NAS.
  • smbmount //ip/share /mnt/mountpoint -o username=domain\\user,password=pass
For me this would look like:
  • smbmount //192.168.1.10/Backup /mnt/nas -o username=user,password=password
df - shows disk info (usage, mount point, free space)
The
-a switch displays all filesystems, the -T switch displays the FS type, and the -h switch displys the results in "human readable" formats (such as MB and GB)
  • df -a -h -T
du - shows size of files and folders
The -c switch gives a total of the size of all files in the directory, the -h switch lists size in a human readable format, and the -s switch outputs only the size of the directory, not the files within (it is pointless to use the -c switch with the -s switch unless you really enjoy doing so. Also without the -s switch, the output will be of every file and folder in a directory, which could be very verbose)
  • du -c -h /mnt/Backup
  • du -h -s /mnt/Backup
Unix/Mac
Here is how to make a release renew script to make quicken things up a bit:
In a terminal window, type:
  • nano /usr/bin/rr
Which will open a blank page called rr. Now add:
  • #!/bin/bash
  • echo "Now releasing your IP"
  • sudo ipconfig set int BOOTP
  • sleep 5
  • echo "Renewing your IP"
  • sudo ipconfig set int DHCP
  • echo "Done!"
Where int is the specified interface. CTRL+O to write the file then CTRL-X to exit.
Now to make the file executable enter:
  • sudo chmod 775 /usr/bin/rr
That is it...now just enter rr to release and renew your ip.

Windows
I have also been using Windows to mount network shares through command prompt.
  • net use
  • net use a-z: \\ip\share /USER:domain\user
  • net use /DELETE a-z:
  • net use /DELETE *
The first command will display all mapped network shares.
The second command will map a share and use the logon credentials of domain\user, and might prompt you for your password (a-z is the drive letter for the share to be mapped to, you must use a drive letter not currently used).
The third command will delete a specified mapped drive (again, you must specify a drive letter for a-z).
The fourth command will delete all mapped drives.


These are all simple commands, but very useful for me day to day.


Installing BT3 in VMware *UPDATED*

There are a couple of ways to run BT3 in VMware, but when it comes to down to speed and function ability, you should really just install it. *NOTE: Now you can just download a preconfigured VM with an early version of VMWare tools installed. Just download it and when first booting up the VM, select the option "I copied it". Here is a link for the download. The installation process is rather easy. Just make a new virtual machine, select all your settings, and then just format your virtual HDD to ext2 and install.

Here are the steps:
  • Create a new virtual machine.
    • File > New > Virtual Machine
    • Click Next > Typical > Linux (select "Other Linux 2.6 x kernel")
    • Name it what you want and select the storage location of the VM
    • Choose "Use bridged networking" if you want the VM to look like an actual device on your LAN
    • Then select the size of your virtual HDD, and uncheck "allocate disk space now"
    • Click finish
  • Add a USB device to your VM
    • This is real simple to do, and very useful to have done. Select your VM and select "Edit this virtual machine".
    • Under the Hardware tab select "Add".
    • Then select USB controller.
  • Boot into the VM with the BT3 CD in the cd drive.
  • Select Boot into KDE (default selection)
  • Then once BT has booted, open Konsole
  • Prepare the disk for formatting
    • Type fdisk -l
    • See your HD, it should be /dev/sda
    • Assuming it is /dev/sda, enter fdisk /dev/sda
    • Enter n to create a new partition
    • Then p to make it the primary partition
    • Then 1 to assign it as the first partition
    • Then press enter to accept the default first cylinder
    • Then enter again to accept the default last cylinder
    • Finally enter w to write the changes
  • Now format the disk in ext2 format
    • mke2fs /dev/sda1
  • Once the disk is properly formatted, make a mount directory for the hard drive.
    • mkdir /mnt/sda1
    • mount /dev/sda1 /mnt/sda1
    • mount
  • Now you should see that device sda1 is mounted at /mnt/sda1 and is formatted in ext2
  • Install Backtrack
    • K > Backtrack > Backtrack Installer
    • Keep all defaults except change "Installation method" to "Real" and uncheck "Restore Original MBR After LILO".
    • Click install
  • After the installation is finished, reboot the VM without the CD inserted.
After the installation of Backtrack, it might be a good idea to install VMware tools. I am currently writing and figuring out the steps to do so. It will hopefully be up in a few days.


Changing IP configurations and enabling SSH in ESX

A few simple commands to help troubleshoot ESX connections.
NOTE: The commands listed must be executed as root. This guide assumes you are logged in as root and are locally connected to the ESX console.
To change the IP for vswif0 change directory to /usr/sbin/

  • cd /usr/sbin

Then delete the old vswif0 interface:

  • esxcfg-vswif -d vswif0

Now create a new vswif0 interface with the correct IP settings:

  • esxcfg-vswif -a vswif0 -p Service\ Console -i x.x.x.x -n x.x.x.x -b x.x.x.x
  • -a (Adds an interface)
  • -p (Sets the portgroup name of the int)
  • -i (IP of the vswif int, ex. 192.168.1.100)
  • -n (Netmask, ex. 255.255.255.0)
  • -b (Broadcast, ex. 192.168.1.255)

Now to verify the changes have been made type:

  • esxcfg-vswif -l

That will list all vswif interfaces and show the configurations.
To change your default gateway (extends beyond just the vswif interface):

  • nano /etc/sysconfig/network

Here you can change the hostname of the server and the default gateway. To change the gateway, just type in the IP of your gateway where it reads GATEWAY=:

  • GATEWAY=x.x.x.x

Now CTRL-O to write the file then press enter. Then to exit press CTRL-X.
Now that the IP configurations are correct, make sure you can ping the server.

To SSH into your ESX server, you only need to modify one config file. SSH is enabled by default, telnet is not (for security reasons).

  • nano /etc/ssh/sshd_config

Find the line that reads PermitRootLogin and change the no to yes.
Now restart the service and try remoting in.

  • service sshd restart

I use Putty to SSH into ESX, which can be downloaded here.