We are old and small , but still useful!!

We are old and small , but still useful!!

Every time when there  is new pendrive/thumbdrive with larger released in the market, you will buy it for your mp3, movie, porn, iso…..junk files.  It is fun to have small little tiny things with more capacity. End up you will have bunch of pendrive laying around your offices.

I love to reuse the old devices for other purposes. I have few suggestion on for the old pendrive:

  1. Load Linux into pendrive and apply it as rescue disk. Suggest Backtrack 3 on a 1GB pendrive.
  2. Backup device for your Linux and Windows PC

For point number 1 , i have my 1GB pendrive loaded with backtrack3 and Fedora. Backtrack3 is very useful when you need to :

  • Reset windows local administrator password
  • Check volume group data in Live CD mode
  • Copy data from a dead OS(both windows and Linux)
  • many more……


Point number 2 is my favorite part. I have 512GB mounted to my PC as my permanent backup device for my critical documents. You will need:

1.Cygwin installed with rsync

-Cygwin is a powerful opensource developed to simulate *nix environment. You are able to use *nix command in windows and it is powerful.

-rsync is a simple yet powerful script widely used in *nix for sync process.  Please read http://en.wikipedia.org/wiki/Rsync for more info.

2. Simple script(bak.bat) to trigger for backup with Scheduler.

bak.bat content

Scheduled Task in Windows XP

Scheduled Task in Windows XP

@ECHO OFF
rsync -avz –delete /cygdrive/c/’Documents and Settings’/tiwlim/’My Documents’/NCS /cygdrive/x
touch /cygdrive/x/done.flag

Line 1

rsync -avz –delete /cygdrive/c/’Documents and Settings’/tiwlim/’My Documents’/NCS /cygdrive/x

-avz means copy everything from source (including the permission and display the output).

–delete means compare source and destination, the destination must have whatever source is having. EG: if destination has b.txt and source does not has b.txt , b.txt will be deleted in destination.

/cygdrive/c/ is the c drive.

/cygdrive/x is my pendrive mounted to “My Computer” as X drive.

Line 2

touch /cygdrive/x/done.flag

create a done.flag once the rsync is completed.This is to let you know when is the last update.

Most of the time, the document did not consume much space. I have only 512MB pendrive mounted as my backup devices.

15 Apr, 2010  |  Written by TingWei  |  under etc

Yesterday was not a good day, gnome-session was dead in my Linux core machine causes some failure to my apps. My perforce proxy server is upside down,  seems like the hardware is dying soon. As usual, unless the server has death certification, else we will continue to squeeze it….

Trying to google around for SUN OS single mode (without cd) boot up so i can run fsck on root volume. This is the finding i have for SunOS 5.1 i386 after combining all article read.

Run fsck in SunOS 5.1

1. Boot into single mode

reboot — -m milestone=”none”

2. run

fsck -F ufs /dev/rdsk/c0t0d0s0

Result:

** phase 1 – Check Blocks and Sizes
** phase 2 – Check Pathnames
** phase 3 – Check Connectivity
** phase 4 – Check Reference Counts
** phase 5 – Check Cylinder Groups

I am safe, no bad superblock or sector. However, if you are running into trouble like : corrupted super block

newfs -Nv /dev/rdsk/c0t0d0s0

to obtain the block number of Superblock backup’s. Then finally

fsck -F ufs -o -b=32 /dev/rdsk/c0t0d0s0

*When you created new file system, alternate superblock was created as well, we are using this technique to repair bad superblock.

I will need to use smartd to scan the harddisk in SUN. write this on next post later on.

9 Apr, 2010  |  Written by TingWei  |  under Linux

Q: I have a LVM(logical volume) in my Linux, i need to extend the size without offline the logical volume.

A:

You will need to ensure you have spaces in volume group. Assuming the VG name is : VolGroup00.

[root@linux1 data]# vgdisplay
— Volume group —
VG Name               VolGroup00
System ID
Format                lvm2
Metadata Areas        1
Metadata Sequence No  10
VG Access             read/write
VG Status             resizable
MAX LV                0
Cur LV                8
Open LV               8
Max PV                0
Cur PV                1
Act PV                1
VG Size               1.36 TB
PE Size               32.00 MB
Total PE              44703
Alloc PE / Size       28570 / 872.81 GB
Free  PE / Size       16133 / 524.16 GB
VG UUID               d2vwa2-6JHI-lTXJ-0WHg-iXhv-6COc-h01kf6

According to “Free PE/Size” you have 524.16GB left . Then you are good to proceed with the steps.

Lets check the current size of the LV you want to resize

[root@linux1 data]# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-lvdata
296G  191M  281G   1% /data

