Monday, December 31, 2012

Lvm setup

What’s LVM? Why using Linux Logical Volume Manager or LVM? Well, these questions are not the scope here. But in brief, the most attractive feature of Logical Volume Manager is to make disk management easier in Linux!

Basically, LVM allows users to dynamically extend or shrink Linux “partition” or file system in online mode! The LVM can resize volume groups (VG) online by adding new physical volumes (PV) or rejecting those existing PVs attached to VG.

A visualized concept diagram of the Linux Logical Volume Manager or LVM.
A visualized concept diagram of the Linux Logical Volume Manager or LVM

In this 3-minutes Linux LVM guide, let’s assume that

  • The LVM is not currently configured or in used. Having say that, this is the LVM tutorial if you’re going to setup LVM from the ground up on a production Linux server with a new SATA / SCSI hard disk.
     
  • Without a luxury server hardware, I tested this LVM tutorial on PC with the secondary hard disk dedicated for LVM setup. So, the Linux dev file of secondary IDE hard disk will be /dev/hdb (or /dev/sdb for SCSI hard disk).
     
  • This guide is fully tested in Red Hat Enterprise Linux 4 with Logical Volume Manager 2 (LVM2) run-time environment (LVM version 2.00.31 2004-12-12, Library version 1.00.19-ioctl 2004-07-03, Driver version 4.1.0)!

How to setup Linux LVM in 3 minutes at command line?
  1. Login with root user ID and try to avoid using sudo command for simplicity reason.
     
  2. Using the whole secondary hard disk for LVM partition:
    fdisk /dev/hdb

    At the Linux fdisk command prompt,
    1. press n to create a new disk partition,
    2. press p to create a primary disk partition,
    3. press 1 to denote it as 1st disk partition,
    4. press ENTER twice to accept the default of 1st and last cylinder – to convert the whole secondary hard disk to a single disk partition,
    5. press t (will automatically select the only partition – partition 1) to change the default Linux partition type (0×83) to LVM partition type (0x8e),
    6. press L to list all the currently supported partition type,
    7. press 8e (as per the L listing) to change partition 1 to 8e, i.e. Linux LVM partition type,
    8. press p to display the secondary hard disk partition setup. Please take note that the first partition is denoted as /dev/hdb1 in Linux,
    9. press w to write the partition table and exit fdisk upon completion.

     
  3. Next, this LVM command will create a LVM physical volume (PV) on a regular hard disk or partition:
    pvcreate /dev/hdb1
     
  4. Now, another LVM command to create a LVM volume group (VG) called vg0 with a physical extent size (PE size) of 16MB:
    vgcreate -s 16M vg0 /dev/hdb1

    Be properly planning ahead of PE size before creating a volume group with vgcreate -s option!
     
  5. Create a 400MB logical volume (LV) called lvol0 on volume group vg0:
    lvcreate -L 400M -n lvol0 vg0

    This lvcreate command will create a softlink /dev/vg0/lvol0 point to a correspondence block device file called /dev/mapper/vg0-lvol0.
     
  6. The Linux LVM setup is almost done. Now is the time to format logical volume lvol0 to create a Red Hat Linux supported file system, i.e. EXT3 file system, with 1% reserved block count:
    mkfs -t ext3 -m 1 -v /dev/vg0/lvol0
     
  7. Create a mount point before mounting the new EXT3 file system:
    mkdir /mnt/vfs
     
  8. The last step of this LVM tutorial – mount the new EXT3 file system created on logical volume lvol0 of LVM to /mnt/vfs mount point:
    mount -t ext3 /dev/vg0/lvol0 /mnt/vfs

To confirm the LVM setup has been completed successfully, the df -h command should display these similar message:

/dev/mapper/vg0-lvol0 388M 11M 374M 3% /mnt/vfs

Some of the useful LVM commands reference:
vgdisplay vg0
 
To check or display volume group setting, such as physical size (PE Size), volume group name (VG name), maximum logical volumes (Max LV), maximum physical volume (Max PV), etc.
 
pvscan
 
To check or list all physical volumes (PV) created for volume group (VG) in the current system.
 
vgextend
 
To dynamically adding more physical volume (PV), i.e. through new hard disk or disk partition, to an existing volume group (VG) in online mode. You’ll have to manually execute vgextend after pvcreate command that create LVM physical volume (PV).

