How to hot add lun to Linux server without rebooting
2012-11-20 00:58
393 查看
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:
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:
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
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:
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
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
Then, add an individual device with:
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!
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:
# echo "scsi add-single-device 2 0 4 0" > /proc/scsi/scsi # tail /var/log/messages # fdisk -l ##something new would appear.
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:
#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
# echo "- - -" > /sys/class/scsi_host/host0/scan # 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:
#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
ccissdriver. 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
ccissdriver 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!
相关文章推荐
- How to Add Linux Host to Nagios Monitoring Server Using NRPE Plugin
- How to add a new user in linux and add it to a new group
- What is EPOLL? EPOLL vs Select call? And How to implement UDP server in Linux using EPOLL?
- How do I add more disk space to a virtual guest using LVM on Red Hat Enterprise Linux?
- Linux: How to Configure the DNS Server for 11gR2 SCAN [ID 1107295.1]
- How to add ppa repository on kali linux
- SQL Server 2005: how to add a linked server
- How to build DHCP&NTP server on Linux(Ubuntu)
- How can I add a user to a group under Linux operating system?
- How to attach to running target w/o reset from Linux JLinkGDBServer
- How to Add Windows Host to Nagios Monitoring Server
- What is EPOLL? Epoll vs Poll vs Select call ? And How to implement UDP server in Linux using EPOLL?
- 本周技术关注:ISP-Server Setup - Ubuntu 5.10 'Breezy Badger' | HowtoForge - Linux Howtos and Tutorials
- How to Sync Your Linux Server Time with Network Time Servers (NTP)
- How to delete duplicate rows without children in sql server
- Zyxel Switch-How to block a fake DHCP server without enabling DHCP snooping?
- Linux: How to delete a disk or LUN reference from /dev
- how to add lun
- How to Clear the Application Server Cache Without Shutting it Down