How to add new SCSI disk in RedHat OS (under VMware)

To add new SCSI device in RedHat operating system we need to do following steps:

1. Scan system looking for new disks:

echo “- – -” > /sys/class/scsi_host/<hostname>/scan

Parameter <hostname> can be obtained using command:

ls /sys/class/scsi_host
host0

Our command will be looking :

echo ‘- – -‘ > /sys/class/scsi_host/host0/scan

 

Then  we can list new disks:

fdisk -l

 

Disk /dev/sda: 10.7 GB, 10737418240 bytes255 heads, 63 sectors/track, 1305 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot      Start         End      Blocks   Id  System

/dev/sda1   *           1          13      104391   83  Linux

/dev/sda2              14        1305    10377990   8e  Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdb doesn’t contain a valid partition table
Disk /dev/sdc: 4294 MB, 4294967296 bytes255 heads, 63 sectors/track, 522 cylinders

Units = cylinders of 16065 * 512 = 8225280 bytes
Disk /dev/sdc doesn’t contain a valid partition table

 

We have got two new disks: /dev/sdb and /dev/sdc.

cat /proc/scsi/scsi
Attached devices:
Host: scsi0 Channel: 00 Id: 00 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 01 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Type:   Direct-Access                    ANSI SCSI revision: 02
Host: scsi0 Channel: 00 Id: 02 Lun: 00
Vendor: VMware   Model: Virtual disk     Rev: 1.0
Type:   Direct-Access                    ANSI SCSI revision: 02

 

2. Create partition table and filesystem on new disks:

To create partitions we will use fdisk command:

fdisk /dev/sdb

Then we can choose : n,p,1,w for create new primary partition on disk /dev/sdb

To create filesystem we will use command mkfs.ext3:

mkfs.ext3 /dev/sdb1

 

mke2fs 1.39 (29-May-2006)
Filesystem label=
OS type: Linux
Block size=4096 (log=2)
Fragment size=4096 (log=2)
524288 inodes, 1048233 blocks
52411 blocks (5.00%) reserved for the super user
First data block=0
Maximum filesystem blocks=1073741824
32 block groups
32768 blocks per group, 32768 fragments per group
16384 inodes per group
Superblock backups stored on blocks:
32768, 98304, 163840, 229376, 294912, 819200, 884736

Writing inode tables: done
Creating journal (16384 blocks): done
Writing superblocks and filesystem accounting information: done

This filesystem will be automatically checked every 28 mounts or
180 days, whichever comes first.  Use tune2fs -c or -i to override.

 

3. Create mount points and modify fstab file:

We are creating folders where new filesystems will be mounted:

 

mkdir /u01

mkdir /oradb

 

then, we are adding following lines to /etc/fstab file :

/dev/sdb1               /u01                    ext3    defaults        1 2
/dev/sdc1               /oradb                  ext3    defaults        1 2

and use command mount to mount new filesystems:

mount -a

We can check if we can see them under os:

df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/VolGroup00-LogVol00
7.7G  5.8G  1.6G  79% /
/dev/sda1              99M   13M   82M  14% /boot
tmpfs                      502M     0  502M   0% /dev/shm
/dev/sdb1             4.0G   73M  3.7G   2% /u01
/dev/sdc1             4.0G   73M  3.7G   2% /oradb

 

To add single device called i.e. /dev/sdb we need to use command:

echo “scsi add-single-device <H> <B> <T> <L>” > /proc/scsi/scsi

where:

H – host
B – bus(channel)
T – target(id)
L – lun number

in our case:

echo “scsi add-single-device 0 0 2 0” > /proc/scsi/scsi

Leave a Response