Linux file system without using partition DIRECTLY

How Can  we create a Linux file system without using partition DIRECTLY – sort of file system within file system management?

The answer is certainly YES we can do !

With a loopback device in Linux (a feature that’s not natively available in Windows Vista and its predecessors) one can easily create a Linux loopback file system on a regular disk file, and not directly using a disk partition!

How to create a Linux loopback file system with a regular disk file?
To complete this Linux tricks, you need to login with a root user ID for all the steps given below

  1. Type dd if=/dev/zero of=/virtualfs bs=1024 count=30720 to create a 30MB disk file (zero-filled) called virtualfs in the root (/) directory
     
  2. Type losetup /dev/loop0 to confirm that the current system is not using any loopback devices. Replace /dev/loop0 with /dev/loop1, /dev/loop2, etc, until a free Linux loopback device is found. In this case, let’s assume that /dev/loop0 is free for usage
     
  3. Tpye losetup /dev/loop0 /virtualfs to attach the first Linux loopback device (/dev/loop0) with regular disk file (/virtualfs) created in step 1
     
  4. Type echo $? to confirm the previous step is completed successfully without error – a zero will be returned to indicate success. Alternative, type losetup /dev/loop0 to confirm
     
  5. Type mkfs -t ext3 -m 1 -v /dev/loop0 to create a Linux EXT3 file system with 1% reserved block count on the loopback device that’s currently associated with a regular disk file. Hence, we are creating a file system within file system, or creating a file system (mkfs) without using a disk partition directly
     
  6. Type mkdir /mnt/vfs to create a directory (as mount point) in /mnt
     
  7. Type mount -t ext3 /dev/loop0 /mnt/vfs to mount the loopback device (regular disk file) to /mnt/vfs as a “regular” Linux EXT3 file system! Now, all the Linux file system-related commands can be act on this unusual Linux file system. For example, you can type df -h to confirm its “disk usage”, type tune2fs -l /dev/loop0 to print its file system settings, create / remove files or directories, etc.
     
  8. To un-mount the loopback file system, type umount /mnt/vfs follow with losetup -d /dev/loop0 to effectively remove the loopback file system and release loopback device subsequently.

How to install VNC in Linux

VNC server works similar to Telnet or SSH daemon, except that it allows VNC clients running on diverse OS platforms to remotely access Linux Desktop Manager of the server itself, rather than the TTY text-based console!

  1. Locate the vnc-server-4.0-8.1.rpm package from the Red Hat Linux installation CD or download the latest free version of VNC server from Real VNC.
     
  2. Install the rpm package of VNC server:
    rpm -Uvh vnc-server-4.0-8.1.rpm
     
  3. VNC server is using different set of login authentication than the Linux /etc/passwd. Meaning that, you have to create VNC login password for individual Linux login accounts who are granted remote access with VNC client.
  4. Run the command 'vncserver -geometry 1024x768' - if you know how to tweak this command then feel free. This command will give you a basic VNC server 
    5.) Note the number that it prints to console after you supply a password to use - example output:

    [15:23:10][Siva@Siva-pc:~]$ vncserver -geometry 1024x768

    You will require a password to access your desktops.

    Password:
    Verify:
    xauth:  creating new authority file /home/siva/.Xauthority
    xauth: (stdin):1:  bad display name "xxxxxxx:2" in "add" command

    New 'xxxxxxxxxxxxxxxxxxxxxxx:2 (Siva)' desktop is xxxxxxxxxxxxx:2

    Creating default startup script /home/siva/.vnc/xstartup
    Starting applications specified in /home/siva/.vnc/xstartup
    Log file is /home/siva/.vnc/xxxxxxxxxxxxxxx:2.log


Sunday, December 30, 2012

How add new/otherJava Versions in linux

 just download the java( tar.gz files) which you want  install in linux

extract that  for example:

I have downloaded the Jdk1.7.tar.gz for 64 bit,placed on the opt/local

follow:

ln -s jdk1.7.0 newjava

then edit the  profile file and add the following linesat bottom

vi /etc/profile

export JAVA_HOME=/opt/local/newjava
export PATH=$PATH:$JAVA_HOME/bin
export CLASSPATH=.:$JAVA_HOME/jre/lib:$JAVA_HOME/lib:$JAVA_HOME/lib/tools.jar