You can check the LUN (Logical Unit Number) size in Linux using various commands depending on the tools available on your system and how the LUNs are presented (e.g., directly attached storage, iSCSI, Fibre Channel). Here's a breakdown of common methods:
1. Using lsblk
lsblk
(list block devices) is a utility for listing information about block devices. It's a straightforward way to find the size of a LUN.
lsblk
This command will display a list of all block devices, including LUNs, along with their sizes. Look for entries that correspond to your LUNs (you might need to identify them by their device name, such as /dev/sda
, /dev/sdb
, etc.). The "SIZE" column will show the size of the LUN.
Example Output:
NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
sda 8:0 0 100G 0 disk
sdb 8:16 0 50G 0 disk
sdc 8:32 0 200G 0 disk
In this example, sda
, sdb
, and sdc
could represent LUNs with sizes 100GB, 50GB, and 200GB, respectively.
2. Using fdisk
fdisk
is a disk partitioning utility that can also provide information about disk sizes.
sudo fdisk -l /dev/sdX
Replace /dev/sdX
with the actual device name of the LUN you want to check (e.g., /dev/sda
, /dev/sdb
). The output will include the disk size in sectors and a more human-readable format.
Example Output:
Disk /dev/sda: 107.4 GB, 107374182400 bytes, 209715200 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disklabel type: dos
Disk identifier: 0x1234abcd
This output shows that /dev/sda
has a size of 107.4 GB.
3. Using multipath -ll
(for Multipath Devices)
If your LUNs are presented through multipathing (which is common in enterprise environments), you can use multipath -ll
to get information. This command shows information about multipath devices, which aggregate multiple paths to the same LUN.
multipath -ll
The output will show details about each multipath device, including its size. This command might also help you identify the LUN ID as shown in the short answer in the references.
Example Output
mpatha (3600a098038303038474e596d68347567) dm-0 HP,MSA2312i SAN
size=200G features='3 queue_if_no_path pg_init_retries 50' hwhandler='1 alua' alua_inq=1
|_ round robin 0 [prio=50][active]
| |_ 1:0:0:0 sda 8:0 [active][ready]
|_ round robin 0 [prio=10][enabled]
| |_ 2:0:0:0 sdb 8:16 [active][ready]
The 'size=200G' attribute shows the LUN size.
4. Using sg_inq
(for SCSI devices)
sg_inq
(SCSI generic inquiry) is a low-level utility to query SCSI devices. You'll need the sg3_utils
package installed.
sg_inq /dev/sdX
Replace /dev/sdX
with the appropriate device. The output will contain information about the device, including its capacity.
Example Output:
standard INQUIRY:
PQual=0 Device_type=0 RMB=0 LU_CONG=0 version=0x06 response_format=2
additional_length=31
[BProtect=0][RelAdr=0][WBus16=0][Sync=0][Linked=0][TranDis=0][CmdQue=1]
vendor: HITACHI
product: H101460SUN600G
revision: A150
...
[pmi=0][aenc=0][tpe=0][protect=0][app_bytes=0]
Unit serial number: 0607DAK0C8
iSCSI name: iqn.1992-08.com.emc:cx4-469.ap_storage.53e34b11076e4c11
extended INQUIRY data:
INQUIRY duration=0 current_q_depth=1
...
Maximum LUN supported=16383 (0x3fff)
LUN reset delay=0 seconds
command queuing parameters follow:
Maximum queue depth=254
...
WRITE SAME: not supported
REPORT LUNS supported
Long id descriptor format supported, relative target port identifier is preferred
Target port support asymetric logical unit access (ALUA)
Additional bytes from standard INQUIRY follow: none
This provides low-level information, but not a direct size. You might need to combine this with other tools to determine the exact usable size.
Considerations
- Device Naming: Be absolutely certain you're identifying the correct device. Incorrectly identifying a device and running commands on it can lead to data loss.
- Root Privileges: Many of these commands require root privileges (using
sudo
). - Storage Technologies: The best method depends on how the LUNs are presented to the Linux system. Multipathing and iSCSI setups will have different tools and considerations.