how to add lun

In our daily work many SAs would come across such problem,one Linux server is for critical task,and there's not enough disk space,and you're asked to add more disk space,also new LUN to the very server without rebooting it.

     In Windows server this would be simple,you just have to click several mouse to accomplish this task in the disk manager of the device manager,all of these are online operations.

    I used to reboot the server without take much care about the service to get the new added lun, but now,this should be NO for new SLA.

  Ok,here we will discuss about the steps about the subject.

  Firstly, these steps could be used for both iSCSI and FC SAN.

 when we add a new lun,just follow up:

1、Configure your storage.create virtual disk or some what lun.

2、Configure your  hosts in the storage server,For iSCSI,you'd add an IQN of your client;For FC,you'd like to add a WWN.

PS:one thing  matters is that  if you configure it with Fabric environment,say there're san switches,then make sure that the san switch could read your HBA's WWN.

 

Yes,this may be neglected, but it's one of the critical point.I used to forget to configure the zone ,so whatever scripts or command i tried to,no LUNs came out.

3、On the storage server,you should map or present the LUN to the host,usually this configuration is simple according to the venders.

4、Then you should operate on the host server.first,I recommand to install a package for listing scsi devices:lsscsi.

 

 

5、Then to discovry the LUN  you've just mapped.

On usual,if you have already attahced some luns from the storage server you just opreated,then you can do the following:

#lsscsi     ##list SCSI devices (or hosts) and their attributes

[1:0:0:0]    cd/dvd  NECVMWar VMware IDE CDR10 1.00  /dev/sr0
[2:0:0:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sda
[2:0:1:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdb
[2:0:2:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdc
[2:0:3:0]    disk    VMware,  VMware Virtual S 1.0   /dev/sdd
so if you add a lun which comes from the same storage,then H,C,L would be easy to determine.if I add a new lun or disk ,then it may be [2:0:4:0],right?

then you can use the following commands:

 

 
 
  1. # echo "scsi add-single-device 2 0 4 0" > /proc/scsi/scsi  
  2.  
  3. # tail /var/log/messages    
  4.  
  5. # fdisk -l                  ##something new would appear.  
  6.  

 

unfortunately,in my system, I‘ve nerver used a  FC storage,and my lsscsi seems like this :

 

 

I found that 2:0:0:0 is a iSCSI device,and 1:0:X:0 are FC devices,so i would think if i add a new FC lun,the HOST(H) would be 1!  Why is 1? Ok here we go,i have got 2 HBA adapters:

 

 
 
  1. #systool -v -c fc_host 

one is host0,one is host1.so if there's multipath device ,then may be there would be 0:0:X:0 and 1:0:X:0.
 

6、Scan the newly add LUN

 
 
  1. # echo "- - -" > /sys/class/scsi_host/host0/scan  
  2. # echo "- - -" > /sys/class/scsi_host/host1/scan  

 This is why i mentioned 0:0:X:0 and 1:0:X:0 and host0,host1.the output of mine would be like this:

 

then we can see the newly added devices:

 
 
  1. #lsscsi 

of course,wo have 2 adpaters,so the H is 0 and,and the B for BUS is 0 for both,the T for TARGET is 0,1,2... and last L for LUN,this digital would be determined  by your storage configuration.Mine is lun 1,so it's 1 for the host,and 0 for the storage! This would be more clearly:

7、Ok,here we've already got the newly add lun,i've two adapters online and two controllers on the storage server,so there would be multipath devices.So i have to configure it.

I configure it with device-mapper service :

till now,it's Ok.

 

Conclusions:

if you want to hot add a new lun for your linux system,there would be 2 ways:

1、script: for RedHat,install a rpm package:sg3_utils,then it would generate a script in /usr/bin/rescan-scsi-bus.sh,For SuSe,it would be /bin/rescan-scsi-bus.sh

2、(1)# echo "scsi add-single-device X Y Z W" > /proc/scsi/scsi

The above example would add a device on controller X(HOST), bus Y, target Z, lun W. Change the values according to the position and settings of the device that was added.
 

      (2) # echo "c t l" >  /sys/class/scsi_host/hostH/scan

where H is the HBA number, c is the channel on the HBA, t is the SCSI target ID, and l is the LUN

In RHEL6,  echo "scsi add-single-device X Y Z W" > /proc/scsi/scsi   is deprecated.

 

 

Quot from RedHat:

HP Smart Array controllers use the cciss driver. This driver does not present disk or array devices to the Linux SCSI subsystem and users should use the vendor provided management tools to configure and enable new disks or disk arrays.

For tape devices, media changers and other serial access devices the CCISS controller will register devices with the SCSI subsystem. If new tapes or medium changers are added to a running system, they will not be seen by the system until the CCISS scsi bus is re-scanned. This happens automatically on reboot. If a reboot is not possible or desirable, the following commands can be used. First, a rescan is done to inform the cciss driver about the changes to the SCSI bus:

$ echo "rescan" > /proc/driver/cciss/cciss0

Then, add an individual device with:

$ echo scsi add-single-device 3 2 1 0 > /proc/scsi/scsi

The above example would add a device on controller 3, bus 2, target 1, lun 0. Change the values according to the position and settings of the device that was added.

It is important to note that this operation will not affect any disks or RAID arrays presented to the system via the CCISS controller.

I tried,but it doesn't work out!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值