Tuesday, May 31, 2011

How to add SCSI disk on RHEL 5 in VMWare


1)    Once Newly created LUN is presented to the RHEL5 server, run the c  ommand to scan the SCSI bus:
# echo "- - -" >/sys/class/scsi_host/host#/scan
The “- – -” is used for Bus Channel , for Target id and Lun .

2.Check the /var/log/messages file to find the device name , in example the secondary disk device name is sdb
# tail -f /var/log/messages
# fdisk -l /dev/sdb
 
Partitioning
Assuming that you are using fdisk to partition your disk, and that the disk is identified by your system as sdb (the second scsi device), then the following steps should allow you to create the necessary partition:
1.    fdisk /dev/sdb
this will launch the fdisk application. As with all usage of the fdisk command, I must remind you that any changes you make here will remove access to data you have on the
disk you pass as the parameter to this command.
  1. type n for new
  2. type p for primary partition
  3. type 1 for the first partition
  4. accept the defaults for the start and end blocks (ie maximum size)
  5. type t to change the type
  6. enter the code 8e for Linux LVM
  7. enter w to write the changes to disk and exit the application
  8. partprobe
LVM Physical Volume Creation

Whether or not you chose to partition the new disk, you will need to add it to the LVM configuration as a PV. To do this issue the command
pvcreate /dev/sdb1
(or pvcreate /dev/sdb if not partitioned)
If you want to see the before and after effects issue the command pvscan and pvdisplay before and after the pvcreate command shown above

Volume Groups

use of this command depends on whether or not you wish to add the new PV to an existing LVM Volume Group (VG) or a new VG.
To create a new VG: <<<TBD>>>(notes about different VG's in the same LV)<<<TBD>>>
vgcreate VolGroupXX /dev/sdb1
 
(or /dev/sdb if not partitioned), where the parameter VolGroupXX is the usual format for Volume Group named in RedHat, but any name meaningful to you as the system administrator can be used, with the XX being a 2 digit number.
To extend an existing VG:
vgextend VolGroupXX /dev/sdb1
 vgextend vgname  /dev/sdb1
(or /dev/sdb if not partitioned), where the paremeter VolGroupXX is the name of the existing Volume Group.
as above, before and after changes can be observed by running the vgscan and vgdisplay commands before and after the create or extend commands

Logical Volumes

To increase the size of the (or create a new) LVM Logical Volume (LV)
To create a new LV:
lvcreate -l 100%FREE -n /dev/VolGroupXX/LogVolYY /dev/VolGroup00
 
Alternative way
lvcreate -l 6335 -n /dev/vgname/lvname ( Specify the full space)
 
 
where the following parameters are used:
-l 100%FREE - uses all the available space in the Volume Group. Can be changed for -L nn[KMGTPE] for nn Kilo, Mega, Giga, Tera, Peta, Exa bytes -n /dev/VolGroupXX/LogVolYY - this is the name of the Logical Volume expressed as a path. With XX & YY as 2 digit numbers. This naming convention can be changed to suit your own needs but follows the default RedHat configuration. /dev/VolGroupXX - is the VG to take extents from for this LV.
To extend an existing LV:
lvextend -l +100%FREE /dev/VolGroupXX/LogVolYY /dev/sdb1
 
where the following parameters are used:
-l +100%FREE - extends the LV by all the available space in the VG. Can be changed as before for absolute values using -L. The preceding + means extend the current value by this much. Omitting the + means set the value to this much - if you pick the wrong value, you can actually shrink the LV!, which would be fatal if the file system has not yet been resized. /dev/VolGroupXX/LogVolYY - this is the LV you wish to extend /dev/sdb1 - this is teh PV you wish to use to extend the LV.

mkfs.ext3 /dev/vgname/lvname
Mount the partition wherever you want to map it.
mount /dev/vgname/lvname /path/tomap
Add it in fstab entries for permanent Access.



3 comments:

  1. Great article. I followed all your steps on RHEL6 and I can see the disk space added to file system when doing a lvdisplay command. However when I go to the drive in the GUI>Properties I do not see the additional space.

    Also got lost on the vary part your were talking about. I'm not sure what the following is or if it's necessary? Any clarification on that would be great.

    mkfs.ext3 /dev/vgname/lvname
    Mount the partition wherever you want to map it.
    mount /dev/vgname/lvname /path/tomap
    Add it in fstab entries for permanent Access

    ReplyDelete