Tuesday, February 14, 2012

RedHat /CentOS Tapes MT command

Working with "mt" Commands: reading and writing to tape.

    The following assumes the tape device is "/dev/st0"

    STEP 1 ( rewind the tape)

         # mt -f /dev/nst0 rewind

    STEP 2 (check to see if you are at block 0)

         # mt -f /dev/nst0 tell
           At block 0.

    STEP 3 (Backup "tar compress"  directories "today"  and "etc")

         # tar -czf /dev/nst0 today  etc

    STEP 4 (Check to see what block you are at)

          # mt -f /dev/nst0 tell

      You should get something like block 2 at this point.

    STEP 5 (Rewind the tape)

          # mt -f /dev/nst0 rewind

    STEP 6 (List the files)

          # tar -tzf /dev/nst0
    STEP 7 (Restore directory "one"  into directory "junk").  Note, you
         have to first rewind the tape, since the last operation moved
         ahead 2 blocks. Check this with "mt -f /dev/nst0".

          # cd junk
          # mt -f /dev/nst0 rewind
          # mt -f /dev/nst0 tell
             At block 0.
          # tar -xzf /dev/nst0 today

    STEP 8 (Next, take a look to see what block the tape is at)

          # mt -f /dev/nst0 tell
             At block 2.

    STEP 9 (Now backup directories three  and four)

          # tar -czf /dev/nst0 kd6w2 kd6mtf

      After backing up the files, the tape should be past block 2.
      Check this.

          # mt -f /dev/nst0 tell
            At block 4.

         Currently the following exist:

               At block 1:

               At block 2:
                 At block 4:
                   (* This is empty *)

    A few notes. You can set the blocking factor and a label
    with tar. 

     $ tar --label="temp label" --create  --blocking-factor=128 --file=/dev/nst0 Notes

    But note if you try to read it with the default, incorrect blocking
    factor, then, you will get the following error:

       $ tar -t   --file=/dev/nst0
       tar: /dev/nst0: Cannot read: Cannot allocate memory
       tar: At beginning of tape, quitting now
       tar: Error is not recoverable: exiting now

    However this is easily fixed with the correct blocking factor

        $ mt -f /dev/nst0 rewind
        $ tar -t --blocking-factor=128 --file=/dev/nst0
        workingdir testarea

    Take advantage of the label command.

        $ MYCOMMENTS="tape"
        $ tar --label="$(date +%F)"+"${MYCOMMENTS}"

    Writing to tape on a remote computer

        $ tar cvzf - ./tmp | ssh -l rajat '(mt -f /dev/nst0 rewind; dd of=/dev/st0 )'

    Restoring the contents from tape on a remote computer

        $ ssh -l rajat '(mt -f /dev/nst0 rewind; dd if=/dev/st0  )'|tar xzf -

    Getting data off of tape with dd command with odd blocking factor. Just set ibs very high

        $ mt -f /dev/nst0 rewind
        $ tar --label="Contenets of Notes" --create  --blocking-factor=128 --file=/dev/nst0 Notes
        $ mt -f /dev/nst0 rewind
        $ dd ibs=1048576 if=/dev/st0 of=notes.tar

    The above will probably work with ibs=64k as well

Monday, February 6, 2012

DNS configuration on CentOS /RedHat 6.2

Step 1

 Step 2
# vi /etc/hosts
# vi /etc/sysconfig/network

Step 4
#vi /etc/resolv.conf
Step 5
#service network restart

Step 6
#yum install bind* -y

Step 7
#vi /etc/named.conf
 Step 8
#vi /etc/named.rfc1912
Step 9
#cd /var/named/
#cp named.localhost forward.zone
#cp named.loopback reverse.zone

Step 10
# vi forward.zone 

Step 11
#vi reverse.zone
Step 12
# dig dns.mydns-setup.com

Thursday, February 2, 2012

Server’s Serial Number from command line – RedHat/CentOS

To get service/serial number from command in linux run command below. The first result is the service tag which usually in alphanumeric.

[server@dev-test ~] # dmidecode | egrep -i “serial|product”
output example:
Product Name: PowerEdge R710
Serial Number: 378CDE1
Product Name: 0DCR13
Serial Number: ..ABC980CDE4545XYZ.
Serial Number: AB66X66
Serial Number: Not Specified
Serial Number: Not Specified
Port Type: Serial Port 11204A Compatible

Wednesday, February 1, 2012

Postfix Mail Server on RedHat 6 /CentOS 6

In this setup:
IP address of server =
Hostname = mail
Domain Name = yeswedeal.com
Full Computer name (FQDN) = mail.yeswedeal.com

Note: Make sure DNS Server is properly configured.

Install Required package:
yum install postfix dovecot squirrelmail http  -y

# vim  /etc/postfix/main.cf

inet_interface   =   all
# inet_interface   =  localhost
mydestination =  $myhostname,  localhost.$mydomain, localhost,  $mydomain
home_mailbox =  Maildir/

vim  /etc/dovecot.conf
protocols  =  imap  imaps  pop3  pop3s
mail_location  = maildir:~/Maildir
pop3_uidl_format  =  %09Xu%09Xv
imap_client_workarounds = outlook-idle  delay-newmail  netscape-eoh
pop3_client_workarounds = outlook-no-nuls    oe-ns-eoh

vim  /etc/squirrelmail/config.php
$domain                       = ‘yeswedeal.com’;
$imapServerAddress    = ‘’;
$smtpServerAddress    = ‘’;
$default_folder_prefix   = ‘Maildir/’;

service  postfix  restart
service   dovecot   restart
service httpd  restart