Sunday, March 25, 2012

Adding SCSI Storage to a Redhat or CentOS without Rebooting



In today's post, we will add the storage we added on the NetApp to the actual machine for usage. 
This storage is coming through the vCenter VMware system (as in the post about adding that storage) and not directly through NFS.


1.  First off log into your Linux box, and SU to root

2.  Then issue a rescan command to the hosts you have:

ls /sys/class/scsi_host

host0 host1 host2



 We will then issue a rescan for all 3:


 echo "- - -" > /sys/class/scsi_host/host0/scan
 echo "- - -" > /sys/class/scsi_host/host1/scan
 echo "- - -" > /sys/class/scsi_host/host2/scan

Then issue a "fdisk -l"


You should see message such as this below:

[root@cent01 ~]# tail /var/log/messages
Mar 26 10:45:56 cent01 kernel: sd 0:0:1:0: [sdb] Assuming drive cache: write through
Mar 26 10:45:56 cent01 kernel: sdb: sdb1
Mar 26 10:47:03 cent01 kernel: kjournald starting.  Commit interval 5 seconds
Mar 26 10:47:03 cent01 kernel: EXT3 FS on sdb1, internal journal
Mar 26 10:47:03 cent01 kernel: EXT3-fs: mounted filesystem with ordered data mode.
Mar 26 10:54:39 cent01 kernel: ata1: soft resetting link
Mar 26 10:54:39 cent01 kernel: ata1: EH complete
Mar 26 10:54:42 cent01 kernel: ata2: soft resetting link
Mar 26 10:54:42 cent01 kernel: ata2.00: configured for UDMA/33
Mar 26 10:54:42 cent01 kernel: ata2: EH complete
[root@cent01 ~]#

You can also look at the output of "fdisk -l" and see the following:

Disk /dev/sdb: 17.2 GB, 17179869184 bytes
64 heads, 32 sectors/track, 16384 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000

Disk /dev/sdb doesn't contain a valid partition table

So our new Disk has been assigned /dev/sdb

Now we have to partition it, and put a filesystem on it:

we will do the following:

fdisk /dev/sdb
then go through the prompts and create a partition for the whole 17Gb virtual disk:


after the partition has been created, now format it with ext3 filesystem:

mkfs.ext3 /dev/sdb1





As you can see by the screenshot above, the partition was formatted, we will now 
create a mount point:

mkdir /extra16Gb
 

and then mount this device on this mount point:

mount /dev/sdb1  /extra16Gb/

You can see that we can create a file on the new mountpoint, and that it has the expected space on it.

One last thing, is to add this to /etc/fstab, as when this machine will reboot, you want this new disk mounted at boot time.  So we will edit /etc/fstab and add
this disk:


You can test if this works by unmounting the device:


[root@cent01 ~]# umount /extra16Gb/


and do a mount all:


[root@cent01 ~]# mount -a
[root@cent01 ~]#



Then see if this new device is now mounted:


[root@cent01 ~]# df -h
Filesystem            Size  Used Avail Use% Mounted on
/dev/mapper/vg_cent01-lv_root
                       15G  9.6G  4.1G  71% /
tmpfs                 2.9G   76K  2.9G   1% /dev/shm
/dev/sda1             485M   44M  417M  10% /boot
10.0.10.11:/vol/NFSvol1
                       50G   44G  7.0G  87% /opt2
/dev/sdb1              16G  173M   15G   2% /extra16Gb

[root@cent01 ~]#




And as you can see, it's showing up correctly.  The VMware guest now has an additional virtualized storage device. The works for all physical block devices, this includes CD-ROM, DVD and floppy devices.


No comments:

Post a Comment