Lets start increasing the size!

[root@linux1 data]# lvextend -L+20G /dev/VolGroup00/lvdata
Extending logical volume lvdata to 320.00 GB
Logical volume lvdata successfully resized

Then resize it live!

[root@linux1 data]# resize2fs /dev/VolGroup00/lvdata
resize2fs 1.39 (29-May-2006)
Filesystem at /dev/VolGroup00/lvdata is mounted on /data; on-line resizing required
Performing an on-line resize of /dev/VolGroup00/lvdata to 83886080 (4k) blocks.
The filesystem on /dev/VolGroup00/lvdata is now 83886080 blocks long.

The final output you are looking for :)

[root@linux1 data]# df -h .
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-lvdata
315G  195M  299G   1% /data

Easy right? The original guide in Redhat showed “ext2online” but i don’t see it in my /sbin ! Luckily my best friend google told me resize2fs is the new method :) Redhat you should update your documentation!

27 Mar, 2010  |  Written by TingWei  |  under etc

I bought my LG lollipop recently and have been quite excited with the J-phone alike or feel. Bigger screen, Flip, Great animation in Menu and dashboard. With the impression that Jphone can access Email easily, so i decided to enable to email in my phone as well. By referring to Gmail setup here . However, the explanation sucks! It takes me few attempt before i can successfully access to GMAIL.

Incoming Mail (IMAP) Server - requires SSL: imap.gmail.com
Use SSL: Yes
Port: 993
Outgoing Mail (SMTP) Server - requires TLS: smtp.gmail.com (use authentication)
Use Authentication: Yes
Use STARTTLS: Yes (some clients call this SSL)
Port: 465 or 587
Account Name: your full email address (including @gmail.com) Google Apps users, please enter username@your_domain.com
Email Address: your full Gmail email address (username@gmail.com) Google Apps users, please enter username@your_domain.com
Password: your Gmail password

My Setting in Gmail

Title: Gmail

My Name: Tingwei

user name: myemailadd@googlemail.com

password: ****

Email address: myemailadd@googlemail.com

Reply email address: myemailadd@googlemail.com

Outgoing mail server: smtp.googlemail.com

Incoming mail server: imap.googlemail.com

SMTP port number : 465

SMTP TLS/SSL : SSL

Incoming server port : 993

Incoming TSL/SSL: SSL

SMTP authentication: On

SMTP username: cdestiny@googlemail.com

SMTP password: ****

*The rest leave it as default

** If you happen to cancel the synchronization , the rest of the connection will fail for sure. Reboot your Lollipop!

*** Instead of using gmail , apply googlemail . It works like charm, thanks for a comment that i found on a blog!  —> IMPORTANT

Enjoy then!

11 Mar, 2010  |  Written by TingWei  |  under Linux

Situation: You have NIS Master, you need a slave setup in your office.

This tutorial is covering steps for Redhat/CentOS/Fedora 64 bits. It might differ from what you have seen online.

1. Install ypserv in your server

yum install -y  ypserv.x86_64

2. Start the services

service ypserv start

service ypxfrd start

3. Verify the yp is ready

#rpcinfo -u localhost ypserv
program 100004 version 1 ready and waiting
program 100004 version 2 ready and waiting
4. Copy the database fro Master

/usr/lib/yp/ypinit -s master_domain_name

or

/usr/lib64/yp/ypinit -s master_domain_name

5. edit /etc/yp.conf

ensure you have the new slave hostname set is primary

6. Test

ypcat -k passwd | grep userid

7. Never forget to turn on

chkconfig ypserv on

chkconfig ypxfrd on

How to keep the database in sync?

1. Master push , this can be done via master. You can find it here

2.Slave pull from Master.

/usr/lib64/yp/

either one will do:

ypxfr_1perday  ypxfr_1perhour  ypxfr_2perday

Run this at your crontab :)

8 Mar, 2010  |  Written by TingWei  |  under Linux

Your boss came to you and asked for total size of files which has not been accessed for more than 30 days! Assume that you are just checking for 1 directory “/abc” . Here comes the simple command:

find /abc -atime +30 -exec ls -lk ‘{}’ \;  | awk ‘{SUM += $5} END {print SUM} ‘

Explaination:

find /abc -atime +30 -exec ls -lk ‘{}’ \

find command will find /abc and check for accestime which has not been access for 30 days and list it out the result

awk ‘{SUM += $5} END {print SUM} ‘

awk will sum all the result then only print out final figure.

The command is extremely useful especially you have multiple of directory residing in /abc :

/abc/123

/abc/456

/abc/789

Just write a simple script to generate it! I will cover this on next post.

