Showing posts with label Linux. Show all posts
Showing posts with label Linux. Show all posts

Tuesday, September 24, 2013

Linux /etc/fstab explanation

A simple /etc/fstab, using kernel name descriptors:

/etc/fstab
# <file system>        <dir>         <type>    <options>             <dump> <pass>
/dev/sda1 / ext4 defaults,noatime 0 1
/dev/sda2 none swap defaults 0 0
/dev/sda3 /home ext4 defaults,noatime 0 2

Field definitions


The /etc/fstab file contains the following fields separated by a space or tab:

 <file system>        <dir>         <type>    <options>             <dump> <pass>


  • <file system> - the partition or storage device to be mounted.
  • <dir> - the mountpoint where <file system> is mounted to.
  • <type> - the file system type of the partition or storage device to be mounted. Many different file systems are supported: ext2, ext3, ext4, btrfs, reiserfs, xfs, jfs, smbfs, iso9660, vfat, ntfs, swap and auto. The auto type lets the mount command guess what type of file system is used. This is useful for optical media (CD/DVD).
  • <options> - mount options of the filesystem to be used. Note that some mount options are filesystem specific. Some of the most common options are:




  • auto - Mount automatically at boot, or when the command mount -a is issued.
  • noauto - Mount only when you tell it to.
  • exec - Allow execution of binaries on the filesystem.
  • noexec - Disallow execution of binaries on the filesystem.
  • ro - Mount the filesystem read-only.
  • rw - Mount the filesystem read-write.
  • user - Allow any user to mount the filesystem. This automatically implies noexec, nosuid, nodev, unless overridden.
  • users - Allow any user in the users group to mount the filesystem.
  • nouser - Allow only root to mount the filesystem.
  • owner - Allow the owner of device to mount.
  • sync - I/O should be done synchronously.
  • async - I/O should be done asynchronously.
  • dev - Interpret block special devices on the filesystem.
  • nodev - Don't interpret block special devices on the filesystem.
  • suid - Allow the operation of suid, and sgid bits. They are mostly used to allow users on a computer system to execute binary executables with temporarily elevated privileges in order to perform a specific task.
  • nosuid - Block the operation of suid, and sgid bits.
  • noatime - Don't update inode access times on the filesystem. Can help performance (see atime options).
  • nodiratime - Do not update directory inode access times on the filesystem. Can help performance (see atime options).
  • relatime - Update inode access times relative to modify or change time. Access time is only updated if the previous access time was earlier than the current modify or change time. (Similar to noatime, but doesn't break mutt or other applications that need to know if a file has been read since the last time it was modified.) Can help performance (see atime options).
  • discard - Issue TRIM commands to the underlying block device when blocks are freed. Recommended to use if the filesystem is located on an SSD.
  • flush - The vfat option to flush data more often, thus making copy dialogs or progress bars to stay up until all data is written.
  • nofail - Mount device when present but ignore if absent. This prevents errors being reported at boot for removable media.
  • defaults - the default mount options for the filesystem to be used. The default options for ext4 are: rw, suid, dev, exec, auto, nouser, async.


  • <dump> - used by the dump utility to decide when to make a backup. Dump checks the entry and uses the number to decide if a file system should be backed up. Possible entries are 0 and 1. If 0, dump will ignore the file system; if 1, dump will make a backup. Most users will not have dump installed, so they should put 0 for the <dump> entry.


  • <pass> - used by fsck to decide which order filesystems are to be checked. Possible entries are 0, 1 and 2. The root file system should have the highest priority 1 (unless its type is btrfs, in which case this field should be 0) - all other file systems you want to have checked should have a 2. File systems with a value 0 will not be checked by the fsck utility.

Ref:

Wednesday, September 4, 2013

Enable VNC on Oracle Linux

Change last line of /root/.vnc/xstartup file to “gnome-session &” and restart server

After restart type #vncserver

[root@oracleap1 ~]# cat /root/.vnc/xstartup
#!/bin/sh

# Uncomment the following two lines for normal desktop:
# unset SESSION_MANAGER
# exec /etc/X11/xinit/xinitrc

[ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup
[ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources
xsetroot -solid grey
vncconfig -iconic &
xterm -geometry 80x24+10+10 -ls -title "$VNCDESKTOP Desktop" &
gnome-session &

#if test -z "$DBUS_SESSION_BUS_ADDRESS" ; then
#       eval `dbus-launch --sh-syntax .exit-with-session`
#       echo "D-BUS per-session daemon address is: \
#       $DBUS_SESSION_BUS_ADDRESS"
#fi
gnome-session & 

Install HP SPP on Linux - HP Blade Server

Copy HP SPP ISO image to Linux using FTP

Mount ISO image  #mount -o loop -t iso9660 file_name.iso /mnt

Browse to /mnt/hp/swpackages and run “hpsum”

Monday, August 12, 2013

Linux NIC Teaming (Bonding) Options Explained

mode=0 (balance-rr)
Round-robin policy: Transmit packets in sequential order from the first available slave through the last. This mode provides load balancing and fault tolerance.
mode=1 (active-backup)
Active-backup policy: Only one slave in the bond is active. A different slave becomes active if, and only if, the active slave fails. The bond's MAC address is externally visible on only one port (network adapter) to avoid confusing the switch. This mode provides fault tolerance. The primary option affects the behavior of this mode.
mode=2 (balance-xor)
XOR policy: Transmit based on [(source MAC address XOR'd with destination MAC address) modulo slave count]. This selects the same slave for each destination MAC address. This mode provides load balancing and fault tolerance.
mode=3 (broadcast)
Broadcast policy: transmits everything on all slave interfaces. This mode provides fault tolerance.
mode=4 (802.3ad)
IEEE 802.3ad Dynamic link aggregation. Creates aggregation groups that share the same speed and duplex settings. Utilizes all slaves in the active aggregator according to the 802.3ad specification.

	Pre-requisites:
1. Ethtool support in the base drivers for retrieving
the speed and duplex of each slave.
2. A switch that supports IEEE 802.3ad Dynamic link
aggregation.
Most switches will require some type of configuration
to enable 802.3ad mode.
mode=5 (balance-tlb)
Adaptive transmit load balancing: channel bonding that does not require any special switch support. The outgoing traffic is distributed according to the current load (computed relative to the speed) on each slave. Incoming traffic is received by the current slave. If the receiving slave fails, another slave takes over the MAC address of the failed receiving slave.
	Prerequisite:
Ethtool support in the base drivers for retrieving the
speed of each slave.
mode=6 (balance-alb)
Adaptive load balancing: includes balance-tlb plus receive load balancing (rlb) for IPV4 traffic, and does not require any special switch support. The receive load balancing is achieved by ARP negotiation. The bonding driver intercepts the ARP Replies sent by the local system on their way out and overwrites the source hardware address with the unique hardware address of one of the slaves in the bond such that different peers use different hardware addresses for the server.
The most used are the first four mode types...
Also you can use multiple bond interface but for that you must load the bonding module as many as you need.
Presuming that you want two bond interface you must configure the /etc/modules.conf as follow:
	alias bond0 bonding
options bond0 -o bond0 mode=0 miimon=100
alias bond1 bonding
options bond1 -o bond1 mode=1 miimon=100
Notes:

  • To restore your slaves MAC addresses, you need to detach them from the bond (`ifenslave -d bond0 eth0'). The bonding driver will then restore the MAC addresses that the slaves had before they were enslaved.
  • The bond MAC address will be the taken from its first slave device.
  • Promiscous mode: According to your bond type, when you put the bond interface in the promiscous mode it will propogates the setting to the slave devices as follow:

    • for mode=0,2,3 and 4 the promiscuous mode setting is propogated to all slaves.
    • for mode=1,5 and 6 the promiscuous mode setting is propogated only to the active slave.
      For balance-tlb mode the active slave is the slave currently receiving inbound traffic, for balance-alb mode the active slave is the slave used as a "primary." and for the active-backup, balance-tlb and balance-alb modes, when the active slave changes (e.g., due to a link failure), the promiscuous setting will be propogated to the new active slave.

Ref:

Saturday, November 10, 2012

VMware/Linux-Difference between init 6 and reboot commands

Here’s an interesting Linux tidbit that not many ESX admins realize.

reboot is not the same as init 6

In Linux, the init 6 command gracefully reboots the system running all the K* shutdown scripts first, before rebooting.  The reboot command does a very quick reboot.  It doesn’t execute any kill scripts, but just unmounts filesystems and restarts the system.  The reboot command is more forceful.

So, should I use reboot or init 6?  – neither!  My advice is to use the shutdown command.  shutdown will do a similar job to init 6, but it has more options and a better default action.  Along with kicking off an init 6, the shutdown command will also notify all logged in users (logged in at a tty), notify all processes the system is going down and by default will pause  for a set time before rebooting (giving you the chance to cancel the reboot if you realize that you made a mistake).  Jolly civil.

-

How does this advice apply to VMware ESX servers you ask?  Well I’m not a VMware kernel developer so to be honest I’m not the best person to ask (if you do know murky details, then please let us know in the comments).  However I will say this; I will always use shutdown -r first and foremost.  It’s just a better habit to get into.

Is there a difference on an ESX server? Yes, but as I said I’m entirely sure how it affects the VMkernel processes.  The reason I definitely know – a couple of times I’ve had to use the reboot command to force an unresponsive ESX shutdown -r.

P.S. This also applies to init 0 / halt (i.e. use shutdown -h instead).

***************

Update: Following Andrew’s comments below I’ve done a bit more digging.  He’s correct that the default action of the reboot command has now changed to call the shutdown command.  This upstream change (presumably because its a safer default action as I explained above) is now reflected in a lot of the current distributions, including the Service Console that comes with ESX 4.0.  So if you want to force a reboot you have run reboot -f.

Here’s the section on ESX4 man page explaining the change:

NOTES
Under older sysvinit releases , reboot and halt should never be called directly. From release 2.74 on  halt and reboot invoke shutdown(8) if the system is not in runlevel 0 or 6. This means that  if  halt  or  reboot cannot find out the current runlevel (for example, when /var/run/utmp hasn’t been initial ized correctly) shutdown will be called, which might not be what you want.  Use the -f  flag  if  you want to do a hard halt or reboot.

Does it change my advice?  No.
Firstly, ESX 3.x still uses the old style reboot command and doesn’t link to shutdown (as Greg points out the comments, this change was actually made much earlier on) .  Secondly, if your anything like me you are logging into a mix of unix/linux style command lines on servers, SANs, etc; you don’t want to guess what their version of reboot does. Thirdly, I’d still argue that

shutdown -r +1 “*** reboot for RAM upgrade by Forbes ***”

is still a better habit to get into.

  • It allows other users to finish what they are doing or ask you to postpone things.
  • It let’s you cancel the shutdown if you’ve made a boob (remember that sinking feeling in your stomach the last time you realized you’d just shutdown the wrong server).
  • It writes a message explaining why, so you can track the reboots.

Lastly, if you’ve read this far and survived or re-visited for the update, here is an extra tip for you.  Try this at the command line:

last -x|grep -e shutdown -e reboot

Source:

Find open/active ports on Linux Server

command: #netstat -t -l -n
-t  = List TCP only
-l  = List ports opened as listening end points only
-n = Display numeric port numbers (don’t display service names)

Tuesday, February 7, 2012

Determining IP information for eth0… failed

Bellow commands can be used to troubleshoot this issue.

# dmesg | grep eth0 (displays information about the Ethernet controller card, mac address etc.)

# cat /etc/sysconfig/network (displays the network settings)

# cat /etc/sysconfig/network-scripts/ifcfp-eth0 (displays the network settings)

# ifconfig eth0 down (to down the nic)

# ifconfig eth0 up (to start the nic)

# netstat -rn (display kernel routing IP table)

# service network restart (restart the network settings)

Tuesday, October 25, 2011

Install Fedora 15 using Live CD

To install the operating system to the hard disk. Go to Application >> System Tools and select "Install to Hard Drive".

Thursday, October 6, 2011

Discrepancy in Linux Memory Usage in Top and System Monitor

Linux kernel uses available memory for caching. If needed, it will use 100% of free memory for caching. Cached data is stored for faster retrieval of applications, but can in any time be disposed of in favor of memory for applications. Different apps will report memory usage differently because different people perceive definition of free memory in different ways.



Wednesday, October 5, 2011

Find memory usage in Linux

free command

# free –m

# free -t -m


vmstat command

# vmstat


top command

# top


Meminfo:

# cat /proc/meminfo

Tuesday, October 4, 2011

Linux Command Line History

 1. Display timestamp using HISTTIMEFORMAT

For auditing purpose, it may be beneficial to display the timepstamp along with the command as shown below.

 

# export HISTTIMEFORMAT='%F %T '

# history | more

 

2. Repeat previous command quickly using 4 different methods

Following are the 4 different ways to repeat the last executed command.

    Use the up arrow to view the previous command and press enter to execute it.

    Type !! and press enter from the command line

    Type !-1 and press enter from the command line.

    Press Control+P will display the previous command, press enter to execute it

 

3. Search the history using Control+R

Press Control+R and type the keyword.

 

4. Execute a specific command from history

 

In the following example, If you want to repeat the command #4, you can do !4 as shown below.

 

# history | more

1  service network restart

2  exit

3  id

4  cat /etc/redhat-release

 

# !4

cat /etc/redhat-release

Fedora release 9 (Sulphur)

 

5. Clear all the previous history using option -c

 

# history -c

 

Reference: http://www.thegeekstuff.com/2008/08/15-examples-to-master-linux-command-line-history

Tuesday, September 20, 2011

Command to extract and "untar" a file

This is a two step command to extract and untar the file.
#gunzip "filename".tar.gz
#tar xvf "filename".tar

This is a one step command to extract and untar the file.

#tar zvxf "filename".tar.gz

 

z = Gunzip(uncompress) it before extracting, used on file ending in .tar.gz or .tgz

x = Extract the contents of the TAR file

v = Verbose - display contents as it is tarring or extracting

f =  Filename to follow

Monday, July 11, 2011

Monitoring ESX Storage using "esxtop"

To monitor storage performance per HBA:
  1. Start esxtop by typing esxtop at the command line.
  2. Press d to switch to disk view (HBA mode).
  3. Press f to modify the fields that are displayed.
  4. Press b, c, d, e, h, and j to toggle the fields and press Enter.
  5. Press s, then 2 to alter the update time to every 2 seconds and press Enter.
To monitor storage performance on a per-LUN basis:
  1. Start esxtop by typing esxtop from the command line.
  2. Press u to switch to disk view (LUN mode).
  3. Press f to modify the fields that are displayed.
  4. Press b, c, f, and h to toggle the fields and press Enter.
  5. Press s, then 2 to alter the update time to every 2 seconds and press Enter.
 
To monitor storage performance on a per-virtual machine basis:
  1. Start esxtop by typing esxtop at the command line.
  2. Type v to switch to disk view (virtual machine mode).
  3. Press f to modify the fields that are displayed.
  4. Press b, d, e, h, and j to toggle the fields and press Enter.
  5. Press s, then 2 to alter the update time to every 2 seconds and press Enter.
     

Analyzing esxtop columns

This table lists the relevant columns and a brief description of these values:
ColumnDescription
CMDS/s This is the number of IOPS (Input/Output Operations Per Second) being sent to or coming from the device or virtual machine being monitored
DAVG/cmd This is the average response time in milliseconds per command being sent to the device
KAVG/cmd This is the amount of time the command spends in the VMkernel
GAVG/cmdThis is the response time as it is perceived by the guest operating system. This number is calculated with the formula: DAVG + KAVG = GAVG

Friday, July 8, 2011

Enable screen and scroll-back buffer on PuTTy

Go to the "Features" in settings panel and tick 'Disable switching to alternate terminal screen'



Thursday, July 7, 2011

Fix Ubuntu “Requires Installation of Untrusted Packages” Update Error

The error screen below is what you'll get when you try to update your system via Update  Manager

untrusted_mav

1  On your Ubuntu panel, click on System > Administration > Update Manager.
2. Look for Settings at the bottom left corner of the Update Manager window, click on it.

3. On the Software Sources window, click on the Ubuntu Software tab.
4. Under Downloadable from the Internet, put a check on Source Code.
Ubuntu Update Error

5. Close the window and the changes will be applied.
6. On Update Manager, click on Install Updates.

That should do it and you should now be able to download and install the available updates for your system

Sunday, June 19, 2011

Find Linux Distribution Name and Version

Find what version of Linux you are running:

#cat /etc/*-release

 

The lsb_release command displays certain LSB (Linux Standard Base) and distribution-specific information.

#lsb_release –a

 

Find Out My Kernel Version

#uname –mrs



Wednesday, June 15, 2011

Bonding (Teaming) NICs in Linux

This example assumes you have two interfaces and want to use them in a 'fail-over' setup, where if one cable dies, the kernel will automatically switch to using the other cable.
You need the following files in /etc/sysconfig/network-scripts/ :
ifcfg-eth0
ifcfg-eth1
ifcfg-bond0
 
1: Edit bond0 configuration file:
If ‘ifcfg-bond0’ is not there, create it  "# vi /etc/sysconfig/network-scripts/ifcfg-bond0"
Edit bond0 using VI
DEVICE=bond0
IPADDR=192.168.1.20
NETWORK=192.168.1.0
NETMASK=255.255.255.0
USERCTL=no
BOOTPROTO=none
ONBOOT=yes
Replace above IP address with your actual IP address. Save file and exit VI.
2: Modify eth0 and eth1 config files:
Open eth0 and eth1 files VI text editor and make sure file read as follows
ifcfg-eth0 ‘  file:
DEVICE=eth0
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
 
ifcfg-eth0 ‘ file:
DEVICE=eth1
USERCTL=no
ONBOOT=yes
MASTER=bond0
SLAVE=yes
BOOTPROTO=none
Save files and exit VI.
 
3: Load bond driver/module
Make sure bonding module is loaded when the channel-bonding interface (bond0) is brought up.
Open /etc/modprobe.conf file in VI and append bellow two lines
alias bond0 bonding
options bonding miimon=100 mode=0
Save file and VI
(Linux bonding options explained)
**********************************************************************************
miimon
Specifies the MII link monitoring frequency in milliseconds. This determines how often the link state of each slave is inspected for link failures. A value of zero disables MII link monitoring. A value of 100 is a good starting point.
The use_carrier option, below, affects how the link state is determined. See the High Availability section for additional information. The default value is 0.
mode
Specifies one of the bonding policies. The default is balance-rr (round robin).
 
**********************************************************************************
 
For a complete reference please click here.
4: Test configuration
First, load the bonding module # modprobe bonding and restart networking service

Wednesday, May 11, 2011

Install Symantec Backup Exec Linux Agent on ESX hosts and Linux servers


1)       1)  root@esx4vm_1 agent]# gunzip BEWS_12.5.2213_LINUX-UNIX-MAC-SAP_AGENTS.tar.gz
 2) [root@esx4vm_1 installer]# tar xvf  /home/vmadmin/backupexec/agent/BEWS_12.5.2213_LINUX-UNIX-MAC-SAP_AGENTS.t
3)         [root@esx4vm_1 installer]# ./installrmal
3)        
4)       Enter the system names separated by spaces on which to install RMAL: (esx4vm)192.168.10.10
5)        Checking system communication:
 Checking OS version on 192.168.10.10............. Linux 2.6.18-128.ESX
 Checking system support for 192.168.10.10... Linux 2.6.18-128.ESX supported by RMAL
Initial system check completed successfully.

4)         Press [Return] to continue:
installrmal will install the following RMAL packages on Linux target system: 192.168.10.10
VRTSralus        Symantec Backup Exec Media Agent for Linux Servers
Press [Return] to continue:

5)         Checking system installation requirements:
Checking RMAL installation requirements on Linux target systems: 192.168.10.10
Checking RMAL installation requirements on 192.168.10.10:
    Checking file system space ................ required space is available
Installation requirements checks completed successfully.
Press [Return] to continue:

6)         To display the Remote Agent as a selection in a media server's backup selection tree, and to be able to specify a local network for use between the Remote Agent and a media server, enter the names or IP addresses of the media servers that you want the Remote Agent to communicate with.
        An IP Address: XXX.XXX.XXX.XXX
        A Host Name: COMPUTERNAME
Enter a directory host:192.168.0.10      

7)         Do you want to add another name or address for this agent? [y, n] (n)n

Hostnames and/or IP addresses verification:
        Address: 192.168.0.10
8)         Is this information correct? [y, n] (y)y

9)         To perform backups, you must have a 'beoper' user group. This user group can be created only if you are not using NIS server. Your system will be scanned to detect a NIS server, group and membership.
Press [Return] to continue:
    Checking if system uses NIS server: ............................... No
10)       The installer will now check your system for the 'beoper' user group and root membership.
Press [Return] to continue:

    Checking for 'beoper' user group: ........................... Not Found
    Checking for 'root' user membership in 'beoper' user group: ... Not Found
11)       You can create 'beoper' user group manually or you can choose to have it created automatically.
Do you want installer to create 'beoper' user group? [y, n] (y)y

12)       Do you want installer to create 'beoper' user group? [y, n] (y)y
Do you want to use specific group ID when creating 'beoper' user group? [y, n] (n)n

13)       Do you want to add the 'root' user to 'beoper' user group? [y, n] (y)y

Adding 'root' user to 'beoper' user group: ...................... Done
Press [Return] to continue:

14)       Checking Symantec Backup Exec Remote Media Agent for Linux Servers on 192.168.10.10:
    Checking VRTSralus package .............................. not installed
Press [Return] to continue:

15)       Installing VRTSralus 12.5.2213 on 192.168.10.10
Symantec Backup Exec Remote Media Agent for Linux Servers installation completed successfully.
Press [Return] to continue:

16)       Configuring Symantec Backup Exec Remote Media Agent for Linux Servers:
    Creating configuration files ..................................... Done
Symantec Backup Exec Remote Media Agent for Linux Servers configured successfully.
Press [Return] to continue:

17)       The response file is saved at:
    /var/tmp/vxif/installrmal511104346/installrmal511104346.response
The installrmal log is saved at:
    /var/tmp/vxif/installrmal511104346/installrmal.log

18)       Start the agent using the following command
[root@esx4vm_1 installer]# /etc/init.d/VRTSralus.init start

19)       To stop the agent use the following command
[root@esx4vm_1 installer]#/etc/init.d/VRTSralus.init stop

20)       Configure firewall to allow TCP Port 10000 in and out
            ESX:      [root@esx4vm_1 installer]# esxcfg-firewall --openPort 10000,tcp,in,bkpexecagnt
          [root@esx4vm_1 installer]# esxcfg-firewall --openPort 10000,tcp,out,bkpexecagnt
     Confirm entries are added : [root@esx4vm_1 installer]#iptables –nL |grep 10000
    
     Linux:    # vi /etc/sysconfig/iptables
#-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 10000 -j ACCEPT
            # /etc/init.d/iptables restart



Friday, May 6, 2011

How to change hostname in Linux

1)   Edit file /etc/sysconfig/network using your favourite editor. In my case is VI. So i'll enter  #vi /etc/sysconfig/network

2)   Look for HOSTNAME=xxxxxx

3)   Change the xxxx to the name you wish to set for your computer. (ex: HOSTNAME=abcd.yourdomain.com)

4)   Save the file and restart the xinetd service. Type  #service xinetd restart

5)   Done! You have just changed your hostname in Linux platform


Display the size of file and directory in Linux using DU command

The du command below show the files size in the current directory in MB or K.

[root@linux_1]# du –h

 

Get the total size of current directory

[root@linux_1]# du –s

[root@linux_1]# du –sh

(-s = summarize and -h = human readable format)

 

To get the size of file and directory in current directory

[root@linux_1]# du -sh *

 

Display the size of specific file extension

[root@linux_1]# du -ch *.txt

 

To produce grand total of the directory size

[root@fedora home]# du -csh *