linux添加新LUN,无需重启

linux添加新LUN,无需重启

在给存储增加新的Lun时,在linux下一般是:

A.重启操作系统
B.重启HBA卡驱动

1. kudzu
添加完新硬盘后,运行命令kudzu重新扫描新的硬件设备,类似aix的cfgmgr

eg:
[[email protected]]#  kudzu -p | more
-
class: OTHER
bus: PCI
detached: 0
driver: shpchp
desc: "VMware PCI Express Root Port"
vendorId: 15ad
deviceId: 07a0
subVendorId: 0000
subDeviceId: 0000
pciType: 1
pcidom:    0
pcibus:  0
pcidev: 18
pcifn:  7
-
class: OTHER
bus: PCI
detached: 0
driver: shpchp
desc: "VMware PCI Express Root Port"
vendorId: 15ad
deviceId: 07a0

官方解释:
DESCRIPTION
       kudzu  detects  and configures new and/or changed hardware on a system.
    When started, kudzu detects the current hardware, and checks it against
    a database stored in /etc/sysconfig/hwconf, if  one  exists.  It
       then determines if any hardware has been added or removed from the system.
    If so, it gives the users the opportunity to configure any added hardware,
    and unconfigure any removed hardware. It then  updates  the database 
    in /etc/sysconfig/hwconf.

2.直接修改文件权限,让系统重新扫描新的硬件设备

在RHEL4,5之下,在/sys/class/scsi_host/hostX文件系统中找到对应的卡的目录,
会存在一个文件叫做scan。该文件的权限只有write,没有read。
只需要执行echo "- - -" > scan即可扫描对应的新LUN

查看机器有几块HBA卡
[[email protected]] ls /sys/class/fc_host/
host1

[[email protected]~]# ls /sys/class/scsi_host/host0/
cmd_per_lun  hba_bios_version     host_busy    model       scan           state      unchecked_isa_dma
device       hba_kernel_version   max_channel  proc_name   serial_number  subsystem  unique_id
flags        hba_monitor_version  max_id       reset_host  sg_tablesize   uevent     vendor

[[email protected]~]# ls -l /sys/class/scsi_host/host0/scan
--w------- 1 root root 4096 Dec 12 18:51 /sys/class/scsi_host/host0/scan

修改文件“scan”权限,
[[email protected]~]# echo "- - -" > /sys/class/scsi_host/host0/scan

查看
[[email protected]~]# fdisk -l

记录一篇英文参考:

Dynamically adding storage for use with multipath I/O

This document (3000817) is provided subject to the disclaimer at the end of this document.
Environment
SUSE Linux Enterprise Server 10
SUSE Linux Enterprise Server 9
Novell Open Enterprise Server (Linux based)

SAN suited for multiple paths to storage

The Linux installation has already been configured to use Device-Mapper Multipath I/O (DM-MPIO) per the article "How to setup / use multipathing on SLES".

The Linux driver for the host base adapters (HBAs) on the system supports rescanning the HBA to detect the addition or deletion of storage areas ("SAN disks"). For example, a QLogic or Emulex HBA is being used.

The system has been booted with kernel parameters for SCSI device scanning that are appropriate for the SCSI device numbering plan being followed in the SAN and for the SCSI levels reported by the HBAs as discussed in TID 3955167 - Troubleshooting SCSI (LUN) scanning issues.
Situation
Purpose
Adding SAN storage to the Linux system and setting up multiple I/O paths to it without needing to reboot the system. 
Resolution
Follow these steps to allocate new storage on the SAN, make it visible to the Linux system and use it to create new filesystems or to expand existing filesystems residing on logical volumes:
Allocate the storage on the SAN and update its access control settings to allow the Linux system access to the new storage. How this is done in detail is highly dependent on the components of the SAN and its architecture; refer to the SAN vendor‘s documentation for details.

On the Linux system, instruct the HBA driver to rescan the SAN to discover the new storage area ("LUN"). The exact commands depend on the kernel version and driver.

With SLES10, a LIP (Loop Initialization Procedure) can be issued to both Qlogic and Emulex drivers through sysfs:
echo 1 > /sys/class/fc_host/host/issue_lip

With SLES9 and OES/Linux, the Qlogic and Emulex drivers require different commands for rescanning. For example, for a QLogic 2300 HBA, the command is
echo scsi-qlascan > /proc/scsi/qla2xxx/
whereas for an Emulex HBA, it is
echo 1 > /sys/class/scsi_host/host/issue_lip

If the HBA driver supports it, check that the new disk is seen by the HBA driver correctly (at this point, the newly added LUN will not yet be known to the higher layers of the Linux kernel‘s SCSI subsystem and will not yet be usable).

With SLES10, after the LIP, a directory for the new disk should have been created under /sys/class/fc_remote_ports/ containing information such as port ID and port name.

With SLES9 or OES/Linux, for a QLogic 2300 HBA, run
less /proc/scsi/qla2xxx/
and check the "SCSI LUN information" section. The entries for the newly added disks are indicated by a "*" after the flags.
Unfortunately, there is no equivalent for Emulex cards.

Make the new device known to the middle layer of the Linux kernel‘s SCSI subsystem. This can be done in two ways.
Through the
rescan-scsi-bus.sh
command which rescans the SCSI subsystem for changes. Depending on the SCSI device numbering plan in use, arguments may need to be used to enlarge the scope of the search or to control it more carefully, e.g through
rescan-scsi-bus.sh -l -w -c
which will search LUNs other than 0, scan for more device IDs and for more channels, or through
rescan-scsi-bus.sh --hosts="hostlist" --channels="channellist" --ids="idlist" --luns="lunlist"
Alternatively, one can
echo "scsi add-single-device 0 1 2 3" > /proc/scsi/scsi
to add the storage with host ID 0, channel ID 1, target ID 2, LUN ID 3, or, with kernel 2.6.5-7.257 or newer,
echo "- - -" > /sys/class/scsi_host/host/scan
to rescan all targets on a host.

Run
multipath
to have the new devices be picked up for DM-MPIO.
Examine /dev/disk/by-id to identify the persistent device names for the new storage area(s) and use the persistent device names for further operations (including filesystem creation and addition to /etc/fstab).
If LVM is to be used for the new storage area(s), configure LVM at this point, either through YaST or using the LVM command line tools, starting with pvcreate.

时间: 2024-12-15 07:16:00

linux添加新LUN,无需重启的相关文章

Linux 添加新分区

Linux系统由于数据累计增长.前期存储规划不合理等诸多因素,出现存储不够用的情况时,此时就需要扩展逻辑分区或添加新的逻辑分区.下面介绍一下通过使用fdsik添加新的逻辑分区. 首先使用df命令检查文件系统的磁盘空间占用情况 [[email protected]~]# df -h Filesystem Size Used Avail Use% Mounted on /dev/mapper/VolGroup00-sda3 30G 2.4G 26G 9% / /dev/sda1 99M 23M 71

Linux添加新硬盘自动挂载硬盘

Linux添加新硬盘自动挂载硬盘的具体步骤 1.插入新硬盘,启动Linux服务器,使用fdisk -l 查看硬盘 #fdisk -l Disk /dev/sdb: 1000.2 GB, 1000204886016 bytes 2.格式化硬盘 #mkfs -t ext4 /dev/sdb 3.挂载硬盘 #mount 硬盘地址 要挂载的地址 #mount /dev/sdb /media/imgs 4.实现系统重启后自动挂载该分区 #vi /etc/fstab 在最后一行添加 /dev/sdb /me

linux添加静态路由表,重启继续生效

在日常的使用中,或者在服务器中,有两个网卡配置两个地址,访问不同的网络段,这种情况是非常常见的现象,但是,我们需要额外的添加路由表来决定发送的数据包经过正确的网关和interface才能正确的进行通信 今天来介绍在linux操作系统中如何添加路由(主要针对rhel系列,测试平台为rhel5.4) 一.使用route命令添加临时路由 添加到主机的路由 # route add -host 192.168.1.123 dev eth0 # route  add -host 192.168.1.123

linux添加新硬盘不需要重启识盘

 添加新物理硬盘 用ssh工具连接到服务器,执行:fdisk -l 查看磁盘,并没有新加的硬盘 fdisk -l查看硬盘及分区状态   查看主机总线号,命令:ls /sys/class/scsi_host/   重新扫描SCSI总线,以添加新设备: echo "- - -">/sys/class/scsi_host/host0/scan echo "- - -">/sys/class/scsi_host/host1/scan echo "- -

Virtualbox中Linux添加新磁盘并创建分区

原文:https://www.linuxidc.com/Linux/2017-01/139616.htm ------------------------------------------------------------------ 引言:我们常常在使用系统的时候突然发现,哎呦~~~我们的磁盘空间不够用啦!我遇到常见的就是数据库数据暴增,预留的空间没有啦,只好新添加磁盘,在VB虚拟机上就可以实现,往往苦于没有图文并茂的好资料,下面我来为大家简单快捷的实操示范一下,做一名"实操族"

linux 添加新硬盘的方法

在服务器上把硬盘接好,启动linux,以root登陆. 比如我新加一块SCSI硬盘,需要将其分成三个区: #fdisk /dev/sdb 进入fdisk模式: Command (m for help):p  //查看新硬盘的分区 Command (m for help):n  //创建新分区 可以用m命令来看fdisk命令的内部命令:n命令创建一个新分区:d命令删除一个存在的分区:p命令显示分区列表:t命令修改分区的类型ID号:l命令显示分区ID号的列表:a命令指定启动分区:w命令是将对分区表的

Linux 添加新用户账号并赋予root权限

除了root用户之外,通常需要为每个管理创建各自的用户账号,方便每个管理员登录使用, 步骤如下: 1.  添加新用户账号 useradd  mary.lee 2.  为新用户账号设置密码 passwd [email protected] 3. 为新用户账号赋予root权限 usermod -a -G root mary.lee 原文地址:https://www.cnblogs.com/yuzg/p/10774147.html

Linux 添加新磁盘,在线扩充空间

CentOS 7开发环境中的home 目录空间满了,需要增加空间 到虚拟机上执行"ls /sys/class/scsi_host",然后重新扫描SCSI总线来添加设备.如右图.然后执行"fdsik -l"来验证是否添加成功. 2.分区前准备yum -y install parted [[email protected] ~]# partprobe[[email protected] ~]# partprobe /dev/sda3 ps:使用fdisk工具只是将分区信

Linux添加新盘扩容空间

添加磁盘扩容操作: 1.添加物理磁盘到服务器重启服务器,#fdisk -l查看识别磁盘(以/dev/sdb为例) [ ~]# fdisk -l Disk /dev/sda: 42.9 GB, 42949672960 bytes 255 heads, 63 sectors/track, 5221 cylinders Units = cylinders of 16065 * 512 = 8225280 bytes Sector size (logical/physical): 512 bytes /