19 Jan, 2010  |  Written by TingWei  |  under NetApp
Comments Off

Recently found my autosupport mail was undelivered.  The config was follow exactly with the working one. So after digging for few days and finally i found the root cause. there is one file *.ems.gz is about 30MB and caused the exchange server to block it. (Thank god 1 of the triggered mail received)

Netapp support had send me the instruction to rotate the log files:

priv set advanced
syslog rotate_syslog
priv set

ta.da……..problem resolved and you are able to receive all autosupport now!

9 Dec, 2009  |  Written by TingWei  |  under Linux

Everybody handling a Unix operating system would very well know what chmod 777 means. That the owner, group and the user of the file is given all permissions (Read, Write and Execute on a particular file). This could otherwise be written as “chmod ugo+rwx “. Meaning that you are giving User, Group and Owner of the file, the rights to Read, Write and Execute the file.

Here comes the rws scenario. Best example that is available for this rws is /usr/bin/passwd command (just issue a “ls -l /usr/bin/passwd”) .

Normally, any user is allowed change HIS password. Meaning he can make an entry or change HIS entry in the /etc/passwd file. But he can never be given ‘WRITE’ permissions on the file because he might end up disturbing other person’s password too. Only a ROOT user is allowed permissions on the /etc/passwd file.

This is where the “rws” comes to picture. When we give “rws” permission to the /usr/bin/passwd command, Unix would assume that the command is executed by the ROOT user. (the user doesnt have permissions on the /etc/passwd file but the root user has). Root user (RWS) permissions could be given on a file as chmod 4700 .

arun@arun-desktop:~/Desktop$ chmod 4700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rws—— 1 arun arun 0 2007-01-17 06:48 hi.txt

If you need to act as a group user of a file and not a normal user when executing a particular command (as against the root user) then user “chmod 2700 ”

arun@arun-desktop:~/Desktop$ chmod 2700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rwx–S— 1 arun arun 0 2007-01-17 06:48 hi.txt

The 4 and 2 in the front of the chmod commands are called as SUID and SGID bits.

What if we put a 1 instead of 4 and 2 (chmod 1700 ).

arun@arun-desktop:~/Desktop$ chmod 1700 hi.txt
arun@arun-desktop:~/Desktop$ ls -l hi.txt
-rwx—–T 1 arun arun 0 2007-01-17 06:48 hi.txt

It shows a “T” in the place of “x” for a normal user. This “T” bit is called as the Sticky bit.

“When the sticky bit is turned on for a directory users can have read and/or write permissions for that directory, but they can only remove or rename files that they own. The sticky bit on a file tells the operating system that the file will be executed frequently. Files like this are kept in swap space even when they aren’t being executed. Although this takes up swap space it greatly reduces the time it takes to execute the program. Some programs such as vi have the sticky bit turned on by default on some Unixes.”

Source: http://beanpicks.wordpress.com/2007/02/03/rwsr-xr-x-unix-file-permission/

13 Nov, 2009  |  Written by TingWei  |  under Linux

Redhat just released RHEL 5.4 with KVM & Xen both supported in this release, so i have downloaded CentOS 5.4 and try to play around with KVM.

My hardware:

Dell M710 with 8 cores of  Nehalem , 72G of RAMs

My OS:

CentOS 5.4 with KVM & Xen installed

My test guest:

Windows 7

The sweet thing:

The bad thingssss:

  • Xen & KVM cannot run in the same time, it is either KVM or Xen
  • No paravirtualization in KVM, only FULL Virtialization, Xen jhas both!
  • Need driver for network in paravirtualzied mode for XP,Vista,Win7
  • No network bridge setup!! Xen do this automatically for us! Network bridge allow your guest os to have their own IP without sharing with the host! I will cover this later on.

Continue Reading ->

Comments Off

Dell has a very good Driver support page until recently they forced the user to use Dell Download Manager which is sucks! If you are XP user, you have no choice but to use Download Manager, but they did not provide Proxy setting in the Download Manager!! Firefox and IE both not working! Shame on you Dell!

Luckily my colleague found a loop hole which is to use Linux’s Firefox to download the driver.

So Dell latest M710 come with Intel Nahelem :) which is the latest toy for us to play with, but i have to install Windows XP 64 bits for the organization needs! Dell does not support windows XP in official, so you have to grab the driver by yourself.

Since the RAID controller is LSI SAS 1068E , just goto
http://www.lsi.com/storage_home/products_home/standard_product_ics/sas_ics/lsisas1068e/index.html?remote=1&locale=EN

and download the installer for Windows XP or whatever OS you can find inside.

Go and google how to install Third Party RAID drive , i am not covering it here.