centostricks

Just another WordPress.com site

Hot add scsci Disk in Centos 6.x/5.x without reboot of OS


Steps to Identify a newly added scsi disk in Centos 6.0 without rebooting OS

[root@localhost ~]# ls /sys/class/scsi_host/host
host0/ host1/ host2/
[root@localhost ~]#

This command will identify and hot add the disk running on host 2 , below we can see then as scsi2..

[root@localhost ~]# echo “- – -” > /sys/class/scsi_host/host2/scan

Now displaying the identified disks /dev/sdc, /dev/sdd, /dev/sdb

[root@localhost ~]# fdisk -l |grep sd
Disk /dev/dm-0 doesn’t contain a valid partition table
Disk /dev/dm-1 doesn’t contain a valid partition table
Disk /dev/sdc doesn’t contain a valid partition table
Disk /dev/sdd doesn’t contain a valid partition table
Disk /dev/sdb doesn’t contain a valid partition table
Disk /dev/sda: 14.0 GB, 13958643712 bytes
/dev/sda1 * 1 64 512000 83 Linux
/dev/sda2 64 1698 13118464 8e Linux LVM
Disk /dev/sdc: 1073 MB, 1073741824 bytes
Disk /dev/sdd: 1073 MB, 1073741824 bytes
Disk /dev/sdb: 1073 MB, 1073741824 bytes

[root@localhost ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 02 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 03 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02

current status : there are 2 scsi drives with 1 scsi drive (CDROM) on scsi 1 is the harddrive. Now i have added 1 more scsi drive. We will see what happens

Adding one more disk, but identifying with a different command

Another method used to identify the newly added disk : this command will not alter/overwrite any existing configurations

[root@localhost ~]# echo “scsi add-single-device 2 0 4 0” > /proc/scsi/scsi

When we run with a wrong values, below will be the output. there is no changes or damage. i have not encountered any issues. but not recommended to do so !

[root@localhost ~]# echo “scsi add-single-device 0 0 4 0” > /proc/scsi/scsi
-bash: echo: write error: Invalid argument
[root@localhost ~]# echo “scsi add-single-device 0 4 4 0” > /proc/scsi/scsi
-bash: echo: write error: Invalid argument
[root@localhost ~]# echo “scsi add-single-device 0 3 4 0” > /proc/scsi/scsi
-bash: echo: write error: Invalid argument
[root@localhost ~]# echo “scsi add-single-device 0 2 4 0” > /proc/scsi/scsi
-bash: echo: write error: Invalid argument
[root@localhost ~]# echo “scsi add-single-device 0 1 4 0” > /proc/scsi/scsi
-bash: echo: write error: Invalid argument
[root@localhost ~]# echo “scsi add-single-device 1 0 4 0” > /proc/scsi/scsi
-bash: echo: write error: Invalid argument
[root@localhost ~]# echo “scsi add-single-device 4 0 4 0” > /proc/scsi/scsi
-bash: echo: write error: No such device or address
[root@localhost ~]# echo “scsi add-single-device 3 0 4 0” > /proc/scsi/scsi
-bash: echo: write error: No such device or address

The effect of echo “scsi add-single-device 2 0 4 0” > /proc/scsi/scsi is shown below :

[root@localhost ~]# echo “scsi add-single-device 2 0 4 0” > /proc/scsi/scsi
[root@localhost ~]# cat /proc/scsi/scsi
Attached devices:
Host: scsi1 Channel: 00 Id: 00 Lun: 00
Vendor: NECVMWar Model: VMware IDE CDR10 Rev: 1.00
Type: CD-ROM ANSI SCSI revision: 05
Host: scsi2 Channel: 00 Id: 00 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 01 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 02 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 03 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02
Host: scsi2 Channel: 00 Id: 04 Lun: 00
Vendor: VMware, Model: VMware Virtual S Rev: 1.0
Type: Direct-Access ANSI SCSI revision: 02

We can see that there is a newly identified disk, Please use fdisk or parted to create required partitions ….

Initializing the Newly added disk before creating partitions

Better to use fdisk to create partitions with fdisk(Initializes the Disk) , as this disks are not initialized yet, and will give below errors, if parted is used

[root@localhost ~]# parted -l |grep sd*
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sda: 14.0GB
Sector size (logical/physical): 512B/512B
Partition Table: msdos
Number Start End Size Type File system Flags
Error: /dev/sdb: unrecognised disk label
Error: /dev/sdc: unrecognised disk label
Error: /dev/sdd: unrecognised disk label
Error: /dev/sde: unrecognised disk label

See the below results, parted is not even allowing to create partitions :

[root@localhost ~]# parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) p
Error: /dev/sdc: unrecognised disk label
(parted) u s
(parted) mkpart primary 64 -1s
Error: /dev/sdc: unrecognised disk label
(parted) p
Error: /dev/sdc: unrecognised disk label
(parted)

See the below output. “Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)”

If you are flexible with fdisk, you can go ahead and create partitions and save it.

If you are not flexible with fdisk and good with parted, just use the below steps , don’t create any partitions. just access the device and type ‘w’ later use parted to create partitions

[root@localhost ~]# fdisk /dev/sdc
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0xfa03eeaf.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won’t be recoverable.

Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)

WARNING: DOS-compatible mode is deprecated. It’s strongly recommended to
switch off the mode (command ‘c’) and change display units to
sectors (command ‘u’).

Command (m for help): w
The partition table has been altered!

Calling ioctl() to re-read partition table.
Syncing disks.

Now use parted and create partitions. see the below output, no more errors or warning. you are good to proceed with next steps of creating partitions. Good Luck !!!

[root@localhost ~]# parted /dev/sdc
GNU Parted 2.1
Using /dev/sdc
Welcome to GNU Parted! Type ‘help’ to view a list of commands.
(parted) p
Model: VMware, VMware Virtual S (scsi)
Disk /dev/sdc: 1074MB
Sector size (logical/physical): 512B/512B
Partition Table: msdos

Number Start End Size Type File system Flags

(parted)

***** END****

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: